Skip to content

Commit

Permalink
unit-tests: allow running as user
Browse files Browse the repository at this point in the history
  • Loading branch information
neolynx committed Dec 3, 2024
1 parent b10cd66 commit 22cd4e2
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 8 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ swagger: swagger-install

etcd-install:
# 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 system/
Expand Down
4 changes: 2 additions & 2 deletions system/lib.py
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ def prepare_fixture(self):
os.environ["HOME"], self.aptlyDir, "pool"), ignore=shutil.ignore_patterns(".git"))

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")])

if self.fixtureDB and self.databaseType != "etcd":
Expand All @@ -258,7 +258,7 @@ def prepare_fixture(self):

if self.fixtureDB:
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")
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)
Expand Down
15 changes: 11 additions & 4 deletions system/t13_etcd/install-etcd.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,16 @@
ETCD_VER=v3.5.2
DOWNLOAD_URL=https://storage.googleapis.com/etcd

if [ ! -e /tmp/etcd-${ETCD_VER}-linux-amd64.tar.gz ]; then
curl -L ${DOWNLOAD_URL}/${ETCD_VER}/etcd-${ETCD_VER}-linux-amd64.tar.gz -o /tmp/etcd-${ETCD_VER}-linux-amd64.tar.gz
ARCH=""
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

mkdir /srv/etcd
tar xf /tmp/etcd-${ETCD_VER}-linux-amd64.tar.gz -C /srv/etcd --strip-components=1
mkdir /tmp/aptly-etcd
tar xf /tmp/etcd-${ETCD_VER}-linux-$ARCH.tar.gz -C /tmp/aptly-etcd --strip-components=1
2 changes: 1 addition & 1 deletion system/t13_etcd/start-etcd.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ finish()
}
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
etcdpid=`cat /tmp/etcd.pid`
wait $etcdpid
Expand Down

0 comments on commit 22cd4e2

Please sign in to comment.