Skip to content

Commit

Permalink
E2E test: Add more BMO versions for upgrade tests
Browse files Browse the repository at this point in the history
Signed-off-by: Huy Mai <huy.mai@est.tech>
  • Loading branch information
mquhuy committed Feb 5, 2024
1 parent 53281e6 commit 4c94b2b
Show file tree
Hide file tree
Showing 12 changed files with 172 additions and 39 deletions.
10 changes: 10 additions & 0 deletions config/overlays/e2e-release-0.3/ironic.env
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
HTTP_PORT=6180
PROVISIONING_IP=192.168.222.199
DEPLOY_KERNEL_URL=http://192.168.222.199:6180/images/ironic-python-agent.kernel
DEPLOY_RAMDISK_URL=http://192.168.222.199:6180/images/ironic-python-agent.initramfs
IRONIC_ENDPOINT=https://192.168.222.199:6385/v1/
IRONIC_INSPECTOR_ENDPOINT=https://192.168.222.199:5050/v1/
CACHEURL=http://192.168.222.199/images
IRONIC_FAST_TRACK=true
IRONIC_KERNEL_PARAMS=console=ttyS0
IRONIC_INSPECTOR_VLAN_INTERFACES=all
38 changes: 38 additions & 0 deletions config/overlays/e2e-release-0.3/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
namespace: baremetal-operator-system
resources:
- https://github.com/metal3-io/baremetal-operator/config/tls?ref=release-0.3
components:
- ../../components/basic-auth
configMapGenerator:
- name: ironic
behavior: merge
envs:
- ironic.env
patches:
- patch: |
# Don't try to pull again the pre-loaded image
- op: replace
path: /spec/template/spec/containers/0/imagePullPolicy
value: IfNotPresent
target:
kind: Deployment
name: controller-manager
images:
- name: quay.io/metal3-io/baremetal-operator
newTag: release-0.3
# We cannot use suffix hashes since the kustomizations we build on
# cannot be aware of what suffixes we add.
generatorOptions:
disableNameSuffixHash: true
# NOTE: These credentials are generated automatically in hack/ci-e2e.sh
secretGenerator:
- name: ironic-credentials
files:
- username=ironic-username
- password=ironic-password
- name: ironic-inspector-credentials
files:
- username=ironic-inspector-username
- password=ironic-inspector-password
27 changes: 10 additions & 17 deletions config/overlays/e2e-release-0.4/kustomization.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,14 @@ apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
namespace: baremetal-operator-system
resources:
- https://github.com/metal3-io/baremetal-operator/config/tls?ref=release-0.4

- https://github.com/metal3-io/baremetal-operator/config/tls?ref=release-0.4
components:
- ../../components/basic-auth

- ../../components/basic-auth
configMapGenerator:
- name: ironic
behavior: merge
envs:
- ironic.env

patches:
- patch: |
# Don't try to pull again the pre-loaded image
Expand All @@ -22,24 +19,20 @@ patches:
target:
kind: Deployment
name: controller-manager

images:
- name: quay.io/metal3-io/baremetal-operator
newTag: release-0.4

# We cannot use suffix hashes since the kustomizations we build on
# cannot be aware of what suffixes we add.
generatorOptions:
disableNameSuffixHash: true

# NOTE: These credentials are generated automatically in hack/ci-e2e.sh
secretGenerator:
- name: ironic-credentials
files:
- username=ironic-username
- password=ironic-password
- name: ironic-inspector-credentials
files:
- username=ironic-inspector-username
- password=ironic-inspector-password

