Skip to content

Commit fe94cb7

Browse files
🌱 Use vm operator v1.8.6 for supervisor e2e testing (#2894)
* Use vm-operator v1.8.6 for supervisor mode testing * Use VSPHERE_NETWORK instead of NAMED_NETWORK * Add content library items * Address comments * make generate-modules * make lint-fix --------- Co-authored-by: Stefan Bueringer <[email protected]>
1 parent e06aebb commit fe94cb7

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+1452
-175
lines changed

‎Makefile‎

Lines changed: 38 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ BIN_DIR := bin
5858
BUILD_DIR := .build
5959
TEST_DIR := test
6060
VCSIM_DIR := test/infrastructure/vcsim
61+
NETOP_DIR := test/infrastructure/net-operator
6162
TOOLS_DIR := hack/tools
6263
TOOLS_BIN_DIR := $(abspath $(TOOLS_DIR)/$(BIN_DIR))
6364
FLAVOR_DIR := $(ROOT_DIR)/templates
@@ -223,9 +224,15 @@ VM_OPERATOR_IMAGE_NAME ?= extra/vm-operator
223224
VM_OPERATOR_CONTROLLER_IMG ?= $(STAGING_REGISTRY)/$(VM_OPERATOR_IMAGE_NAME)
224225
VM_OPERATOR_DIR := test/infrastructure/vm-operator
225226
VM_OPERATOR_TMP_DIR ?= vm-operator.tmp
226-
VM_OPERATOR_VERSION ?= v1.8.1
227+
# note: this is the commit from 1.8.6 tag
228+
VM_OPERATOR_COMMIT ?= de75746a9505ef3161172d99b735d6593c54f0c5
229+
VM_OPERATOR_VERSION ?= v1.8.6-0-gde75746a
227230
VM_OPERATOR_ALL_ARCH = amd64 arm64
228231

232+
# net operator
233+
NET_OPERATOR_IMAGE_NAME ?= cluster-api-net-operator
234+
NET_OPERATOR_IMG ?= $(STAGING_REGISTRY)/$(NET_OPERATOR_IMAGE_NAME)
235+
229236
# It is set by Prow GIT_TAG, a git-based tag of the form vYYYYMMDD-hash, e.g., v20210120-v0.3.10-308-gc61521971
230237

231238
TAG ?= dev
@@ -255,6 +262,7 @@ VCSIM_CRD_ROOT ?= $(VCSIM_DIR)/config/crd/bases
255262
WEBHOOK_ROOT ?= $(MANIFEST_ROOT)/webhook
256263
RBAC_ROOT ?= $(MANIFEST_ROOT)/rbac
257264
VCSIM_RBAC_ROOT ?= $(VCSIM_DIR)/config/rbac
265+
NETOP_RBAC_ROOT ?= $(NETOP_DIR)/config/rbac
258266
VERSION ?= $(shell cat clusterctl-settings.json | jq .config.nextVersion -r)
259267
OVERRIDES_DIR := $(HOME)/.cluster-api/overrides/infrastructure-vsphere/$(VERSION)
260268

@@ -294,16 +302,21 @@ generate-manifests: $(CONTROLLER_GEN) ## Generate manifests e.g. CRD, RBAC etc.
294302
paths=./apis/vmware/v1beta1 \
295303
crd:crdVersions=v1 \
296304
output:crd:dir=$(SUPERVISOR_CRD_ROOT)
297-
# vm-operator crds are loaded to be used for integration tests.
305+
# vm-operator crds are used for test.
298306
$(CONTROLLER_GEN) \
299307
paths=github.com/vmware-tanzu/vm-operator/api/v1alpha1/... \
300308
crd:crdVersions=v1 \
301309
output:crd:dir=$(VMOP_CRD_ROOT)
310+
# net-operator is used for tests
311+
$(CONTROLLER_GEN) \
312+
paths=./$(NETOP_DIR)/controllers/... \
313+
output:rbac:dir=$(NETOP_RBAC_ROOT) \
314+
rbac:roleName=manager-role
302315
# vcsim crds are used for tests.
303316
$(CONTROLLER_GEN) \
304-
paths=./$(VCSIM_DIR)/api/v1alpha1 \
305-
crd:crdVersions=v1 \
306-
output:crd:dir=$(VCSIM_CRD_ROOT)
317+
paths=./$(VCSIM_DIR)/api/v1alpha1 \
318+
crd:crdVersions=v1 \
319+
output:crd:dir=$(VCSIM_CRD_ROOT)
307320
$(CONTROLLER_GEN) \
308321
paths=./$(VCSIM_DIR)/ \
309322
paths=./$(VCSIM_DIR)/controllers/... \
@@ -317,8 +330,8 @@ generate-go-deepcopy: $(CONTROLLER_GEN) ## Generate deepcopy go code for core
317330
object:headerFile=./hack/boilerplate/boilerplate.generatego.txt \
318331
paths=./apis/...
319332
$(CONTROLLER_GEN) \
320-
object:headerFile=./hack/boilerplate/boilerplate.generatego.txt \
321-
paths=./$(VCSIM_DIR)/api/...
333+
object:headerFile=./hack/boilerplate/boilerplate.generatego.txt \
334+
paths=./$(VCSIM_DIR)/api/...
322335

323336
.PHONY: generate-go-conversions
324337
generate-go-conversions: $(CONTROLLER_GEN) $(CONVERSION_GEN) ## Runs Go related generate targets
@@ -539,6 +552,15 @@ docker-build-vcsim: docker-pull-prerequisites ## Build the docker image for vcsi
539552
$(MAKE) set-manifest-pull-policy TARGET_RESOURCE="./$(VCSIM_DIR)/config/default/manager_pull_policy.yaml"; \
540553
fi
541554

555+
.PHONY: docker-build-net-operator
556+
docker-build-net-operator: docker-pull-prerequisites ## Build the docker image for net-operator controller manager
557+
## reads Dockerfile from stdin to avoid an incorrectly cached Dockerfile (https://github.com/moby/buildkit/issues/1368)
558+
cat $(NETOP_DIR)/Dockerfile | DOCKER_BUILDKIT=1 docker build --build-arg builder_image=$(GO_CONTAINER_IMAGE) --build-arg goproxy=$(GOPROXY) --build-arg ARCH=$(ARCH) --build-arg ldflags="$(LDFLAGS)" . -t $(NET_OPERATOR_IMG)-$(ARCH):$(TAG) --file -
559+
@if [ "${DOCKER_BUILD_MODIFY_MANIFESTS}" = "true" ]; then \
560+
$(MAKE) set-manifest-image MANIFEST_IMG=$(NET_OPERATOR_IMG)-$(ARCH) MANIFEST_TAG=$(TAG) TARGET_RESOURCE="./$(NETOP_DIR)/config/default/manager_image_patch.yaml"; \
561+
$(MAKE) set-manifest-pull-policy TARGET_RESOURCE="./$(NETOP_DIR)/config/default/manager_pull_policy.yaml"; \
562+
fi
563+
542564
## --------------------------------------
543565
## Testing
544566
## --------------------------------------
@@ -586,6 +608,7 @@ e2e-images: ## Build the e2e manager image
586608
# also the same settings must exist in e2e.sh
587609
$(MAKE) REGISTRY=gcr.io/k8s-staging-capi-vsphere PULL_POLICY=IfNotPresent TAG=dev docker-build
588610
$(MAKE) REGISTRY=gcr.io/k8s-staging-capi-vsphere PULL_POLICY=IfNotPresent TAG=dev docker-build-vcsim
611+
$(MAKE) REGISTRY=gcr.io/k8s-staging-capi-vsphere PULL_POLICY=IfNotPresent TAG=dev docker-build-net-operator
589612

590613
.PHONY: e2e
591614
e2e: e2e-images generate-e2e-templates
@@ -785,13 +808,15 @@ vm-operator-checkout:
785808
@if [ -z "${VM_OPERATOR_VERSION}" ]; then echo "VM_OPERATOR_VERSION is not set"; exit 1; fi
786809
@if [ -d "$(VM_OPERATOR_TMP_DIR)" ]; then \
787810
echo "$(VM_OPERATOR_TMP_DIR) exists, skipping clone"; \
788-
cd "$(VM_OPERATOR_TMP_DIR)"; \
789-
if [ "$$(git describe --match "v[0-9]*")" != "$(VM_OPERATOR_VERSION)" ]; then \
790-
echo "ERROR: checked out version $$(git describe --match "v[0-9]*") does not match expected version $(VM_OPERATOR_VERSION)"; \
791-
exit 1; \
792-
fi \
793811
else \
794-
git clone --depth 1 --branch "$(VM_OPERATOR_VERSION)" "https://github.com/vmware-tanzu/vm-operator.git" "$(VM_OPERATOR_TMP_DIR)"; \
812+
git clone "https://github.com/vmware-tanzu/vm-operator.git" "$(VM_OPERATOR_TMP_DIR)"; \
813+
cd "$(VM_OPERATOR_TMP_DIR)"; \
814+
git checkout "$(VM_OPERATOR_COMMIT)"; \
815+
fi
816+
@cd "$(ROOT_DIR)/$(VM_OPERATOR_TMP_DIR)"; \
817+
if [ "$$(git describe --dirty 2> /dev/null)" != "$(VM_OPERATOR_VERSION)" ]; then \
818+
echo "ERROR: checked out version $$(git describe --dirty 2> /dev/null) does not match expected version $(VM_OPERATOR_VERSION)"; \
819+
exit 1; \
795820
fi
796821

797822
.PHONY: vm-operator-manifest-build

‎hack/e2e.sh‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ export VSPHERE_SSH_AUTHORIZED_KEY="${VM_SSH_PUB_KEY:-}"
8383
export VSPHERE_SSH_PRIVATE_KEY="/root/ssh/.private-key/private-key"
8484
export E2E_CONF_FILE="${REPO_ROOT}/test/e2e/config/vsphere.yaml"
8585
export E2E_CONF_OVERRIDE_FILE=""
86-
export E2E_VM_OPERATOR_VERSION="${VM_OPERATOR_VERSION:-v1.8.1}"
86+
export E2E_VM_OPERATOR_VERSION="${VM_OPERATOR_VERSION:-v1.8.6-0-gde75746a}"
8787
export ARTIFACTS="${ARTIFACTS:-${REPO_ROOT}/_artifacts}"
8888
export DOCKER_IMAGE_TAR="/tmp/images/image.tar"
8989
export GC_KIND="false"

‎internal/test/helpers/vcsim/model.go‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,3 +89,8 @@ func NetworkFolderName(datacenter int) string {
8989
func NetworkPath(datacenter int, network string) string {
9090
return fmt.Sprintf("/%s/%s", NetworkFolderName(datacenter), network)
9191
}
92+
93+
// DistributedPortGroupName provide a function to compute vcsim distribute port group names in a datacenter.
94+
func DistributedPortGroupName(datacenter int, distributedPortGroup int) string {
95+
return fmt.Sprintf("%s_DVPG%d", DatacenterName(datacenter), distributedPortGroup)
96+
}

‎internal/test/helpers/vcsim/model_test.go‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ func Test_vcsim_NamesAndPath(t *testing.T) {
2828
datacenter := 5
2929
cluster := 3
3030
datastore := 7
31+
distributedPortGroup := 4
3132

3233
g.Expect(DatacenterName(datacenter)).To(Equal("DC5"))
3334
g.Expect(ClusterName(datacenter, cluster)).To(Equal("DC5_C3"))
@@ -39,4 +40,5 @@ func Test_vcsim_NamesAndPath(t *testing.T) {
3940
g.Expect(VMPath(datacenter, "my-mv")).To(Equal("/DC5/vm/my-mv"))
4041
g.Expect(NetworkFolderName(datacenter)).To(Equal("DC5/network"))
4142
g.Expect(NetworkPath(datacenter, "my-network")).To(Equal("/DC5/network/my-network"))
43+
g.Expect(DistributedPortGroupName(datacenter, distributedPortGroup)).To(Equal("DC5_DVPG4"))
4244
}

‎test/e2e/config/vsphere.yaml‎

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,9 @@ images:
2020
loadBehavior: mustLoad
2121
- name: gcr.io/k8s-staging-capi-vsphere/cluster-api-vcsim-controller-{ARCH}:dev
2222
loadBehavior: mustLoad
23-
- name: gcr.io/k8s-staging-capi-vsphere/extra/vm-operator:v1.8.1
23+
- name: gcr.io/k8s-staging-capi-vsphere/cluster-api-net-operator-{ARCH}:dev
24+
loadBehavior: mustLoad
25+
- name: gcr.io/k8s-staging-capi-vsphere/extra/vm-operator:v1.8.6-0-gde75746a
2426
loadBehavior: tryLoad
2527
- name: quay.io/jetstack/cert-manager-cainjector:v1.12.2
2628
loadBehavior: tryLoad
@@ -213,9 +215,9 @@ providers:
213215
- name: vm-operator
214216
type: RuntimeExtensionProvider # vm-operator isn't a provider, but we fake it is so it can be handled by the clusterctl machinery.
215217
versions:
216-
- name: v1.8.1
218+
- name: v1.8.6-0-gde75746a
217219
# Use manifest from source files
218-
value: "https://storage.googleapis.com/artifacts.k8s-staging-capi-vsphere.appspot.com/vm-operator/v1.8.1.yaml"
220+
value: "https://storage.googleapis.com/artifacts.k8s-staging-capi-vsphere.appspot.com/vm-operator/v1.8.6-0-gde75746a.yaml"
219221
type: "url"
220222
contract: v1beta1
221223
files:
@@ -224,6 +226,19 @@ providers:
224226
- old: "imagePullPolicy: Always"
225227
new: "imagePullPolicy: IfNotPresent"
226228

229+
- name: net-operator
230+
type: RuntimeExtensionProvider # net-operator isn't a provider, but we fake it is so it can be handled by the clusterctl machinery.
231+
versions:
232+
- name: v1.10.99
233+
# Use manifest from source files
234+
value: ../../../../cluster-api-provider-vsphere/test/infrastructure/net-operator/config/default
235+
contract: v1beta1
236+
files:
237+
- sourcePath: "../data/shared/capv/main/metadata.yaml"
238+
replacements:
239+
- old: "imagePullPolicy: Always"
240+
new: "imagePullPolicy: IfNotPresent"
241+
227242
variables:
228243
# Ensure all Kubernetes versions used here are covered in patch-vsphere-template.yaml
229244
KUBERNETES_VERSION: "v1.29.0"
@@ -252,8 +267,10 @@ variables:
252267
VSPHERE_MACHINE_CLASS_CPU_CONFORMANCE: "8"
253268
VSPHERE_MACHINE_CLASS_MEMORY_CONFORMANCE: "8Gi"
254269
VSPHERE_CONTENT_LIBRARY: "capv"
270+
VSPHERE_CONTENT_LIBRARY_ITEMS: "ubuntu-2204-kube-v1.28.0,ubuntu-2204-kube-v1.29.0"
255271
VSPHERE_IMAGE_NAME: "ubuntu-2204-kube-v1.29.0"
256272
VSPHERE_NETWORK: "sddc-cgw-network-6"
273+
VSPHERE_DISTRIBUTED_PORT_GROUP: "/SDDC-Datacenter/network/sddc-cgw-network-6"
257274
VSPHERE_TEMPLATE: "ubuntu-2204-kube-v1.29.0"
258275
FLATCAR_VSPHERE_TEMPLATE: "flatcar-stable-3602.2.3-kube-v1.29.0"
259276
VSPHERE_INSECURE_CSI: "true"

‎test/e2e/e2e_setup_test.go‎

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -273,7 +273,7 @@ func setupNamespaceWithVMOperatorDependenciesVCenter(managementClusterProxy fram
273273
// NOTE: when running on vCenter the vm-operator automatically creates VirtualMachine objects for the content library.
274274
Items: []vcsimv1.ContentLibraryItemConfig{},
275275
},
276-
NetworkName: e2eConfig.GetVariable("VSPHERE_NETWORK"),
276+
DistributedPortGroupName: e2eConfig.GetVariable("VSPHERE_DISTRIBUTED_PORT_GROUP"),
277277
},
278278
StorageClasses: []vcsimv1.StorageClass{
279279
{
@@ -296,6 +296,16 @@ func setupNamespaceWithVMOperatorDependenciesVCenter(managementClusterProxy fram
296296
},
297297
}
298298

299+
items := e2eConfig.GetVariable("VSPHERE_CONTENT_LIBRARY_ITEMS")
300+
if items != "" {
301+
for _, i := range strings.Split(e2eConfig.GetVariable("VSPHERE_CONTENT_LIBRARY_ITEMS"), ",") {
302+
dependenciesConfig.Spec.VCenter.ContentLibrary.Items = append(dependenciesConfig.Spec.VCenter.ContentLibrary.Items, vcsimv1.ContentLibraryItemConfig{
303+
Name: i,
304+
ItemType: "ovf",
305+
})
306+
}
307+
}
308+
299309
err := vmoperator.ReconcileDependencies(ctx, c, dependenciesConfig)
300310
Expect(err).ToNot(HaveOccurred(), "Failed to reconcile VMOperatorDependencies")
301311
}

‎test/framework/framework.go‎

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,21 @@ func LoadE2EConfig(ctx context.Context, configPath string, configOverridesPath,
122122
break
123123
}
124124
}
125+
126+
Byf("Dropping net-operator from the e2e config")
127+
for i := range config.Providers {
128+
if config.Providers[i].Name == "net-operator" {
129+
config.Providers = append(config.Providers[:i], config.Providers[i+1:]...)
130+
break
131+
}
132+
}
133+
134+
for i := range config.Images {
135+
if strings.Contains(config.Images[i].Name, "net-operator") {
136+
config.Images = append(config.Images[:i], config.Images[i+1:]...)
137+
break
138+
}
139+
}
125140
} else {
126141
// In case we are testing supervisor, change the folder we build manifest from
127142
Byf("Overriding source folder for vsphere provider to /config/supervisor in the e2e config")

0 commit comments

Comments
 (0)