Skip to content

Commit

Permalink
Added basic e2e tests
Browse files Browse the repository at this point in the history
Signed-off-by: Patryk Strusiewicz-Surmacki <[email protected]>
  • Loading branch information
p-strusiewiczsurmacki-mobica committed Apr 11, 2024
1 parent 6803215 commit 4552910
Show file tree
Hide file tree
Showing 88 changed files with 1,496 additions and 9,438 deletions.
2 changes: 0 additions & 2 deletions .golangci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,6 @@ linters-settings:
- pkg: sigs.k8s.io/cluster-api/api/v1beta1
alias: clusterv1
# CAPM3
- pkg: github.com/metal3-io/cluster-api-provider-metal3/api/v1alpha5
alias: infrav1alpha5
- pkg: github.com/metal3-io/cluster-api-provider-metal3/api/v1beta1
alias: infrav1
# BMO
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
# limitations under the License.

# Support FROM override
ARG BUILD_IMAGE=docker.io/golang:1.21.7@sha256:549dd88a1a53715f177b41ab5fee25f7a376a6bb5322ac7abe263480d9554021
ARG BUILD_IMAGE=docker.io/golang:1.21.8@sha256:c82d4ad02c062cf2b393bf0374df26638c6fed3dfe52cdbd3635d4a7befab86e
ARG BASE_IMAGE=gcr.io/distroless/static:nonroot@sha256:9ecc53c269509f63c69a266168e4a687c7eb8c0cfd753bd8bfcaa4f58a90876f

# Build the manager binary on golang image
Expand Down
56 changes: 37 additions & 19 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ SHELL:=/usr/bin/env bash

.DEFAULT_GOAL:=help

GO_VERSION ?= 1.21.7
GO_VERSION ?= 1.21.8
GO := $(shell type -P go)
# Use GOPROXY environment variable if set
GOPROXY := $(shell $(GO) env GOPROXY)
Expand Down Expand Up @@ -134,12 +134,16 @@ unit-cover-verbose:
GO_TEST_FLAGS=-v GINKGO_TEST_FLAGS=-ginkgo.v $(MAKE) unit-cover

.PHONY: test
test: fmt lint unit ## Run tests
test: lint unit ## Run tests

.PHONY: test-e2e
test-e2e: ## Run e2e tests with capi e2e testing framework
./scripts/ci-e2e.sh

.PHONY: test-clusterclass-e2e
test-clusterclass-e2e: ## Run e2e tests with capi e2e testing framework
CLUSTER_TOPOLOGY=true GINKGO_FOCUS=basic ./scripts/ci-e2e.sh

GINKGO_NOCOLOR ?= false
ARTIFACTS ?= $(ROOT_DIR)/_artifacts
E2E_CONF_FILE ?= $(ROOT_DIR)/test/e2e/config/e2e_conf.yaml
Expand Down Expand Up @@ -168,6 +172,14 @@ cluster-templates: $(KUSTOMIZE) ## Generate cluster templates
$(KUSTOMIZE) build $(E2E_TEMPLATES_DIR)/cluster-template-ubuntu > $(E2E_OUT_DIR)/cluster-template-ubuntu.yaml
$(KUSTOMIZE) build $(E2E_TEMPLATES_DIR)/cluster-template-centos > $(E2E_OUT_DIR)/cluster-template-centos.yaml
$(KUSTOMIZE) build $(E2E_TEMPLATES_DIR)/cluster-template-upgrade-workload > $(E2E_OUT_DIR)/cluster-template-upgrade-workload.yaml
touch $(E2E_OUT_DIR)/clusterclass.yaml

.PHONY: clusterclass-templates
clusterclass-templates: $(KUSTOMIZE) ## Generate cluster templates
$(KUSTOMIZE) build $(E2E_TEMPLATES_DIR)/clusterclass-template-ubuntu > $(E2E_OUT_DIR)/cluster-template-ubuntu.yaml
$(KUSTOMIZE) build $(E2E_TEMPLATES_DIR)/clusterclass-template-centos > $(E2E_OUT_DIR)/cluster-template-centos.yaml
$(KUSTOMIZE) build $(E2E_TEMPLATES_DIR)/clusterclass-template-upgrade-workload > $(E2E_OUT_DIR)/cluster-template-upgrade-workload.yaml
$(KUSTOMIZE) build $(E2E_TEMPLATES_DIR)/clusterclass > $(E2E_OUT_DIR)/clusterclass.yaml

## --------------------------------------
## E2E Testing
Expand Down Expand Up @@ -204,6 +216,29 @@ e2e-tests: $(GINKGO) e2e-substitutions cluster-templates # This target should be

rm $(E2E_CONF_FILE_ENVSUBST)

.PHONY: e2e-clusterclass-tests
e2e-clusterclass-tests: CONTAINER_RUNTIME?=docker # Env variable can override this default
export CONTAINER_RUNTIME