- name: ironic-credentials
files:
- username=ironic-username
- password=ironic-password
- name: ironic-inspector-credentials
files:
- username=ironic-inspector-username
- password=ironic-inspector-password
9 changes: 9 additions & 0 deletions config/overlays/e2e-release-0.5/ironic.env
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
HTTP_PORT=6180
PROVISIONING_IP=192.168.222.199
DEPLOY_KERNEL_URL=http://192.168.222.199:6180/images/ironic-python-agent.kernel
DEPLOY_RAMDISK_URL=http://192.168.222.199:6180/images/ironic-python-agent.initramfs
IRONIC_ENDPOINT=https://192.168.222.199:6385/v1/
CACHEURL=http://192.168.222.199/images
IRONIC_FAST_TRACK=true
IRONIC_KERNEL_PARAMS=console=ttyS0
IRONIC_INSPECTOR_VLAN_INTERFACES=all
36 changes: 36 additions & 0 deletions config/overlays/e2e-release-0.5/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
namespace: baremetal-operator-system
resources:
- https://github.com/metal3-io/baremetal-operator/config/overlays/basic-auth_tls?ref=release-0.5
configMapGenerator:
- name: ironic
behavior: create
envs:
- ironic.env
patches:
- patch: |
# Don't try to pull again the pre-loaded image
- op: replace
path: /spec/template/spec/containers/0/imagePullPolicy
value: IfNotPresent
target:
kind: Deployment
name: controller-manager
images:
- name: quay.io/metal3-io/baremetal-operator
newTag: release-0.5
# We cannot use suffix hashes since the kustomizations we build on
# cannot be aware of what suffixes we add.
generatorOptions:
disableNameSuffixHash: true
# NOTE: These credentials are generated automatically in hack/ci-e2e.sh
secretGenerator:
- name: ironic-credentials
files:
- username=ironic-username
- password=ironic-password
- name: ironic-inspector-credentials
files:
- username=ironic-inspector-username
- password=ironic-inspector-password
21 changes: 21 additions & 0 deletions config/overlays/fixture-release-0.3/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
resources:
- https://github.com/metal3-io/baremetal-operator/config/namespace?ref=release-0.3
- https://github.com/metal3-io/baremetal-operator/config/default?ref=release-0.3
patches:
- patch: |
# Enable test mode (fixture provider instead of ironic)
- op: add
path: /spec/template/spec/containers/0/args/-
value: --test-mode
# Don't try to pull again the pre-loaded image
- op: replace
path: /spec/template/spec/containers/0/imagePullPolicy
value: IfNotPresent
target:
kind: Deployment
name: controller-manager
images:
- name: quay.io/metal3-io/baremetal-operator
newTag: release-0.3
3 changes: 0 additions & 3 deletions config/overlays/fixture-release-0.4/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization

resources:
- https://github.com/metal3-io/baremetal-operator/config/namespace?ref=release-0.4
- https://github.com/metal3-io/baremetal-operator/config/default?ref=release-0.4

patches:
- patch: |
# Enable test mode (fixture provider instead of ironic)
Expand All @@ -18,7 +16,6 @@ patches:
target:
kind: Deployment
name: controller-manager

images:
- name: quay.io/metal3-io/baremetal-operator
newTag: release-0.4
21 changes: 21 additions & 0 deletions config/overlays/fixture-release-0.5/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
resources:
- https://github.com/metal3-io/baremetal-operator/config/namespace?ref=release-0.5
- https://github.com/metal3-io/baremetal-operator/config/default?ref=release-0.5
patches:
- patch: |
# Enable test mode (fixture provider instead of ironic)
- op: add
path: /spec/template/spec/containers/0/args/-
value: --test-mode
# Don't try to pull again the pre-loaded image
- op: replace
path: /spec/template/spec/containers/0/imagePullPolicy
value: IfNotPresent
target:
kind: Deployment
name: controller-manager
images:
- name: quay.io/metal3-io/baremetal-operator
newTag: release-0.5
18 changes: 7 additions & 11 deletions hack/ci-e2e.sh
Original file line number Diff line number Diff line change
Expand Up @@ -113,24 +113,20 @@ docker run --name image-server-e2e -d \
ssh-keygen -t ed25519 -f "${IMAGE_DIR}/ssh_testkey" -q -N ""

