Skip to content

Commit

Permalink
HOSTEDCP-1462: Enable TestNodePool and CreateCluster tests on Azure
Browse files Browse the repository at this point in the history
  • Loading branch information
Patryk-Stefanski committed Mar 22, 2024
1 parent 93c619a commit 4793c3d
Show file tree
Hide file tree
Showing 5 changed files with 70 additions and 2 deletions.
4 changes: 4 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -280,6 +280,10 @@ ci-install-hypershift-private:
ci-test-e2e:
hack/ci-test-e2e.sh ${CI_TESTS_RUN}

.PHONY: ci-test-e2e-azure
ci-test-e2e-azure:
hack/ci-test-e2e-azure.sh

.PHONY: regenerate-pki
regenerate-pki:
REGENERATE_PKI=1 $(GO) test ./control-plane-pki-operator/...
Expand Down
39 changes: 39 additions & 0 deletions hack/ci-test-e2e-azure.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
#!/usr/bin/env bash
#
# This script takes the first argument and use it as the input for -test.run.

set -euo pipefail

set -o monitor

set -x

generate_junit() {
# propagate SIGTERM to the `test-e2e` process
for child in $( jobs -p ); do
kill "${child}"
done
# wait until `test-e2e` finishes gracefully
wait

cat /tmp/test_out | go tool test2json -t > /tmp/test_out.json
gotestsum --raw-command --junitfile="${ARTIFACT_DIR}/junit.xml" --format=standard-verbose -- cat /tmp/test_out.json
# Ensure generated junit has a useful suite name
sed -i 's/\(<testsuite.*\)name=""/\1 name="hypershift-e2e"/' "${ARTIFACT_DIR}/junit.xml"
}
trap generate_junit EXIT

bin/test-e2e \
-test.v \
-test.timeout=2h10m \
-test.run='^TestCreateCluster.*|^TestNodePool.*' \
-test.parallel=20 \
--e2e.platform=Azure \
--e2e.azure-credentials-file=/etc/hypershift-ci-jobs-azurecreds/credentials.json \
--e2e.pull-secret-file=/etc/ci-pull-credentials/.dockerconfigjson \
--e2e.base-domain=hypershift.azure.devcluster.openshift.com \
--e2e.latest-release-image="${OCP_IMAGE_LATEST}" \
--e2e.previous-release-image="${OCP_IMAGE_PREVIOUS}" \
| tee /tmp/test_out &

wait $!
13 changes: 13 additions & 0 deletions test/e2e/create_cluster_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,9 @@ func TestNoneCreateCluster(t *testing.T) {

// TestCreateClusterProxy implements a test that creates a cluster behind a proxy with the code under test.
func TestCreateClusterProxy(t *testing.T) {
if globalOpts.Platform != hyperv1.AWSPlatform {
t.Skip("test only supported on platform AWS")
}
t.Parallel()
ctx, cancel := context.WithCancel(testContext)
defer cancel()
Expand All @@ -177,6 +180,9 @@ func TestCreateClusterProxy(t *testing.T) {
// Validations requiring guest cluster client are dropped here since the kas is not accessible when private.
// In the future we might want to leverage https://issues.redhat.com/browse/HOSTEDCP-697 to access guest cluster.
func TestCreateClusterPrivate(t *testing.T) {
if globalOpts.Platform != hyperv1.AWSPlatform {
t.Skip("test only supported on platform AWS")
}
t.Parallel()

ctx, cancel := context.WithCancel(testContext)
Expand All @@ -197,6 +203,9 @@ func TestCreateClusterPrivate(t *testing.T) {
func testSwitchFromPrivateToPublic(ctx context.Context, client crclient.Client, hostedCluster *hyperv1.HostedCluster, clusterOpts *core.CreateOptions) func(t *testing.T) {
return func(t *testing.T) {
g := NewWithT(t)
if globalOpts.Platform != hyperv1.AWSPlatform {
t.Skip("test only supported on platform AWS")
}

err := e2eutil.UpdateObject(t, ctx, client, hostedCluster, func(obj *hyperv1.HostedCluster) {
obj.Spec.Platform.AWS.EndpointAccess = hyperv1.PublicAndPrivate
Expand All @@ -210,6 +219,10 @@ func testSwitchFromPrivateToPublic(ctx context.Context, client crclient.Client,
func testSwitchFromPublicToPrivate(ctx context.Context, client crclient.Client, hostedCluster *hyperv1.HostedCluster, clusterOpts *core.CreateOptions) func(t *testing.T) {
return func(t *testing.T) {
g := NewWithT(t)
if globalOpts.Platform != hyperv1.AWSPlatform {
t.Skip("test only supported on platform AWS")
}

err := e2eutil.UpdateObject(t, ctx, client, hostedCluster, func(obj *hyperv1.HostedCluster) {
obj.Spec.Platform.AWS.EndpointAccess = hyperv1.Private
})
Expand Down
2 changes: 1 addition & 1 deletion test/e2e/e2e_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -493,7 +493,7 @@ func (o *options) DefaultClusterOptions(t *testing.T) core.CreateOptions {
}

// Arch is only currently valid for aws platform
if o.Platform == hyperv1.AWSPlatform {
if o.Platform == hyperv1.AWSPlatform || o.Platform == hyperv1.AzurePlatform {
createOption.Arch = "amd64"
}

Expand Down
14 changes: 13 additions & 1 deletion test/e2e/util/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -1238,6 +1238,8 @@ func EnsurePodsWithEmptyDirPVsHaveSafeToEvictAnnotations(t *testing.T, ctx conte
"kubevirt-csi-driver": "app",
"cluster-image-registry-operator": "name",
"virt-launcher": "kubevirt.io",
"azure-disk-csi-driver-controller": "app",
"azure-file-csi-driver-controller": "app",
}

hcpPods := &corev1.PodList{}
Expand Down Expand Up @@ -1276,7 +1278,7 @@ func EnsurePodsWithEmptyDirPVsHaveSafeToEvictAnnotations(t *testing.T, ctx conte
for _, volume := range pod.Spec.Volumes {
// Check the pod's volumes, if they are emptyDir or hostPath,
// they should include that volume in the annotation
if volume.EmptyDir != nil || volume.HostPath != nil {
if (volume.EmptyDir != nil && volume.EmptyDir.Medium != corev1.StorageMediumMemory) || volume.HostPath != nil {
g.Expect(strings.Contains(annotationValue, volume.Name)).To(BeTrue(), "pod with name %s do not have the right volumes set in the safe-to-evict-local-volume annotation: \nCurrent: %s, Expected to be included in: %s", pod.Name, volume.Name, annotationValue)
}
}
Expand Down Expand Up @@ -1804,6 +1806,16 @@ func EnsureSATokenNotMountedUnlessNecessary(t *testing.T, ctx context.Context, c
"ovnkube-control-plane", //remove once https://issues.redhat.com/browse/OCPBUGS-26408 is closed,
)

if hostedCluster.Spec.Platform.Type == hyperv1.AzurePlatform {
expectedComponentsWithTokenMount = append(expectedComponentsWithTokenMount,
"azure-cloud-controller-manager",
"azure-disk-csi-driver-controller",
"azure-disk-csi-driver-operator",
"azure-file-csi-driver-controller",
"azure-file-csi-driver-operator",
)
}

if hostedCluster.Spec.Platform.Type == hyperv1.KubevirtPlatform {
expectedComponentsWithTokenMount = append(expectedComponentsWithTokenMount, hostedCluster.Name+"-test-",
"kubevirt-cloud-controller-manager",
Expand Down

0 comments on commit 4793c3d

Please sign in to comment.