github.com/verrazzano/verrazzano@v1.7.1/tests/e2e/clusterapi/capi/capi_test.go (about)

     1  // Copyright (c) 2023, Oracle and/or its affiliates.
     2  // Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl.
     3  
     4  package capi
     5  
     6  import (
     7  	"context"
     8  	"encoding/base64"
     9  	"fmt"
    10  	"github.com/verrazzano/verrazzano/tests/e2e/pkg/test/framework/metrics"
    11  	"go.uber.org/zap"
    12  	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
    13  	"os"
    14  	"time"
    15  
    16  	. "github.com/onsi/ginkgo/v2"
    17  	. "github.com/onsi/gomega"
    18  	"github.com/verrazzano/verrazzano/pkg/k8sutil"
    19  	"github.com/verrazzano/verrazzano/tests/e2e/pkg"
    20  	"github.com/verrazzano/verrazzano/tests/e2e/pkg/test/framework"
    21  )
    22  
    23  const (
    24  	shortWaitTimeout               = 10 * time.Minute
    25  	shortPollingInterval           = 30 * time.Second
    26  	waitTimeout                    = 30 * time.Minute
    27  	capiClusterCreationWaitTimeout = 60 * time.Minute
    28  	pollingInterval                = 30 * time.Second
    29  	vzPollingInterval              = 60 * time.Second
    30  
    31  	// file paths
    32  	clusterTemplate              = "templates/cluster-template-addons-new-vcn.yaml"
    33  	clusterResourceSetTemplate   = "templates/cluster-template-addons.yaml"
    34  	clusterSecurityListTemplate  = "templates/cluster-template-addons-new-vcn-securitylist.yaml"
    35  	clusterClassTemplate         = "templates/cluster-template-cluster-class.yaml"
    36  	clusterResourceSetTemplateVZ = "templates/cluster-template-verrazzano-resource.yaml"
    37  	ocnecpmoduldisabled          = "templates/ocnecontrolplanemoduledisabled.yaml"
    38  	ocnecpmodulenabled           = "templates/ocnecontrolplanemoduleenabled.yaml"
    39  	moduleOperatorStatusType     = "ModuleOperatorDeployed"
    40  	moduleUninstalled            = "ModuleOperatorUninstalled"
    41  	vzOperatorStatusType         = "VerrazzanoPlatformOperatorDeployed"
    42  	vzOperatorUninstalled        = "VerrazzanoPlatformOperatorUninstalled"
    43  )
    44  
    45  var verrazzanoPlatformOperatorPods = []string{"verrazzano-platform-operator", "verrazzano-platform-operator-webhook"}
    46  var verrazzanoModuleOperatorPod = []string{"verrazzano-module-operator"}
    47  
    48  func init() {
    49  	ensureCAPIVarsInitialized()
    50  }
    51  
    52  var beforeSuite = t.BeforeSuiteFunc(func() {
    53  	start := time.Now()
    54  	capiPrerequisites()
    55  	metrics.Emit(t.Metrics.With("deployment_elapsed_time", time.Since(start).Milliseconds()))
    56  })
    57  
    58  var _ = BeforeSuite(beforeSuite)
    59  
    60  var afterSuite = t.AfterSuiteFunc(func() {
    61  	start := time.Now()
    62  	//capiCleanup()
    63  	metrics.Emit(t.Metrics.With("undeployment_elapsed_time", time.Since(start).Milliseconds()))
    64  })
    65  
    66  var _ = AfterSuite(afterSuite)
    67  
    68  var t = framework.NewTestFramework("cluster-api")
    69  
    70  var capiTest = NewCapiTestClient()
    71  
    72  // 'It' Wrapper to only run spec if the ClusterAPI is supported on the current Verrazzano version
    73  func WhenClusterAPIInstalledIt(description string, f func()) {
    74  	kubeconfigPath, err := k8sutil.GetKubeConfigLocation()
    75  	if err != nil {
    76  		t.It(description, func() {
    77  			Fail(fmt.Sprintf("Failed to get default kubeconfig path: %s", err.Error()))
    78  		})
    79  	}
    80  	supported, err := pkg.IsVerrazzanoMinVersion("1.6.0", kubeconfigPath)
    81  	if err != nil {
    82  		t.It(description, func() {
    83  			Fail(fmt.Sprintf("Failed to check Verrazzano version 1.6.0: %s", err.Error()))
    84  		})
    85  	}
    86  	if supported {
    87  		t.It(description, f)
    88  	} else {
    89  		t.Logs.Infof("Skipping check '%v',clusterAPI is not supported", description)
    90  	}
    91  }
    92  
    93  func EnsurePodsAreRunning(clusterName, namespace, podNamePrefix string, log *zap.SugaredLogger) bool {
    94  	k8sclient, err := capiTest.GetCapiClusterK8sClient(clusterName, log)
    95  	if err != nil {
    96  		t.Logs.Info("Failed to get k8s client for workload cluster")
    97  		return false
    98  	}
    99  
   100  	var podLabel string
   101  	switch podNamePrefix {
   102  	case "etcd":
   103  		podLabel = "component=etcd"
   104  	case "dns":
   105  		podLabel = "k8s-app=kube-dns"
   106  	case "apiserver":
   107  		podLabel = "component=kube-apiserver"
   108  	case "controller-manager":
   109  		podLabel = "component=kube-controller-manager"
   110  	case "proxy":
   111  		podLabel = "k8s-app=kube-proxy"
   112  	case "scheduler":
   113  		podLabel = "component=kube-scheduler"
   114  	case "ccm":
   115  		podLabel = "component=oci-cloud-controller-manager"
   116  	case "module":
   117  		podLabel = "app.kubernetes.io/instance=verrazzano-module-operator"
   118  	}
   119  	result, err := pkg.SpecificPodsRunningInClusterWithClient(namespace, podLabel, k8sclient)
   120  	if err != nil {
   121  		AbortSuite(fmt.Sprintf("One or more pods are not running in the namespace: %v, error: %v", namespace, err))
   122  	}
   123  
   124  	err = capiTest.DisplayWorkloadClusterResources(ClusterName, t.Logs)
   125  	if err != nil {
   126  		log.Errorf("Unable to display resources from workload cluster ", zap.Error(err))
   127  		return false
   128  	}
   129  
   130  	return result
   131  }
   132  
   133  func EnsureCSIPodsAreRunning(clusterName, namespace string, log *zap.SugaredLogger) bool {
   134  	k8sclient, err := capiTest.GetCapiClusterK8sClient(clusterName, log)
   135  	if err != nil {
   136  		t.Logs.Info("Failed to get k8s client for workload cluster")
   137  		return false
   138  	}
   139  	result1, err := pkg.SpecificPodsRunningInClusterWithClient(namespace, "app=csi-oci-node", k8sclient)
   140  	if err != nil {
   141  		AbortSuite(fmt.Sprintf("One or more pods are not running in the namespace: %v, error: %v", namespace, err))
   142  	}
   143  	result2, err := pkg.SpecificPodsRunningInClusterWithClient(namespace, "app=csi-oci-controller", k8sclient)
   144  	if err != nil {
   145  		AbortSuite(fmt.Sprintf("One or more pods are not running in the namespace: %v, error: %v", namespace, err))
   146  	}
   147  	err = capiTest.DisplayWorkloadClusterResources(ClusterName, t.Logs)
   148  	if err != nil {
   149  		log.Errorf("Unable to display resources from workload cluster ", zap.Error(err))
   150  		return false
   151  	}
   152  
   153  	return result1 && result2
   154  }
   155  
   156  func EnsureCalicoPodsAreRunning(clusterName string, log *zap.SugaredLogger) bool {
   157  	k8sclient, err := capiTest.GetCapiClusterK8sClient(clusterName, log)
   158  	if err != nil {
   159  		t.Logs.Info("Failed to get k8s client for workload cluster")
   160  		return false
   161  	}
   162  	result1, err := pkg.SpecificPodsRunningInClusterWithClient("calico-system", "app.kubernetes.io/name=calico-node", k8sclient)
   163  	if err != nil {
   164  		AbortSuite(fmt.Sprintf("One or more pods are not running in the namespace: calico-system, error: %v", err))
   165  	}
   166  	result2, err := pkg.SpecificPodsRunningInClusterWithClient("calico-system", "app.kubernetes.io/name=calico-kube-controllers", k8sclient)
   167  	if err != nil {
   168  		AbortSuite(fmt.Sprintf("One or more pods are not running in the namespace: calico-system, error: %v", err))
   169  	}
   170  	result3, err := pkg.SpecificPodsRunningInClusterWithClient("calico-apiserver", "app.kubernetes.io/name=calico-apiserver", k8sclient)
   171  	if err != nil {
   172  		AbortSuite(fmt.Sprintf("One or more pods are not running in the namespace: calico-apiserver, error: %v", err))
   173  	}
   174  	result4, err := pkg.SpecificPodsRunningInClusterWithClient("calico-system", "app.kubernetes.io/name=calico-typha", k8sclient)
   175  	if err != nil {
   176  		AbortSuite(fmt.Sprintf("One or more pods are not running in the namespace: calico-system, error: %v", err))
   177  	}
   178  
   179  	err = capiTest.DisplayWorkloadClusterResources(ClusterName, t.Logs)
   180  	if err != nil {
   181  		log.Errorf("Unable to display resources from workload cluster ", zap.Error(err))
   182  		return false
   183  	}
   184  
   185  	return result1 && result2 && result3 && result4
   186  }
   187  
   188  func EnsureVPOPodsAreRunning(clusterName, namespace string, log *zap.SugaredLogger) bool {
   189  	k8sclient, err := capiTest.GetCapiClusterK8sClient(clusterName, log)
   190  	if err != nil {
   191  		t.Logs.Info("Failed to get k8s client for workload cluster")
   192  		return false
   193  	}
   194  	result1, err := pkg.SpecificPodsRunningInClusterWithClient(namespace, "app=verrazzano-platform-operator", k8sclient)
   195  	if err != nil {
   196  		AbortSuite(fmt.Sprintf("One or more pods are not running in the namespace: %v, error: %v", namespace, err))
   197  	}
   198  	result2, err := pkg.SpecificPodsRunningInClusterWithClient(namespace, "app=verrazzano-platform-operator-webhook", k8sclient)
   199  	if err != nil {
   200  		AbortSuite(fmt.Sprintf("One or more pods are not running in the namespace: %v, error: %v", namespace, err))
   201  	}
   202  
   203  	err = capiTest.DisplayWorkloadClusterResources(ClusterName, t.Logs)
   204  	if err != nil {
   205  		log.Errorf("Unable to display resources from workload cluster ", zap.Error(err))
   206  		return false
   207  	}
   208  
   209  	return result1 && result2
   210  }
   211  
   212  func EnsurePodsAreNotRunning(clusterName, namespace string, nameprefix []string, log *zap.SugaredLogger) bool {
   213  	k8sclient, err := capiTest.GetCapiClusterK8sClient(clusterName, log)
   214  	if err != nil {
   215  		t.Logs.Info("Failed to get k8s client for workload cluster")
   216  		return false
   217  	}
   218  	result, err := pkg.SpecificPodsPodsNotRunningInClusterWithClient(namespace, k8sclient, nameprefix)
   219  	if err != nil {
   220  		AbortSuite(fmt.Sprintf("One or more pods are not running in the namespace: %v, error: %v", namespace, err))
   221  	}
   222  
   223  	return result
   224  }
   225  
   226  func EnsureSecret(clusterName, namespace, secretName string, log *zap.SugaredLogger) bool {
   227  	k8sclient, err := capiTest.GetCapiClusterK8sClient(clusterName, log)
   228  	if err != nil {
   229  		t.Logs.Info("Failed to get k8s client for workload cluster")
   230  		return false
   231  	}
   232  	secret, err := k8sclient.CoreV1().Secrets(namespace).Get(context.TODO(), secretName, metav1.GetOptions{})
   233  	if err != nil {
   234  		t.Logs.Info("Failed to get secret from workload cluster: %v", zap.Error(err))
   235  		return false
   236  	}
   237  
   238  	if secret != nil {
   239  		return true
   240  	}
   241  	return false
   242  }
   243  
   244  func EnsureConfigMap(clusterName, namespace, configMapName string, log *zap.SugaredLogger) bool {
   245  	k8sclient, err := capiTest.GetCapiClusterK8sClient(clusterName, log)
   246  	if err != nil {
   247  		t.Logs.Info("Failed to get k8s client for workload cluster")
   248  		return false
   249  	}
   250  	cm, err := k8sclient.CoreV1().ConfigMaps(namespace).Get(context.TODO(), configMapName, metav1.GetOptions{})
   251  	if err != nil {
   252  		t.Logs.Info("Failed to get configmap from workload cluster: %v", zap.Error(err))
   253  		return false
   254  	}
   255  
   256  	if cm != nil {
   257  		return true
   258  	}
   259  	return false
   260  }
   261  
   262  func EnvSet() error {
   263  	if err := os.Setenv(OCITenancyIDKeyBase64, base64.StdEncoding.EncodeToString([]byte(OCITenancyID))); err != nil {
   264  		return err
   265  	}
   266  	if err := os.Setenv(OCICredsFingerprintKeyBase64, base64.StdEncoding.EncodeToString([]byte(OCIFingerprint))); err != nil {
   267  		return err
   268  	}
   269  	if err := os.Setenv(OCIUserIDKeyBase64, base64.StdEncoding.EncodeToString([]byte(OCIUserID))); err != nil {
   270  		return err
   271  	}
   272  	return os.Setenv(OCIRegionKeyBase64, base64.StdEncoding.EncodeToString([]byte(OCIRegion)))
   273  }
   274  
   275  // Run as part of BeforeSuite
   276  func capiPrerequisites() {
   277  	t.Logs.Infof("Start capi pre-requisites for cluster '%s'", ClusterName)
   278  
   279  	t.Logs.Infof("Setup CAPI base64 encoded env values '%s'", ClusterName)
   280  	Eventually(func() error {
   281  		return EnvSet()
   282  	}, shortWaitTimeout, shortPollingInterval).Should(BeNil())
   283  
   284  	t.Logs.Infof("Process and set OCI private keys base64 encoded '%s'", ClusterName)
   285  	Eventually(func() error {
   286  		return capiTest.ProcessOCIPrivateKeysBase64(OCIPrivateKeyPath, OCIPrivateCredsKeyBase64, t.Logs)
   287  	}, shortWaitTimeout, shortPollingInterval).Should(BeNil())
   288  
   289  	t.Logs.Infof("Process and set OCI private key '%s'", ClusterName)
   290  	Eventually(func() error {
   291  		return capiTest.ProcessOCIPrivateKeysSingleLine(OCIPrivateKeyPath, OCICredsKey, t.Logs)
   292  	}, shortWaitTimeout, shortPollingInterval).Should(BeNil())
   293  
   294  	t.Logs.Infof("Process and set OCI node ssh key '%s'", ClusterName)
   295  	Eventually(func() error {
   296  		return capiTest.ProcessOCISSHKeys(OCISSHKeyPath, CAPINodeSSHKey, t.Logs)
   297  	}, shortWaitTimeout, shortPollingInterval).Should(BeNil())
   298  
   299  	t.Logs.Infof("Fetch and set OCI Image ID for cluster '%s'", ClusterName)
   300  	Eventually(func() error {
   301  		return capiTest.SetImageID(OCIImageIDKey, t.Logs)
   302  	}, shortWaitTimeout, shortPollingInterval).Should(BeNil())
   303  
   304  }
   305  
   306  var _ = t.Describe("CAPI e2e tests ,", Label("f:platform-verrazzano.capi-e2e-tests"), Serial, func() {
   307  
   308  	t.Context(fmt.Sprintf("Create CAPI cluster '%s'", ClusterName), func() {
   309  
   310  		WhenClusterAPIInstalledIt("Create CAPI cluster", func() {
   311  			Eventually(func() error {
   312  				return capiTest.TriggerCapiClusterCreation(OCNENamespace, clusterClassTemplate, t.Logs)
   313  			}, capiClusterCreationWaitTimeout, pollingInterval).Should(BeNil(), "Create CAPI cluster")
   314  		})
   315  
   316  		WhenClusterAPIInstalledIt("Monitor Cluster Creation", func() {
   317  			Eventually(func() error {
   318  				return capiTest.MonitorCapiClusterCreation(ClusterName, t.Logs)
   319  			}, capiClusterCreationWaitTimeout, pollingInterval).Should(BeNil(), "Monitor Cluster Creation")
   320  		})
   321  
   322  		WhenClusterAPIInstalledIt("Create ClusterResourceSets on CAPI cluster", func() {
   323  			Eventually(func() error {
   324  				return capiTest.DeployClusterInfraClusterResourceSets(ClusterName, clusterResourceSetTemplate, t.Logs)
   325  			}, capiClusterCreationWaitTimeout, pollingInterval).Should(BeNil(), "Create CAPI cluster")
   326  		})
   327  
   328  		WhenClusterAPIInstalledIt("Ensure ETCD pods in kube-system of CAPI workload cluster are running", func() {
   329  			Eventually(func() bool {
   330  				return EnsurePodsAreRunning(ClusterName, "kube-system", "etcd", t.Logs)
   331  			}, capiClusterCreationWaitTimeout, pollingInterval).Should(BeTrue(), "Check if pods are running")
   332  		})
   333  
   334  		WhenClusterAPIInstalledIt("Ensure kube API Server pods in kube-system of CAPI workload cluster are running", func() {
   335  			Eventually(func() bool {
   336  				return EnsurePodsAreRunning(ClusterName, "kube-system", "apiserver", t.Logs)
   337  			}, capiClusterCreationWaitTimeout, pollingInterval).Should(BeTrue(), "Check if pods are running")
   338  		})
   339  
   340  		WhenClusterAPIInstalledIt("Ensure kube controller pods in kube-system of CAPI workload cluster are running", func() {
   341  			Eventually(func() bool {
   342  				return EnsurePodsAreRunning(ClusterName, "kube-system", "controller-manager", t.Logs)
   343  			}, capiClusterCreationWaitTimeout, pollingInterval).Should(BeTrue(), "Check if pods are running")
   344  		})
   345  
   346  		WhenClusterAPIInstalledIt("Ensure kube scheduler pods in kube-system of CAPI workload cluster are running", func() {
   347  			Eventually(func() bool {
   348  				return EnsurePodsAreRunning(ClusterName, "kube-system", "scheduler", t.Logs)
   349  			}, waitTimeout, pollingInterval).Should(BeTrue(), "Check if pods are running")
   350  		})
   351  
   352  		WhenClusterAPIInstalledIt("Ensure kube proxy pods in kube-system of CAPI workload cluster are running", func() {
   353  			Eventually(func() bool {
   354  				return EnsurePodsAreRunning(ClusterName, "kube-system", "proxy", t.Logs)
   355  			}, capiClusterCreationWaitTimeout, pollingInterval).Should(BeTrue(), "Check if pods are running")
   356  		})
   357  
   358  		WhenClusterAPIInstalledIt("Ensure CCM pods in kube-system of CAPI workload cluster are running", func() {
   359  			Eventually(func() bool {
   360  				return EnsurePodsAreRunning(ClusterName, "kube-system", "ccm", t.Logs)
   361  			}, capiClusterCreationWaitTimeout, pollingInterval).Should(BeTrue(), "Check if pods are running")
   362  		})
   363  
   364  		WhenClusterAPIInstalledIt("Ensure CSI pods in kube-system of CAPI workload cluster are running", func() {
   365  			Eventually(func() bool {
   366  				return EnsureCSIPodsAreRunning(ClusterName, "kube-system", t.Logs)
   367  			}, capiClusterCreationWaitTimeout, pollingInterval).Should(BeTrue(), "Check if pods are running")
   368  		})
   369  
   370  		WhenClusterAPIInstalledIt("Ensure Calico pods in kube-system of CAPI workload cluster are running", func() {
   371  			Eventually(func() bool {
   372  				return EnsureCalicoPodsAreRunning(ClusterName, t.Logs)
   373  			}, capiClusterCreationWaitTimeout, pollingInterval).Should(BeTrue(), "Check if pods are running")
   374  		})
   375  
   376  		WhenClusterAPIInstalledIt("Ensure Module operator pods in verrazzano-module-operator of CAPI workload cluster are running", func() {
   377  			Eventually(func() bool {
   378  				return EnsurePodsAreRunning(ClusterName, "verrazzano-module-operator", "module", t.Logs)
   379  			}, capiClusterCreationWaitTimeout, pollingInterval).Should(BeTrue(), "Check if pods are running")
   380  		})
   381  
   382  		WhenClusterAPIInstalledIt("Ensure Verrazzano Platform operator pods in verrazzano-install of CAPI workload cluster are running", func() {
   383  			Eventually(func() bool {
   384  				return EnsureVPOPodsAreRunning(ClusterName, "verrazzano-install", t.Logs)
   385  			}, capiClusterCreationWaitTimeout, pollingInterval).Should(BeTrue(), "Check if pods are running")
   386  		})
   387  
   388  		WhenClusterAPIInstalledIt("Ensure secret 'test-overrides' is created on CAPI workload cluster", func() {
   389  			Eventually(func() bool {
   390  				return EnsureSecret(ClusterName, "default", "test-overrides", t.Logs)
   391  			}, capiClusterCreationWaitTimeout, pollingInterval).Should(BeTrue(), "Check if secret exists")
   392  		})
   393  
   394  		WhenClusterAPIInstalledIt("Ensure configmap 'test-overrides' is created on CAPI workload cluster", func() {
   395  			Eventually(func() bool {
   396  				return EnsureConfigMap(ClusterName, "default", "test-overrides", t.Logs)
   397  			}, capiClusterCreationWaitTimeout, pollingInterval).Should(BeTrue(), "Check if secret exists")
   398  		})
   399  
   400  	})
   401  
   402  	t.Context(fmt.Sprintf("Disable Module Operator and Verrazzano Platform Operator '%s'", ClusterName), func() {
   403  
   404  		WhenClusterAPIInstalledIt("Disable Module operator and VPO from CAPI cluster", func() {
   405  			Eventually(func() error {
   406  				return capiTest.ToggleModules("cluster.x-k8s.io", "v1beta1", "clusters", ClusterName, OCNENamespace, false, t.Logs)
   407  			}, capiClusterCreationWaitTimeout, pollingInterval).Should(BeNil(), "disable module and vpo")
   408  		})
   409  
   410  		WhenClusterAPIInstalledIt("Ensure Verrazzano Module operator pods in verrazzano-module-operator of CAPI workload cluster are not running", func() {
   411  			Eventually(func() bool {
   412  				return EnsurePodsAreNotRunning(ClusterName, "verrazzano-module-operator", verrazzanoModuleOperatorPod, t.Logs)
   413  			}, capiClusterCreationWaitTimeout, pollingInterval).Should(BeTrue(), "Check if module operator pods are not running")
   414  		})
   415  
   416  		WhenClusterAPIInstalledIt("Ensure Verrazzano Platform operator pods in verrazzano-install of CAPI workload cluster are not running", func() {
   417  			Eventually(func() bool {
   418  				return EnsurePodsAreNotRunning(ClusterName, "verrazzano-install", verrazzanoPlatformOperatorPods, t.Logs)
   419  			}, capiClusterCreationWaitTimeout, pollingInterval).Should(BeTrue(), "Check if vpo pods are not running")
   420  		})
   421  
   422  		WhenClusterAPIInstalledIt("Check OCNE Control plane status for module operator info", func() {
   423  			Eventually(func() bool {
   424  				return capiTest.CheckOCNEControlPlaneStatus(ClusterName, moduleOperatorStatusType, "False", moduleUninstalled, t.Logs)
   425  			}, capiClusterCreationWaitTimeout, pollingInterval).Should(BeTrue(), "check ocne status for module info")
   426  		})
   427  
   428  		WhenClusterAPIInstalledIt("Check OCNE Control plane status for verrazzano platform operator info", func() {
   429  			Eventually(func() bool {
   430  				return capiTest.CheckOCNEControlPlaneStatus(ClusterName, vzOperatorStatusType, "False", vzOperatorUninstalled, t.Logs)
   431  			}, capiClusterCreationWaitTimeout, pollingInterval).Should(BeTrue(), "check ocne status for vpo info")
   432  		})
   433  
   434  		WhenClusterAPIInstalledIt("Display objects from CAPI workload cluster", func() {
   435  			Eventually(func() error {
   436  				return capiTest.DisplayWorkloadClusterResources(ClusterName, t.Logs)
   437  			}, capiClusterCreationWaitTimeout, pollingInterval).Should(BeNil(), "Display objects from CAPI workload cluster")
   438  		})
   439  
   440  	})
   441  
   442  	t.Context(fmt.Sprintf("Enable Module Operator and Verrazzano Platform Operator '%s'", ClusterName), func() {
   443  		WhenClusterAPIInstalledIt("Enable Module operator and VPO from CAPI cluster", func() {
   444  			Eventually(func() error {
   445  				return capiTest.ToggleModules("cluster.x-k8s.io", "v1beta1", "clusters", ClusterName, OCNENamespace, true, t.Logs)
   446  			}, capiClusterCreationWaitTimeout, pollingInterval).Should(BeNil(), "enable module and vpo")
   447  		})
   448  
   449  		WhenClusterAPIInstalledIt("Check OCNE Control plane status for module operator info", func() {
   450  			Eventually(func() bool {
   451  				return capiTest.CheckOCNEControlPlaneStatus(ClusterName, moduleOperatorStatusType, "True", "", t.Logs)
   452  			}, capiClusterCreationWaitTimeout, pollingInterval).Should(BeTrue(), "check ocne status for module info")
   453  		})
   454  
   455  		WhenClusterAPIInstalledIt("Check OCNE Control plane status for verrazzano platform operator info", func() {
   456  			Eventually(func() bool {
   457  				return capiTest.CheckOCNEControlPlaneStatus(ClusterName, vzOperatorStatusType, "True", "", t.Logs)
   458  			}, capiClusterCreationWaitTimeout, pollingInterval).Should(BeTrue(), "check ocne status for vpo info")
   459  		})
   460  
   461  		WhenClusterAPIInstalledIt("Ensure Module operator pods in verrazzano-module-operator of CAPI workload cluster are running", func() {
   462  			Eventually(func() bool {
   463  				return EnsurePodsAreRunning(ClusterName, "verrazzano-module-operator", "module", t.Logs)
   464  			}, capiClusterCreationWaitTimeout, pollingInterval).Should(BeTrue(), "Check if pods are running")
   465  		})
   466  
   467  		WhenClusterAPIInstalledIt("Ensure Verrazzano Platform operator pods in verrazzano-install of CAPI workload cluster are running", func() {
   468  			Eventually(func() bool {
   469  				return EnsureVPOPodsAreRunning(ClusterName, "verrazzano-install", t.Logs)
   470  			}, capiClusterCreationWaitTimeout, pollingInterval).Should(BeTrue(), "Check if pods are running")
   471  		})
   472  
   473  	})
   474  
   475  	t.Context(fmt.Sprintf("Deploy Verrazzano and monitor vz install status  '%s'", ClusterName), func() {
   476  		WhenClusterAPIInstalledIt("Create ClusterResourceSets on CAPI cluster", func() {
   477  			Eventually(func() error {
   478  				return capiTest.DeployAnyClusterResourceSets(ClusterName, clusterResourceSetTemplateVZ, t.Logs)
   479  			}, capiClusterCreationWaitTimeout, pollingInterval).Should(BeNil(), "Create CAPI cluster")
   480  		})
   481  
   482  		t.Context(fmt.Sprintf("Verrazzano installation monitoring '%s'", ClusterName), func() {
   483  			WhenClusterAPIInstalledIt("Ensure Verrazzano install is completed on workload cluster", func() {
   484  				Eventually(func() error {
   485  					return capiTest.EnsureVerrazzano(ClusterName, t.Logs)
   486  				}, capiClusterCreationWaitTimeout, vzPollingInterval).Should(BeNil(), "verify verrazzano is installed")
   487  			})
   488  		})
   489  	})
   490  
   491  })