forked from rancher/distros-test-framework
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'upstream/main'
- Loading branch information
Showing
43 changed files
with
921 additions
and
452 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,5 +7,5 @@ | |
*.terraform* | ||
*.tfstate* | ||
workloads/amd64/plan.yaml | ||
/config/product.yaml | ||
/config/.env | ||
/config/*.tfvars |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,86 +1,193 @@ | ||
include ./config.mk | ||
include ./config/.env | ||
|
||
TAG_NAME := $(if $(TAG_NAME),$(TAG_NAME),distros) | ||
|
||
TAGNAME ?= default | ||
|
||
.PHONY: test-env-up | ||
test-env-up: | ||
docker build . -q -f ./scripts/Dockerfile.build -t acceptance-test-${TAGNAME} | ||
@docker build . -q -f ./scripts/Dockerfile.build -t acceptance-test-${TAG_NAME} | ||
|
||
.PHONY: test-run | ||
test-run: | ||
@docker run -d --name acceptance-test-${IMGNAME} -t \ | ||
-e AWS_ACCESS_KEY_ID="${AWS_ACCESS_KEY_ID}" \ | ||
-e AWS_SECRET_ACCESS_KEY="${AWS_SECRET_ACCESS_KEY}" \ | ||
-v ${ACCESS_KEY_LOCAL}:/go/src/github.com/rancher/distros-test-framework/config/.ssh/aws_key.pem \ | ||
acceptance-test-${TAGNAME} sh -c 'cd ./entrypoint; \ | ||
if [ -n "${TESTDIR}" ]; then \ | ||
if [ "${TESTDIR}" = "upgradecluster" ]; then \ | ||
go test -timeout=45m -v ./upgradecluster/... -installVersionOrCommit "${INSTALLTYPE}"; \ | ||
elif [ "${TESTDIR}" = "versionbump" ]; then \ | ||
go test -timeout=45m -v -tags=versionbump ./versionbump/... -cmd "${CMD}" -expectedValue "${VALUE}" \ | ||
-expectedValueUpgrade "${VALUEUPGRADED}" -installVersionOrCommit "${INSTALLTYPE}" -channel "${CHANNEL}" -testCase "${TESTCASE}" \ | ||
-deployWorkload "${DEPLOYWORKLOAD}" -workloadName "${WORKLOADNAME}" -description "${DESCRIPTION}"; \ | ||
elif [ "${TESTDIR}" = "mixedoscluster" ]; then \ | ||
go test -timeout=45m -v -tags=mixedos ./mixedoscluster/...; \ | ||
fi; \ | ||
elif [ -z "${TESTDIR}" ]; then \ | ||
go test -timeout=45m -v ./createcluster/...; \ | ||
fi;' | ||
|
||
.PHONY: test-logs | ||
@docker run -dt --name acceptance-test-${IMG_NAME} \ | ||
-e AWS_ACCESS_KEY_ID=$${AWS_ACCESS_KEY_ID} \ | ||
-e AWS_SECRET_ACCESS_KEY=$${AWS_SECRET_ACCESS_KEY} \ | ||
--env-file ./config/.env \ | ||
-v ${ACCESS_KEY_LOCAL}:/go/src/github.com/rancher/distros-test-framework/config/.ssh/aws_key.pem \ | ||
-v ./scripts/test-runner.sh:/go/src/github.com/rancher/distros-test-framework/scripts/test-runner.sh \ | ||
acceptance-test-${TAG_NAME} && \ | ||
make image-stats IMG_NAME=${IMG_NAME} && \ | ||
make test-logs USE=IMG_NAME acceptance-test-${IMG_NAME} | ||
|
||
|
||
## Use this to run on the same environement + cluster from the previous last container -${TAGNAME} created | ||
test-run-state: | ||
DOCKER_COMMIT=$$? \ | ||
CONTAINER_ID=$(shell docker ps -a -q --filter ancestor=acceptance-test-${TAG_NAME} | head -n 1); \ | ||
if [ -z "$${CONTAINER_ID}" ]; then \ | ||
echo "No matching container found."; \ | ||
exit 1; \ | ||
else \ | ||
docker commit $$CONTAINER_ID teststate:latest; \ | ||
if [ $$DOCKER_COMMIT -eq 0 ]; then \ | ||
docker run -dt --name acceptance-test-${TEST_STATE} --env-file ./config/.env \ | ||
-e AWS_ACCESS_KEY_ID=${AWS_ACCESS_KEY_ID} \ | ||
-e AWS_SECRET_ACCESS_KEY=${AWS_SECRET_ACCESS_KEY} \ | ||
-v ${ACCESS_KEY_LOCAL}:/go/src/github.com/rancher/distros-test-framework/config/.ssh/aws_key.pem \ | ||
-v ./scripts/test-runner.sh:/go/src/github.com/rancher/distros-test-framework/scripts/test-runner.sh \ | ||
teststate:latest && \ | ||
make test-logs USE=TEST_STATE acceptance-test-${TEST_STATE} \ | ||
echo "Docker run exit code: $$?"; \ | ||
else \ | ||
echo "Failed to commit container"; \ | ||
exit 1; \ | ||
fi; \ | ||
fi | ||
|
||
## use this to test a new run on a totally new fresh environment after delete also aws resources | ||
test-complete: test-env-clean test-env-down remove-tf-state test-env-up test-run | ||
|
||
test-logs: | ||
@docker logs -f acceptance-test${IMGNAME} | ||
@if [ "${USE}" = "IMG_NAME" ]; then \ | ||
docker logs -f acceptance-test-${IMG_NAME}; \ | ||
elif [ "${USE}" = "TEST_STATE" ]; then \ | ||
docker logs -f acceptance-test-${TEST_STATE}; \ | ||
fi; | ||
|
||
image-stats: | ||
@./scripts/docker_stats.sh $$IMG_NAME 2>> /tmp/image-${IMG_NAME}_stats_output.log & | ||
|
||
.PHONY: test-env-down | ||
test-env-down: | ||
@echo "Removing containers and images" | ||
@docker stop $$(docker ps -a -q --filter="name=acceptance-test*") | ||
@docker rm $$(docker ps -a -q --filter="name=acceptance-test*") ; \ | ||
docker rmi --force $$(docker images -q --filter="reference=acceptance-test*") | ||
@echo "Removing containers" | ||
@docker ps -a -q --filter="name=acceptance-test*" | xargs -r docker rm -f 2>/tmp/container_${IMG_NAME}.log || true | ||
@echo "Removing acceptance-test images" | ||
@docker images -q --filter="reference=acceptance-test*" | xargs -r docker rmi -f 2>/tmp/container_${IMG_NAME}.log || true | ||
@echo "Removing dangling images" | ||
@docker images -q -f "dangling=true" | xargs -r docker rmi -f 2>/tmp/container_${IMG_NAME}.log || true | ||
@echo "Removing state images" | ||
@docker images -q --filter="reference=teststate:latest" | xargs -r docker rmi -f 2>/tmp/container_${IMG_NAME}.log || true | ||
|
||
.PHONY: test-env-clean | ||
test-env-clean: | ||
@./scripts/delete_resources.sh | ||
|
||
.PHONY: test-complete | ||
test-complete: test-env-clean test-env-down remove-tf-state test-env-up test-run | ||
|
||
#========================= Run acceptance tests locally =========================# | ||
.PHONY: remove-tf-state | ||
remove-tf-state: | ||
@rm -rf ./modules/${PRODUCT}/.terraform | ||
@rm -rf ./modules/${PRODUCT}/.terraform.lock.hcl ./modules/${PRODUCT}/terraform.tfstate ./modules/${PRODUCT}/terraform.tfstate.backup | ||
|
||
@rm -rf ./modules/${ENV_PRODUCT}/.terraform | ||
@rm -rf ./modules/${ENV_PRODUCT}/.terraform.lock.hcl ./modules/${ENV_PRODUCT}/terraform.tfstate ./modules/${ENV_PRODUCT}/terraform.tfstate.backup | ||
|
||
#========================= Run acceptance tests locally =========================# | ||
|
||
.PHONY: test-create | ||
test-create: | ||
@go test -timeout=45m -v ./entrypoint/createcluster/... | ||
@go test -timeout=45m -v -count=1 ./entrypoint/createcluster/... | ||
|
||
|
||
.PHONY: test-upgrade-suc | ||
test-upgrade-suc: | ||
@go test -timeout=45m -v -tags=upgradesuc ./entrypoint/upgradecluster/... -upgradeVersion ${UPGRADEVERSION} | ||
@go test -timeout=45m -v -tags=upgradesuc -count=1 ./entrypoint/upgradecluster/... -sucUpgradeVersion ${SUC_UPGRADE_VERSION} | ||
|
||
|
||
.PHONY: test-upgrade-manual | ||
test-upgrade-manual: | ||
@go test -timeout=45m -v -tags=upgrademanual ./entrypoint/upgradecluster/... -installVersionOrCommit ${INSTALLTYPE} | ||
@go test -timeout=45m -v -tags=upgrademanual -count=1 ./entrypoint/upgradecluster/... -installVersionOrCommit ${INSTALL_VERSION_OR_COMMIT} -channel ${CHANNEL} | ||
|
||
.PHONY: test-version-bump | ||
test-version-bump: | ||
-cmd "${CMD}" \ | ||
-expectedValue ${VALUE} \ | ||
-expectedValueUpgrade ${VALUEUPGRADED} \ | ||
-installVersionOrCommit ${INSTALLTYPE} -channel ${CHANNEL} \ | ||
-testCase "${TESTCASE}" -deployWorkload ${DEPLOYWORKLOAD} -workloadName ${WORKLOADNAME} -description "${DESCRIPTION}" | ||
|
||
.PHONY: test-create-mixedos | ||
test-create-mixedos: | ||
@go test -timeout=45m -v ./entrypoint/mixedoscluster/... | ||
@go test -timeout=45m -v -count=1 ./entrypoint/mixedoscluster/... $(if ${SONOBUOY_VERSION},-sonobuoyVersion ${SONOBUOY_VERSION}) | ||
|
||
.PHONY: test-create-dualstack | ||
test-create-dualstack: | ||
@go test -timeout=45m -v -count=1 ./entrypoint/dualstack/... | ||
|
||
.PHONY: test-version-bump | ||
test-version-bump: | ||
@go test -timeout=45m -v -count=1 ./entrypoint/versionbump/... -tags=versionbump \ | ||
-cmd "${CMD}" \ | ||
-expectedValue ${EXPECTED_VALUE} \ | ||
$(if ${VALUE_UPGRADED},-expectedValueUpgrade ${VALUE_UPGRADED}) \ | ||
$(if ${INSTALL_VERSION_OR_COMMIT},-installVersionOrCommit ${INSTALL_VERSION_OR_COMMIT}) \ | ||
$(if ${CHANNEL},-channel ${CHANNEL}) \ | ||
$(if ${TEST_CASE},-testCase "${TEST_CASE}") \ | ||
$(if ${WORKLOAD_NAME},-workloadName ${WORKLOAD_NAME}) \ | ||
$(if ${DESCRIPTION},-description "${DESCRIPTION}") \ | ||
$(if ${DEPLOY_WORKLOAD},-deployWorkload ${DEPLOY_WORKLOAD}) \ | ||
|
||
|
||
.PHONY: test-etcd-bump | ||
test-etcd-bump: | ||
@go test -timeout=45m -v -count=1 ./entrypoint/versionbump/... -tags=etcd \ | ||
-expectedValue ${EXPECTED_VALUE} \ | ||
$(if ${VALUE_UPGRADED},-expectedValueUpgrade ${VALUE_UPGRADED}) \ | ||
$(if ${INSTALL_VERSION_OR_COMMIT},-installVersionOrCommit ${INSTALL_VERSION_OR_COMMIT}) \ | ||
$(if ${CHANNEL},-channel ${CHANNEL}) \ | ||
$(if ${TEST_CASE},-testCase "${TEST_CASE}") \ | ||
$(if ${WORKLOAD_NAME},-workloadName ${WORKLOAD_NAME}) \ | ||
$(if ${DEPLOY_WORKLOAD},-deployWorkload ${DEPLOY_WORKLOAD}) | ||
|
||
|
||
.PHONY: test-runc-bump | ||
test-runc-bump: | ||
@go test -timeout=45m -v -count=1 ./entrypoint/versionbump/... -tags=runc \ | ||
-expectedValue ${EXPECTED_VALUE} \ | ||
$(if ${VALUE_UPGRADED},-expectedValueUpgrade ${VALUE_UPGRADED}) \ | ||
$(if ${INSTALL_VERSION_OR_COMMIT},-installVersionOrCommit ${INSTALL_VERSION_OR_COMMIT}) \ | ||
$(if ${CHANNEL},-channel ${CHANNEL}) \ | ||
$(if ${TEST_CASE},-testCase "${TEST_CASE}") \ | ||
$(if ${WORKLOAD_NAME},-workloadName ${WORKLOAD_NAME}) \ | ||
$(if ${DEPLOY_WORKLOAD},-deployWorkload ${DEPLOY_WORKLOAD}) | ||
|
||
|
||
.PHONY: test-cilium-bump | ||
test-cilium-bump: | ||
@go test -timeout=45m -v -count=1 ./entrypoint/versionbump/... -tags=cilium \ | ||
-expectedValue ${EXPECTED_VALUE} \ | ||
$(if ${VALUE_UPGRADED},-expectedValueUpgrade ${VALUE_UPGRADED}) \ | ||
$(if ${INSTALL_VERSION_OR_COMMIT},-installVersionOrCommit ${INSTALL_VERSION_OR_COMMIT}) \ | ||
$(if ${CHANNEL},-channel ${CHANNEL}) \ | ||
$(if ${TEST_CASE},-testCase "${TEST_CASE}") \ | ||
$(if ${WORKLOAD_NAME},-workloadName ${WORKLOAD_NAME}) \ | ||
$(if ${DEPLOY_WORKLOAD},-deployWorkload ${DEPLOY_WORKLOAD}) | ||
|
||
|
||
.PHONY: test-canal-bump | ||
test-canal-bump: | ||
@go test -timeout=45m -v -count=1 ./entrypoint/versionbump/... -tags=canal \ | ||
-expectedValue ${EXPECTED_VALUE} \ | ||
$(if ${VALUE_UPGRADED},-expectedValueUpgrade ${VALUE_UPGRADED}) \ | ||
$(if ${INSTALL_VERSION_OR_COMMIT},-installVersionOrCommit ${INSTALL_VERSION_OR_COMMIT}) \ | ||
$(if ${CHANNEL},-channel ${CHANNEL}) \ | ||
$(if ${TEST_CASE},-testCase "${TEST_CASE}") \ | ||
$(if ${WORKLOAD_NAME},-workloadName ${WORKLOAD_NAME}) \ | ||
$(if ${DEPLOY_WORKLOAD},-deployWorkload ${DEPLOY_WORKLOAD}) | ||
|
||
|
||
.PHONY: test-coredns-bump | ||
test-coredns-bump: | ||
@go test -timeout=45m -v -count=1 ./entrypoint/versionbump/... -tags=coredns \ | ||
-expectedValue ${EXPECTED_VALUE} \ | ||
$(if ${VALUE_UPGRADED},-expectedValueUpgrade ${VALUE_UPGRADED}) \ | ||
$(if ${INSTALL_VERSION_OR_COMMIT},-installVersionOrCommit ${INSTALL_VERSION_OR_COMMIT}) \ | ||
$(if ${CHANNEL},-channel ${CHANNEL}) \ | ||
$(if ${TEST_CASE},-testCase "${TEST_CASE}") \ | ||
$(if ${WORKLOAD_NAME},-workloadName ${WORKLOAD_NAME}) \ | ||
$(if ${DEPLOY_WORKLOAD},-deployWorkload ${DEPLOY_WORKLOAD}) | ||
|
||
|
||
.PHONY: test-cniplugin-bump | ||
test-cniplugin-bump: | ||
@go test -timeout=45m -v -count=1 ./entrypoint/versionbump/... -tags=cniplugin \ | ||
-expectedValue ${EXPECTED_VALUE} \ | ||
$(if ${VALUE_UPGRADED},-expectedValueUpgrade ${VALUE_UPGRADED}) \ | ||
$(if ${INSTALL_VERSION_OR_COMMIT},-installVersionOrCommit ${INSTALL_VERSION_OR_COMMIT}) \ | ||
$(if ${CHANNEL},-channel ${CHANNEL}) \ | ||
$(if ${TEST_CASE},-testCase "${TEST_CASE}") \ | ||
$(if ${WORKLOAD_NAME},-workloadName ${WORKLOAD_NAME}) \ | ||
$(if ${DEPLOY_WORKLOAD},-deployWorkload ${DEPLOY_WORKLOAD}) | ||
|
||
#========================= TestCode Static Quality Check =========================# | ||
.PHONY: vet-lint | ||
vet-lint: | ||
@echo "Running go vet and lint" | ||
@go vet ./${TESTDIR} && golangci-lint run --tests | ||
@go vet ./${TEST_DIR} && golangci-lint run --tests |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.