Skip to content

Commit

Permalink
chore: add tests for the Kata Containers extension
Browse files Browse the repository at this point in the history
Let's add a very basic test for the Kata Containers extension, mimicing
what's already in place for gVisor.

This depends on the work being done in:
siderolabs/extensions#279

Signed-off-by: Fabiano Fidêncio <[email protected]>
Signed-off-by: Noel Georgi <[email protected]>
  • Loading branch information
fidencio authored and frezbo committed Feb 20, 2024
1 parent 9b62919 commit 64e9703
Showing 1 changed file with 19 additions and 8 deletions.
27 changes: 19 additions & 8 deletions internal/integration/api/extensions_qemu.go
Original file line number Diff line number Diff line change
Expand Up @@ -364,36 +364,47 @@ func (suite *ExtensionsSuiteQEMU) TestExtensionsHelloWorldService() {

// TestExtensionsGvisor verifies gvisor runtime class is working.
func (suite *ExtensionsSuiteQEMU) TestExtensionsGvisor() {
suite.testRuntimeClass("gvisor", "runsc")
}

// TestExtensionsKataContainers verifies gvisor runtime class is working.
func (suite *ExtensionsSuiteQEMU) TestExtensionsKataContainers() {
suite.testRuntimeClass("kata", "kata")
}

func (suite *ExtensionsSuiteQEMU) testRuntimeClass(runtimeClassName, handlerName string) {
testName := "nginx-" + runtimeClassName

_, err := suite.Clientset.NodeV1().RuntimeClasses().Create(suite.ctx, &nodev1.RuntimeClass{
ObjectMeta: metav1.ObjectMeta{
Name: "gvisor",
Name: runtimeClassName,
},
Handler: "runsc",
Handler: handlerName,
}, metav1.CreateOptions{})
defer suite.Clientset.NodeV1().RuntimeClasses().Delete(suite.ctx, "gvisor", metav1.DeleteOptions{}) //nolint:errcheck
defer suite.Clientset.NodeV1().RuntimeClasses().Delete(suite.ctx, runtimeClassName, metav1.DeleteOptions{}) //nolint:errcheck

suite.Require().NoError(err)

_, err = suite.Clientset.CoreV1().Pods("default").Create(suite.ctx, &corev1.Pod{
ObjectMeta: metav1.ObjectMeta{
Name: "nginx-gvisor",
Name: testName,
},
Spec: corev1.PodSpec{
RuntimeClassName: pointer.To("gvisor"),
RuntimeClassName: pointer.To(runtimeClassName),
Containers: []corev1.Container{
{
Name: "nginx-gvisor",
Name: testName,
Image: "nginx",
},
},
},
}, metav1.CreateOptions{})
defer suite.Clientset.CoreV1().Pods("default").Delete(suite.ctx, "nginx-gvisor", metav1.DeleteOptions{}) //nolint:errcheck
defer suite.Clientset.CoreV1().Pods("default").Delete(suite.ctx, testName, metav1.DeleteOptions{}) //nolint:errcheck

suite.Require().NoError(err)

// wait for the pod to be ready
suite.Require().NoError(suite.WaitForPodToBeRunning(suite.ctx, 5*time.Minute, "default", "nginx-gvisor"))
suite.Require().NoError(suite.WaitForPodToBeRunning(suite.ctx, 5*time.Minute, "default", testName))
}

// TestExtensionsStargz verifies stargz snapshotter.
Expand Down

0 comments on commit 64e9703

Please sign in to comment.