Skip to content

Commit

Permalink
e2e: Install Cloud API Adaptor optionally
Browse files Browse the repository at this point in the history
Introduce an environment variable to control the installation of CAA.

Fixes: confidential-containers#1544
Signed-off-by: Yuan Yuan Wang <[email protected]>
  • Loading branch information
wyuany authored and Qi Feng Huo committed Nov 10, 2023
1 parent 0f79c3d commit 5004022
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 13 deletions.
2 changes: 2 additions & 0 deletions test/e2e/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ By default it is given 20 minutes for the entire e2e execution to complete, othe

To leave the cluster untouched by the execution finish you should export `TEST_TEARDOWN=no`, otherwise the framework will attempt to wipe out any resources created. For example, if `TEST_PROVISION=yes` is used to create a VPC and cluster for testing and `TEST_TEARDOWN=no` not specified, then at the end of the test the provisioned cluster and VPC, will both be deleted.

To use existing cluster which have already installed Cloud API Adaptor, you should export `TEST_INSTALL_CAA=no`.

## Provision file specifics

As mentioned on the previous section, a properties file can be passed to the cloud provisioner that will be used to controll the provisioning operations. The properties are specific of each cloud provider though, see on the sections below.
Expand Down
38 changes: 25 additions & 13 deletions test/e2e/main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,9 @@ import (
)

var (
testEnv env.Environment
cloudProvider string
provisioner pv.CloudProvisioner
cloudAPIAdaptor *pv.CloudAPIAdaptor
testEnv env.Environment
cloudProvider string
provisioner pv.CloudProvisioner
)

func init() {
Expand Down Expand Up @@ -64,6 +63,14 @@ func TestMain(m *testing.M) {
if os.Getenv("TEST_PROVISION") == "yes" {
shouldProvisionCluster = true
}
// Cloud API Adaptor is installed by default during e2e test.
// In case TEST_INSTALL_CAA is exported as "no", it will skip the installation of
// Cloud API Adaptor.
// In scenario of teardown, CAA will be cleanup when shouldTeardown is true and shoudlInstallCAA is true.
shoudlInstallCAA := true
if os.Getenv("TEST_INSTALL_CAA") == "no" {
shoudlInstallCAA = false
}

// The TEST_PODVM_IMAGE is an option variable which specifies the path
// to the podvm qcow2 image. If it set then the image should be uploaded to
Expand Down Expand Up @@ -93,7 +100,7 @@ func TestMain(m *testing.M) {
cfg := envconf.NewWithKubeConfig(kubeconfigPath)
testEnv = env.NewWithConfig(cfg)
}

var cloudAPIAdaptor *pv.CloudAPIAdaptor
// Run *once* before the tests.
testEnv.Setup(func(ctx context.Context, cfg *envconf.Config) (context.Context, error) {
log.Info("Do setup")
Expand All @@ -116,13 +123,17 @@ func TestMain(m *testing.M) {
return ctx, err
}
}
relativeInstallDirectory := "../../install"
if cloudAPIAdaptor, err = pv.NewCloudAPIAdaptor(cloudProvider, relativeInstallDirectory); err != nil {
return ctx, err
}
log.Info("Deploy the Cloud API Adaptor")
if err = cloudAPIAdaptor.Deploy(ctx, cfg, provisioner.GetProperties(ctx, cfg)); err != nil {
return ctx, err

if shoudlInstallCAA {
log.Info("Install Cloud API Adaptor")
relativeInstallDirectory := "../../install"
if cloudAPIAdaptor, err = pv.NewCloudAPIAdaptor(cloudProvider, relativeInstallDirectory); err != nil {
return ctx, err
}
log.Info("Deploy the Cloud API Adaptor")
if err = cloudAPIAdaptor.Deploy(ctx, cfg, provisioner.GetProperties(ctx, cfg)); err != nil {
return ctx, err
}
}
return ctx, nil
})
Expand All @@ -141,7 +152,8 @@ func TestMain(m *testing.M) {
log.Warnf("Failed to delete vpc resources, err: %s.", err)
return ctx, nil
}
} else {
}
if shoudlInstallCAA {
log.Info("Delete the Cloud API Adaptor installation")
if err = cloudAPIAdaptor.Delete(ctx, cfg); err != nil {
return ctx, err
Expand Down

0 comments on commit 5004022

Please sign in to comment.