e2e-clusterclass-tests: $(GINKGO) e2e-substitutions clusterclass-templates # This target should be called from scripts/ci-e2e.sh
for image in $(E2E_CONTAINERS); do \
$(CONTAINER_RUNTIME) pull $$image; \
done

$(GINKGO) --timeout=$(GINKGO_TIMEOUT) -v --trace --tags=e2e \
--show-node-events --no-color=$(GINKGO_NOCOLOR) \
--fail-fast="$(KEEP_TEST_ENV)" \
--junit-report="junit.e2e_suite.1.xml" \
--focus="$(GINKGO_FOCUS)" $(_SKIP_ARGS) "$(ROOT_DIR)/$(TEST_DIR)/e2e/" -- \
-e2e.artifacts-folder="$(ARTIFACTS)" \
-e2e.config="$(E2E_CONF_FILE_ENVSUBST)" \
-e2e.skip-resource-cleanup=$(SKIP_CLEANUP) \
-e2e.keep-test-environment=$(KEEP_TEST_ENV) \
-e2e.trigger-ephemeral-test=$(EPHEMERAL_TEST) \
-e2e.use-existing-cluster=$(SKIP_CREATE_MGMT_CLUSTER)

rm $(E2E_CONF_FILE_ENVSUBST)

## --------------------------------------
## Build
## --------------------------------------
Expand Down Expand Up @@ -292,18 +327,6 @@ lint-full: $(GOLANGCI_LINT) ## Run slower linters to detect possible issues
cd $(APIS_DIR) && $(GOLANGCI_LINT) run -v --fast=false --timeout=30m
cd $(TEST_DIR) && $(GOLANGCI_LINT) run -v --fast=false --timeout=30m

# Run go fmt against code
fmt:
$(GO) fmt ./controllers/... ./baremetal/... .
cd $(APIS_DIR) && $(GO) fmt ./...
cd $(TEST_DIR) && $(GO) fmt ./...

# Run go vet against code
vet:
$(GO) vet ./controllers/... ./baremetal/... .
cd $(APIS_DIR) && $(GO) vet ./...
cd $(TEST_DIR) && $(GO) fmt ./...

