diff --git a/Makefile b/Makefile index 1ee616d8..ffe2e8a3 100644 --- a/Makefile +++ b/Makefile @@ -7,6 +7,9 @@ COVERAGE_DIR?=$(shell mktemp -d) GOOS=$(shell go env GOHOSTOS) GOARCH=$(shell go env GOHOSTARCH) +# Unit Tests and some sysmte tests rely on expired certificates, turn back the time +export TEST_FAKETIME := 2025-01-02 03:04:05 + # export CAPUTRE=1 for regenrating test gold files ifeq ($(CAPTURE),1) CAPTURE_ARG := --capture @@ -90,7 +93,7 @@ test: prepare swagger etcd-install ## Run unit tests (add TEST=regex to specify @echo "\e[33m\e[1mStarting etcd ...\e[0m" @mkdir -p /tmp/aptly-etcd-data; system/t13_etcd/start-etcd.sh > /tmp/aptly-etcd-data/etcd.log 2>&1 & @echo "\e[33m\e[1mRunning go test ...\e[0m" - faketime '2025-01-02 03:04:05' go test -v ./... -gocheck.v=true -check.f "$(TEST)" -coverprofile=unit.out; echo $$? > .unit-test.ret + faketime "$(TEST_FAKETIME)" go test -v ./... -gocheck.v=true -check.f "$(TEST)" -coverprofile=unit.out; echo $$? > .unit-test.ret @echo "\e[33m\e[1mStopping etcd ...\e[0m" @pid=`cat /tmp/etcd.pid`; kill $$pid @rm -f /tmp/aptly-etcd-data/etcd.log @@ -104,7 +107,7 @@ system-test: prepare swagger etcd-install ## Run system tests if [ ! -e ~/aptly-fixture-pool ]; then git clone https://github.com/aptly-dev/aptly-fixture-pool.git ~/aptly-fixture-pool/; fi test -f ~/etcd.db || (curl -o ~/etcd.db.xz http://repo.aptly.info/system-tests/etcd.db.xz && xz -d ~/etcd.db.xz) # Run system tests - PATH=$(BINPATH)/:$(PATH) FORCE_COLOR=1 faketime '2025-01-02 03:04:05' $(PYTHON) system/run.py --long --coverage-dir $(COVERAGE_DIR) $(CAPTURE_ARG) $(TEST) + PATH=$(BINPATH)/:$(PATH) FORCE_COLOR=1 $(PYTHON) system/run.py --long --coverage-dir $(COVERAGE_DIR) $(CAPTURE_ARG) $(TEST) bench: @echo "\e[33m\e[1mRunning benchmark ...\e[0m" diff --git a/system/lib.py b/system/lib.py index 3f95b102..f7761997 100644 --- a/system/lib.py +++ b/system/lib.py @@ -130,6 +130,7 @@ class BaseTest(object): sortOutput = False debugOutput = False EtcdServer = None + faketime = False aptlyDir = ".aptly" aptlyConfigFile = ".aptly.conf" @@ -311,6 +312,9 @@ class BaseTest(object): aptly_testing_bin = Path(__file__).parent / ".." / "aptly.test" command = [str(aptly_testing_bin), f"-test.coverprofile={Path(self.coverage_dir) / self.__class__.__name__}-{uuid4()}.out", *command[1:]] + if self.faketime: + command = ["faketime", os.environ.get("TEST_FAKETIME", "2025-01-02 03:04:05")] + command + environ = os.environ.copy() environ["LC_ALL"] = "C" environ.update(self.environmentOverride) diff --git a/system/s3_lib.py b/system/s3_lib.py index 4a52b9ad..6e622b2d 100644 --- a/system/s3_lib.py +++ b/system/s3_lib.py @@ -24,7 +24,9 @@ class S3Test(BaseTest): s3Overrides = {} def fixture_available(self): - return super(S3Test, self).fixture_available() and s3_conn is not None + return super(S3Test, self).fixture_available() and \ + 'AWS_SECRET_ACCESS_KEY' in os.environ and 'AWS_ACCESS_KEY_ID' in os.environ and \ + os.environ['AWS_SECRET_ACCESS_KEY'] != "" and os.environ['AWS_ACCESS_KEY_ID'] != "" def prepare(self): self.bucket_name = "aptly-sys-test-" + str(uuid.uuid1()) diff --git a/system/t04_mirror/create.py b/system/t04_mirror/create.py index a2cdbf74..351bb20e 100644 --- a/system/t04_mirror/create.py +++ b/system/t04_mirror/create.py @@ -416,6 +416,7 @@ class CreateMirror31Test(BaseTest): runCmd = "aptly mirror create --keyring=aptlytest-gpg1.gpg mirror11 http://repo.aptly.info/system-tests/archive.debian.org/debian-archive/debian/ stretch" configOverride = {"gpgProvider": "internal", "max-tries": 1} fixtureGpg = True + faketime = True def outputMatchPrepare(self, s): return re.sub(r'Signature made .* using', '', s)