# Generate credentials
BMO_OVERLAY="${REPO_ROOT}/config/overlays/e2e"
BMO_OVERLAYS=("${REPO_ROOT}/config/overlays/e2e" "${REPO_ROOT}/config/overlays/e2e-release-0.4" "${REPO_ROOT}/config/overlays/e2e-release-0.5")
IRONIC_OVERLAY="${REPO_ROOT}/ironic-deployment/overlays/e2e"

IRONIC_USERNAME="$(tr -dc 'a-zA-Z0-9' < /dev/urandom | fold -w 12 | head -n 1)"
IRONIC_PASSWORD="$(tr -dc 'a-zA-Z0-9' < /dev/urandom | fold -w 12 | head -n 1)"
IRONIC_INSPECTOR_USERNAME="$(tr -dc 'a-zA-Z0-9' < /dev/urandom | fold -w 12 | head -n 1)"
IRONIC_INSPECTOR_PASSWORD="$(tr -dc 'a-zA-Z0-9' < /dev/urandom | fold -w 12 | head -n 1)"

echo "${IRONIC_USERNAME}" > "${BMO_OVERLAY}/ironic-username"
echo "${IRONIC_PASSWORD}" > "${BMO_OVERLAY}/ironic-password"
echo "${IRONIC_INSPECTOR_USERNAME}" > "${BMO_OVERLAY}/ironic-inspector-username"
echo "${IRONIC_INSPECTOR_PASSWORD}" > "${BMO_OVERLAY}/ironic-inspector-password"

BMO_UPGRADE_FROM_OVERLAY="${REPO_ROOT}/config/overlays/e2e-release-0.4"
echo "${IRONIC_USERNAME}" > "${BMO_UPGRADE_FROM_OVERLAY}/ironic-username"
echo "${IRONIC_PASSWORD}" > "${BMO_UPGRADE_FROM_OVERLAY}/ironic-password"
echo "${IRONIC_INSPECTOR_USERNAME}" > "${BMO_UPGRADE_FROM_OVERLAY}/ironic-inspector-username"
echo "${IRONIC_INSPECTOR_PASSWORD}" > "${BMO_UPGRADE_FROM_OVERLAY}/ironic-inspector-password"
for overlay in "${BMO_OVERLAYS[@]}"; do
echo "${IRONIC_USERNAME}" > "${overlay}/ironic-username"
echo "${IRONIC_PASSWORD}" > "${overlay}/ironic-password"
echo "${IRONIC_INSPECTOR_USERNAME}" > "${overlay}/ironic-inspector-username"
echo "${IRONIC_INSPECTOR_PASSWORD}" > "${overlay}/ironic-inspector-password"
done

envsubst < "${REPO_ROOT}/ironic-deployment/components/basic-auth/ironic-auth-config-tpl" > \
"${IRONIC_OVERLAY}/ironic-auth-config"
Expand Down
2 changes: 1 addition & 1 deletion test/e2e/config/fixture.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ variables:
UPGRADE_DEPLOY_IRONIC: "false"
UPGRADE_DEPLOY_BMO: "true"
UPGRADE_DEPLOY_CERT_MANAGER: "true"
UPGRADE_BMO_KUSTOMIZATION_FROM: "../../config/overlays/fixture-release-0.4"
UPGRADE_BMO_KUSTOMIZATION_FROM: "../../config/overlays/fixture-release-0.5"

IMAGE_URL: "http://192.168.222.1/cirros-0.6.2-x86_64-disk.img"
IMAGE_CHECKSUM: "c8fc807773e5354afe61636071771906"
Expand Down
2 changes: 1 addition & 1 deletion test/e2e/config/ironic.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ variables:
UPGRADE_DEPLOY_IRONIC: "true"
UPGRADE_DEPLOY_BMO: "true"
UPGRADE_DEPLOY_CERT_MANAGER: "true"
UPGRADE_BMO_KUSTOMIZATION_FROM: "../../config/overlays/e2e-release-0.4"
UPGRADE_BMO_KUSTOMIZATION_FROM: "../../config/overlays/e2e-release-0.5"

