Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/main'
Browse files Browse the repository at this point in the history
  • Loading branch information
est-suse committed Oct 31, 2023
2 parents 441fba8 + 92c46a2 commit 5ac61ab
Show file tree
Hide file tree
Showing 88 changed files with 3,164 additions and 1,593 deletions.
41 changes: 41 additions & 0 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
<!-- HTML Comments can be left in place or removed. -->

#### Proposed Changes ####

<!-- Describe the big picture of your changes here to communicate to the maintainers why we should accept this pull request. -->

<!-- Does this change require an update to documentation? -->

#### Types of Changes ####

<!-- What types of changes does your code introduce to distro framework? Issue validation, Patch Validation, Fix, New functionality, Refactor or etc -->

#### Testing ####
<!-- Answer the checklist bellow -->

Checklist:
1. If your PR changes anything on or related to Jenkins, run it pointing to your branch to make sure it's okay.


2. Verify code lint; we should not have errors.


3. Update the documentation if needed.


4. Update makefile and docker run if adding new tests.


5. Run your tests at least 4 times with all configurations needed and possible.


6. If needed test with different os types.


#### Linked Issues ####

<!-- Link any related issues, pull-requests, qa-tasks repo issues or commit hashes that are relevant to this pull request. If you are opening a PR without a corresponding issue please consider creating one first, at https://github.com/rancher/distros-test-framework/issues . -->

#### Further Comments ####

<!-- If this is a relatively large or complex change, kick off the discussion by explaining why you chose the solution you did and what alternatives you considered, etc... -->
2 changes: 2 additions & 0 deletions .github/workflows/run-distros.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -37,3 +37,5 @@ jobs:
uses: golangci/golangci-lint-action@v3
with:
version: v1.53
args: --timeout 5m --issues-exit-code=0

