Skip to content

Commit

Permalink
e2e: Modify DoTestCreateSimplePod to support CRIO
Browse files Browse the repository at this point in the history
DoTestCreateSimplePod should work with both cri-o and the default
containerd runtime

Signed-off-by: Pradipta Banerjee <pradipta.banerjee@gmail.com>
  • Loading branch information
bpradipt committed Jul 12, 2024
1 parent dd84e3e commit df2790f
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 1 deletion.
4 changes: 4 additions & 0 deletions src/cloud-api-adaptor/test/e2e/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@ func isTestWithKbs() bool {
return os.Getenv("DEPLOY_KBS") == "true" || os.Getenv("DEPLOY_KBS") == "yes"
}

func isTestOnCrio() bool {
return os.Getenv("CONTAINER_RUNTIME") == "crio"
}

type PodOption func(*corev1.Pod)

func WithRestartPolicy(restartPolicy corev1.RestartPolicy) PodOption {
Expand Down
6 changes: 5 additions & 1 deletion src/cloud-api-adaptor/test/e2e/common_suite.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,11 @@ var E2eNamespace = envconf.RandomName("coco-pp-e2e-test", 25)
// DoTestCreateSimplePod tests a simple peer-pod can be created.
func DoTestCreateSimplePod(t *testing.T, e env.Environment, assert CloudAssert) {
pod := NewBusyboxPodWithName(E2eNamespace, "simple-test")
NewTestCase(t, e, "SimplePeerPod", assert, "PodVM is created").WithPod(pod).WithNydusSnapshotter().Run()
if isTestOnCrio() {
NewTestCase(t, e, "SimplePeerPod", assert, "PodVM is created").WithPod(pod).Run()
} else {
NewTestCase(t, e, "SimplePeerPod", assert, "PodVM is created").WithPod(pod).WithNydusSnapshotter().Run()
}
}

func DoTestDeleteSimplePod(t *testing.T, e env.Environment, assert CloudAssert) {
Expand Down
14 changes: 14 additions & 0 deletions src/cloud-api-adaptor/test/e2e/main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@ var (
keyBrokerService *pv.KeyBrokerService
)

const (
defaultContainerRuntime = "containerd"
)

func init() {
initLogger()
}
Expand Down Expand Up @@ -123,6 +127,16 @@ func TestMain(m *testing.M) {
}
}

// Set CONTAINER_RUNTIME env variable if present in the properties
// Default value is containerd.
containerRuntime := defaultContainerRuntime
if props["CONTAINER_RUNTIME"] != "" {
containerRuntime = props["CONTAINER_RUNTIME"]
}

log.Infof("Container runtime: %s", containerRuntime)
os.Setenv("CONTAINER_RUNTIME", containerRuntime)

if shouldProvisionCluster {
log.Info("Cluster provisioning")
if err = provisioner.CreateVPC(ctx, cfg); err != nil {
Expand Down

0 comments on commit df2790f

Please sign in to comment.