IMAGE_URL: "http://192.168.222.1/cirros-0.6.2-x86_64-disk.img"
IMAGE_CHECKSUM: "c8fc807773e5354afe61636071771906"
Expand Down
24 changes: 18 additions & 6 deletions test/e2e/upgrade_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -233,15 +233,17 @@ var _ = Describe("BMO Upgrade", func() {
}

if e2eConfig.GetVariable("UPGRADE_DEPLOY_BMO") != "false" {
By("Installing BMO on the upgrade cluster")
bmoKustomization := e2eConfig.GetVariable("UPGRADE_BMO_KUSTOMIZATION_FROM")
bmoKustomizationName := filepath.Base(bmoKustomization)
By(fmt.Sprintf("Installing BMO from %s on the upgrade cluster", bmoKustomization))
err := BuildAndApplyKustomize(ctx, &BuildAndApplyKustomizeInput{
Kustomization: e2eConfig.GetVariable("UPGRADE_BMO_KUSTOMIZATION_FROM"),
Kustomization: bmoKustomization,
ClusterProxy: upgradeClusterProxy,
WaitForDeployment: true,
WatchDeploymentLogs: true,
DeploymentName: "baremetal-operator-controller-manager",
DeploymentNamespace: bmoIronicNamespace,
LogPath: filepath.Join(artifactFolder, "logs", fmt.Sprintf("%s-%s", bmoIronicNamespace, specName)),
LogPath: filepath.Join(artifactFolder, "logs", fmt.Sprintf("%s-%s", bmoIronicNamespace, specName), fmt.Sprintf("bmo-%s", bmoKustomizationName)),
WaitIntervals: e2eConfig.GetIntervals("default", "wait-deployment"),
})
Expect(err).NotTo(HaveOccurred())
Expand Down Expand Up @@ -269,7 +271,9 @@ var _ = Describe("BMO Upgrade", func() {
Name: specName,
Namespace: namespace.Name,
Annotations: map[string]string{
metal3api.InspectAnnotationPrefix: "disabled",
metal3api.InspectAnnotationPrefix: "disabled",
// hardwareDetails of release0.4 is compatible to release0.3 and release0.5 as well
// This can be changed to the new hardwareDetails once we no longer test release0.4
metal3api.HardwareDetailsAnnotation: hardwareDetailsRelease04,
},
},
Expand Down Expand Up @@ -298,9 +302,17 @@ var _ = Describe("BMO Upgrade", func() {
bmoDeployName := "baremetal-operator-controller-manager"
deploy, err := clientSet.AppsV1().Deployments(bmoIronicNamespace).Get(ctx, bmoDeployName, metav1.GetOptions{})
Expect(err).NotTo(HaveOccurred())
bmoKustomization := e2eConfig.GetVariable("BMO_KUSTOMIZATION")
bmoKustomizationName := filepath.Base(bmoKustomization)
err = BuildAndApplyKustomize(ctx, &BuildAndApplyKustomizeInput{
Kustomization: e2eConfig.GetVariable("BMO_KUSTOMIZATION"),
ClusterProxy: upgradeClusterProxy,
Kustomization: bmoKustomization,
ClusterProxy: upgradeClusterProxy,
WaitForDeployment: false,
WatchDeploymentLogs: true,
DeploymentName: "baremetal-operator-controller-manager",
DeploymentNamespace: bmoIronicNamespace,
LogPath: filepath.Join(artifactFolder, "logs", fmt.Sprintf("%s-%s", bmoIronicNamespace, specName), fmt.Sprintf("bmo-%s", bmoKustomizationName)),
WaitIntervals: e2eConfig.GetIntervals("default", "wait-deployment"),
})
Expect(err).NotTo(HaveOccurred())
By("Waiting for BMO update to rollout")
Expand Down

0 comments on commit 4c94b2b

Please sign in to comment.