9 changes: 5 additions & 4 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
.ssh/
.vscode
.DS_Store
.vscode\
.env
.idea/
*.modules/.terraform/
*.terraform*
*.tfstate*
workloads/amd64/plan.yaml
config/k3s.tfvars
config/rke2.tfvars
config/config.yaml
/config/product.yaml
/config/*.tfvars
15 changes: 10 additions & 5 deletions .golangci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,22 +5,19 @@ linters:
- revive
- gosec
- misspell
- nlreturn
- nestif
- dupl
- exportloopref
- dupl

linters-settings:
govet:
check-shadowing: true
check-tests: true
gci:
local-prefixes: github.com/rancher/distros-test-framework
gosec:
issues:
- G306
- G106
nestif:
min-complexity: 4

revive:
confidence: 0.8
Expand Down Expand Up @@ -71,3 +68,11 @@ issues:
exclude-rules:
- linters: [typecheck]
text: "command-line-arguments"
- linters: [gosec]
text: "G106: Use of ssh InsecureIgnoreHostKey should be audited"
- linters: [gosec]
text: "G306: Expect WriteFile permissions to be 0600 or less"
- linters: [revive]
text: 'Unhandled error in call to function fmt\.Println'
- linters: [govet]
text: '`fmt\.Println` arg list ends with redundant newline'
131 changes: 21 additions & 110 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,39 +1,44 @@
include ./config.mk

TAGNAME ?= default

.PHONY: test-env-up
test-env-up:
@cd ../.. && docker build . -q -f ./tests/acceptance/scripts/Dockerfile.build -t acceptance-test-${TAGNAME}
docker build . -q -f ./scripts/Dockerfile.build -t acceptance-test-${TAGNAME}

.PHONY: test-run
test-run:
@docker run -d --name acceptance-test${IMGNAME} -t \
@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/k3s-io/k3s/tests/acceptance/modules/k3scluster/config/.ssh/aws_key.pem \
k3s-automated-${TAGNAME} sh -c 'cd ./tests/acceptance/entrypoint; \
-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
test-logs:
@docker logs -f k3s-automated-test${IMGNAME}
@docker logs -f acceptance-test${IMGNAME}

.PHONY: test-env-down
test-env-down:
@echo "Removing containers and images"
@docker stop $$(docker ps -a -q --filter="name=k3s-automated*")
@docker rm $$(docker ps -a -q --filter="name=k3s-automated*") ; \
docker rmi --force $$(docker images -q --filter="reference=k3s-automated*")
@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*")

.PHONY: test-env-clean
test-env-clean:
@./scripts/delete_resources.sh

Expand All @@ -42,8 +47,8 @@ test-complete: test-env-clean test-env-down remove-tf-state test-env-up test-run

.PHONY: remove-tf-state
remove-tf-state:
@rm -rf ./modules/k3scluster/.terraform
@rm -rf ./modules/k3scluster/.terraform.lock.hcl ./modules/k3scluster/terraform.tfstate ./modules/k3scluster/terraform.tfstate.backup
@rm -rf ./modules/${PRODUCT}/.terraform
@rm -rf ./modules/${PRODUCT}/.terraform.lock.hcl ./modules/${PRODUCT}/terraform.tfstate ./modules/${PRODUCT}/terraform.tfstate.backup


#========================= Run acceptance tests locally =========================#
Expand All @@ -68,108 +73,14 @@ test-version-bump:
-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/...



#========================= TestCode Static Quality Check =========================#
.PHONY: vet-lint ## Run locally only inside acceptance framework
.PHONY: vet-lint
vet-lint:
@echo "Running go vet and lint"
@go vet ./${TESTDIR} && golangci-lint run --tests



#
#
###########################################################################################
#
#
#include ./config.mk
#
#TAGNAME ?= default
#test-env-up:
# @cd ../.. && docker build . -q -f ./tests/acceptance/scripts/Dockerfile.build -t rke2-automated-${TAGNAME}
#
#.PHONY: test-run
#test-run:
# @docker run --name rke2-automated-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/rke2/tests/acceptance/modules/config/.ssh/aws_key.pem \
# rke2-automated-${TAGNAME} sh -c 'cd ./tests/acceptance/entrypoint; \
# if [ -n "${TESTDIR}" ]; then \
# if [ "${TESTDIR}" = "upgradecluster" ]; then \
# if [ "${TESTTAG}" = "upgradesuc" ]; then \
# go test -timeout=45m -v -tags=upgradesuc ./upgradecluster/... -upgradeVersion "${UPGRADEVERSION}"; \
# elif [ "${TESTTAG}" = "upgrademanual" ]; then \
# go test -timeout=45m -v -tags=upgrademanual ./upgradecluster/... -installVersionOrCommit "${INSTALLTYPE}"; \
# fi; \
# elif [ "${TESTDIR}" = "versionbump" ]; then \
# go test -timeout=45m -v -tags=versionbump ./versionbump/... -cmd "${CMD}" -expectedValue "${VALUE}" \
# -expectedValueUpgrade "${VALUEUPGRADE}" -installVersionOrCommit "${INSTALLTYPE}" -channel "${CHANNEL}" -testCase "${TESTCASE}" \
# -deployWorkload "${DEPLOYWORKLOAD}" -workloadName "${WORKLOADNAME}" -description "${DESCRIPTION}"; \
# fi; \
# elif [ -z "${TESTDIR}" ]; then \
# go test -timeout=45m -v ./createcluster/...; \
# fi;'
#
#
#.PHONY: test-logs
#test-logs:
# @docker logs -f rke2-automated-test-${IMGNAME}
#
#
#.PHONY: test-env-down
#test-env-down:
# @echo "Removing containers and images"
# @docker stop $$(docker ps -a -q --filter="name=rke2-automated*")
# @docker rm $$(docker ps -a -q --filter="name=rke2-automated*")
# @docker rmi $$(docker images -q --filter="reference=rke2-automated*")
#
#
#.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
#
#
#.PHONY: remove-tf-state
#remove-tf-state:
# @rm -rf ./modules/.terraform
# @rm -rf ./modules/.terraform.lock.hcl ./modules/terraform.tfstate ./modules/terraform.tfstate.backup
#
#
##======================= Run acceptance tests locally =========================#
#
#.PHONY: test-create
#test-create:
# @go test -timeout=45m -v ./entrypoint/createcluster/...
#
#
#.PHONY: test-upgrade-suc
#test-upgrade-suc:
# @go test -timeout=45m -v -tags=upgradesuc ./entrypoint/upgradecluster/... -upgradeVersion ${UPGRADEVERSION}
#
#
#.PHONY: test-upgrade-manual
#test-upgrade-manual:
# @go test -timeout=45m -v -tags=upgrademanual ./entrypoint/upgradecluster/... -installVersionOrCommit ${INSTALLTYPE}
#
#
#.PHONY: test-version-bump
#test-version-bump:
# go test -timeout=45m -v -tags=versionbump ./entrypoint/versionbump/... \
# -cmd "${CMD}" \
# -expectedValue ${VALUE} \
# -expectedValueUpgrade ${VALUEUPGRADED} \
# -installVersionOrCommit ${INSTALLTYPE} -channel ${CHANNEL} \
# -testCase "${TESTCASE}" -deployWorkload ${DEPLOYWORKLOAD} -workloadName ${WORKLOADNAME} -description "${DESCRIPTION}"
#
#
##========================= TestCode Static Quality Check =========================#
#.PHONY: vet-lint ## Run locally only inside Tests package
#vet-lint:
# @echo "Running go vet and lint"
# @go vet ./${TESTDIR} && golangci-lint run --tests
@go vet ./${TESTDIR} && golangci-lint run --tests
Loading

0 comments on commit 5ac61ab

Please sign in to comment.