unit-tests: allow running as user

This commit is contained in:
André Roth
2024-12-03 19:03:21 +08:00
parent 3d8968eff3
commit 280563caa8
4 changed files with 15 additions and 8 deletions

View File

@@ -62,7 +62,7 @@ swagger: swagger-install
etcd-install: etcd-install:
# Install etcd # Install etcd
test -d /srv/etcd || system/t13_etcd/install-etcd.sh test -d /tmp/aptly-etcd || system/t13_etcd/install-etcd.sh
flake8: ## run flake8 on system test python files flake8: ## run flake8 on system test python files
flake8 system/ flake8 system/

View File

@@ -242,7 +242,7 @@ class BaseTest(object):
os.environ["HOME"], self.aptlyDir, "pool"), ignore=shutil.ignore_patterns(".git")) os.environ["HOME"], self.aptlyDir, "pool"), ignore=shutil.ignore_patterns(".git"))
if self.databaseType == "etcd": if self.databaseType == "etcd":
if not os.path.exists("/srv/etcd"): if not os.path.exists("/tmp/aptly-etcd"):
self.run_cmd([os.path.join(os.path.dirname(inspect.getsourcefile(BaseTest)), "t13_etcd/install-etcd.sh")]) self.run_cmd([os.path.join(os.path.dirname(inspect.getsourcefile(BaseTest)), "t13_etcd/install-etcd.sh")])
if self.fixtureDB and self.databaseType != "etcd": if self.fixtureDB and self.databaseType != "etcd":
@@ -258,7 +258,7 @@ class BaseTest(object):
if self.fixtureDB: if self.fixtureDB:
print("import etcd") print("import etcd")
self.run_cmd(["/srv/etcd/etcdctl", "--data-dir=/tmp/etcd-data", "snapshot", "restore", os.path.join(os.environ["HOME"], "etcd.db")]) self.run_cmd(["/tmp/aptly-etcd/etcdctl", "--data-dir=/tmp/aptly-etcd-data", "snapshot", "restore", os.path.join(os.environ["HOME"], "etcd.db")])
print("starting etcd") print("starting etcd")
self.EtcdServer = self._start_process([os.path.join(os.path.dirname(inspect.getsourcefile(BaseTest)), "t13_etcd/start-etcd.sh")], stdout=subprocess.PIPE, stderr=subprocess.PIPE) self.EtcdServer = self._start_process([os.path.join(os.path.dirname(inspect.getsourcefile(BaseTest)), "t13_etcd/start-etcd.sh")], stdout=subprocess.PIPE, stderr=subprocess.PIPE)

View File

@@ -4,9 +4,16 @@
ETCD_VER=v3.5.2 ETCD_VER=v3.5.2
DOWNLOAD_URL=https://storage.googleapis.com/etcd DOWNLOAD_URL=https://storage.googleapis.com/etcd
if [ ! -e /tmp/etcd-${ETCD_VER}-linux-amd64.tar.gz ]; then ARCH=""
curl -L ${DOWNLOAD_URL}/${ETCD_VER}/etcd-${ETCD_VER}-linux-amd64.tar.gz -o /tmp/etcd-${ETCD_VER}-linux-amd64.tar.gz case $(uname -m) in
x86_64) ARCH="amd64" ;;
aarch64) ARCH="arm64" ;;
*) echo "unsupported cpu arch"; exit 1 ;;
esac
if [ ! -e /tmp/etcd-${ETCD_VER}-linux-$ARCH.tar.gz ]; then
curl -L ${DOWNLOAD_URL}/${ETCD_VER}/etcd-${ETCD_VER}-linux-$ARCH.tar.gz -o /tmp/etcd-${ETCD_VER}-linux-$ARCH.tar.gz
fi fi
mkdir /srv/etcd mkdir /tmp/aptly-etcd
tar xf /tmp/etcd-${ETCD_VER}-linux-amd64.tar.gz -C /srv/etcd --strip-components=1 tar xf /tmp/etcd-${ETCD_VER}-linux-$ARCH.tar.gz -C /tmp/aptly-etcd --strip-components=1

View File

@@ -16,7 +16,7 @@ finish()
} }
trap finish INT trap finish INT
/srv/etcd/etcd --max-request-bytes '1073741824' --data-dir /tmp/etcd-data & /tmp/aptly-etcd/etcd --max-request-bytes '1073741824' --data-dir /tmp/aptly-etcd-data &
echo $! > /tmp/etcd.pid echo $! > /tmp/etcd.pid
etcdpid=`cat /tmp/etcd.pid` etcdpid=`cat /tmp/etcd.pid`
wait $etcdpid wait $etcdpid