# Run manifest validation
.PHONY: manifest-lint
manifest-lint:
Expand Down Expand Up @@ -388,11 +411,6 @@ generate-go: $(CONTROLLER_GEN) $(MOCKGEN) $(CONVERSION_GEN) $(KUBEBUILDER) $(KUS
-copyright_file=./hack/boilerplate/boilerplate.generatego.txt \
ManagerFactoryInterface

$(CONVERSION_GEN) \
--input-dirs=./api/v1alpha5 \
--output-file-base=zz_generated.conversion $(CONVERSION_GEN_OUTPUT_BASE) \
--go-header-file=./hack/boilerplate/boilerplate.generatego.txt

.PHONY: generate-manifests
generate-manifests: $(CONTROLLER_GEN) ## Generate manifests e.g. CRD, RBAC etc.
$(CONTROLLER_GEN) \
Expand Down
27 changes: 10 additions & 17 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ Metal3.

| CAPM3 version | Cluster API version | CAPM3 Release |  CAPI Release |
| ------------- | ------------------- | ------------- | -------------- |
| v1alpha5 | v1alpha4 | v0.5.X |  v0.4.X        |
| v1beta1 | v1beta1 | v1.1.X |  v1.1.X        |
| v1beta1 | v1beta1 | v1.2.X |  v1.2.X        |
| v1beta1 | v1beta1 | v1.3.X |  v1.3.X        |
Expand All @@ -47,8 +46,9 @@ need to be manually installed. Example flow of installing Metal3 provider:
level of the logging verbose with a positive integer number, ie. -v5.

```shell
clusterctl init --core cluster-api:v1.6.2 --bootstrap kubeadm:v1.6.2 \
--control-plane kubeadm:v1.6.2 -v5
clusterctl init --core cluster-api:v1.7.0-beta.0 \
--bootstrap kubeadm:v1.7.0-beta.0 \
--control-plane kubeadm:v1.7.0-beta.0 -v5
```

1. Install Metal3 provider. This will install the latest version of Cluster API
Expand Down Expand Up @@ -164,10 +164,12 @@ Release-1.4 branch:
## Basic tests

Unlike integration tests, basic tests focus on the target cluster creation
without involving pivoting from the bootstrap cluster. To run basic tests,
replace `integration` with `basic` for instance:
without involving pivoting from the bootstrap cluster. To run basic tests use:

- **/test-ubuntu-e2e-basic-main** runs basic e2e tests with main branch on Ubuntu
- **/test metal3-ubuntu-e2e-basic-test-main** runs basic e2e tests with main
branch on Ubuntu
- **/test metal3-centos-e2e-basic-test-release-1-6** runs basic e2e tests on
release-1.6 branch with centos

### Feature tests

Expand Down Expand Up @@ -209,19 +211,10 @@ Release-1.4 branch:

### Upgrade tests

CAPM3 tests upgrade from all supported release to the current one, while also
maintaining a test for the previous API version release v1alpha5.
CAPM3 tests upgrade from all supported release to the current one.
We run upgrade test on main branch from different releases:

- **/test-e2e-upgrade-main-from-release-0-5** runs e2e upgrade tests from CAPM3
API version v1alpha5/branch release-0.5 to CAPM3 API version v1beta1/branch
main on Ubuntu

- **/test-e2e-upgrade-main-from-release-1-2** runs e2e upgrade tests from CAPM3
API version v1beta1/branch release-1.2 to CAPM3 API version v1beta1/branch
main on Ubuntu

- **/test-e2e-upgrade-main-from-release-1-3** runs e2e upgrade tests from CAPM3
z- **/test-e2e-upgrade-main-from-release-1-3** runs e2e upgrade tests from CAPM3
API version v1beta1/branch release-1.3 to CAPM3 API version v1beta1/branch
main on Ubuntu

Expand Down
38 changes: 18 additions & 20 deletions api/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,39 +3,37 @@ module github.com/metal3-io/cluster-api-provider-metal3/api
go 1.21

require (
github.com/google/gofuzz v1.2.0
github.com/metal3-io/ip-address-manager/api v1.6.0
github.com/onsi/gomega v1.31.1
github.com/metal3-io/ip-address-manager/api v1.7.0-beta.0
github.com/onsi/gomega v1.32.0
github.com/pkg/errors v0.9.1
golang.org/x/net v0.21.0
k8s.io/api v0.29.2
k8s.io/apimachinery v0.29.2
k8s.io/client-go v0.29.2
golang.org/x/net v0.22.0
k8s.io/api v0.29.3
k8s.io/apimachinery v0.29.3
k8s.io/client-go v0.29.3
k8s.io/utils v0.0.0-20231127182322-b307cd553661
sigs.k8s.io/cluster-api v1.6.2
sigs.k8s.io/cluster-api v1.7.0-beta.0
sigs.k8s.io/controller-runtime v0.17.2

)

require (
github.com/beorn7/perks v1.0.1 // indirect
github.com/blang/semver/v4 v4.0.0 // indirect
github.com/cespare/xxhash/v2 v2.2.0 // indirect
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect
github.com/emicklei/go-restful/v3 v3.11.0 // indirect
github.com/evanphx/json-patch/v5 v5.8.0 // indirect
github.com/evanphx/json-patch/v5 v5.9.0 // indirect
github.com/fsnotify/fsnotify v1.7.0 // indirect
github.com/go-logr/logr v1.4.1 // indirect
github.com/go-openapi/jsonpointer v0.19.6 // indirect
github.com/go-openapi/jsonreference v0.20.2 // indirect
github.com/go-openapi/swag v0.22.3 // indirect
github.com/gobuffalo/flect v1.0.2 // indirect
github.com/gogo/protobuf v1.3.2 // indirect
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
github.com/golang/protobuf v1.5.3 // indirect
github.com/golang/protobuf v1.5.4 // indirect
github.com/google/gnostic-models v0.6.8 // indirect
github.com/google/go-cmp v0.6.0 // indirect
github.com/google/uuid v1.3.1 // indirect
github.com/google/gofuzz v1.2.0 // indirect
github.com/google/uuid v1.4.0 // indirect
github.com/imdario/mergo v0.3.13 // indirect
github.com/josharian/intern v1.0.0 // indirect
github.com/json-iterator/go v1.1.12 // indirect
Expand All @@ -50,19 +48,19 @@ require (
github.com/prometheus/procfs v0.12.0 // indirect
github.com/spf13/pflag v1.0.5 // indirect
golang.org/x/exp v0.0.0-20230905200255-921286631fa9 // indirect
golang.org/x/oauth2 v0.14.0 // indirect
golang.org/x/sys v0.17.0 // indirect
golang.org/x/term v0.17.0 // indirect
golang.org/x/oauth2 v0.18.0 // indirect
golang.org/x/sys v0.18.0 // indirect
golang.org/x/term v0.18.0 // indirect
golang.org/x/text v0.14.0 // indirect
golang.org/x/time v0.3.0 // indirect
golang.org/x/time v0.5.0 // indirect
gomodules.xyz/jsonpatch/v2 v2.4.0 // indirect
google.golang.org/appengine v1.6.7 // indirect
google.golang.org/protobuf v1.31.0 // indirect
google.golang.org/protobuf v1.33.0 // indirect
gopkg.in/inf.v0 v0.9.1 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
gopkg.in/yaml.v3 v3.0.1 //indirect
k8s.io/apiextensions-apiserver v0.29.1 // indirect
k8s.io/component-base v0.29.1 // indirect
k8s.io/apiextensions-apiserver v0.29.3 // indirect
k8s.io/component-base v0.29.3 // indirect
k8s.io/klog/v2 v2.110.1 // indirect
k8s.io/kube-openapi v0.0.0-20231010175941-2dd684a91f00 // indirect
sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd // indirect
Expand Down
Loading

0 comments on commit 4552910

Please sign in to comment.