Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,7 @@ test_ctr:
.PHONY: test_crictl
test_crictl:
@echo "Testing crictl"
@GOFLAGS=$(TEST_FLAGS) $(GO) test $(TEST_OPTS) ./tests/e2e -run TestCrictl -v
@GOFLAGS=$(TEST_FLAGS) $(GO) test $(TEST_OPTS) ./tests/e2e -run TestE2E -v --ginkgo.v --ginkgo.focus="Crictl"
@echo " "

## test_docker Run all end-to-end tests with docker
Expand Down Expand Up @@ -307,7 +307,7 @@ test_ctr_%:
.PHONY: test_crictl_%
test_crictl_%:
@echo "Testing crictl"
@GOFLAGS=$(TEST_FLAGS) $(GO) test $(TEST_OPTS) ./tests/e2e -v -run "TestCrictl/$*"
@GOFLAGS=$(TEST_FLAGS) $(GO) test $(TEST_OPTS) ./tests/e2e -v --ginkgo.v -run TestE2E --ginkgo.focus="Crictl.*$*"
@echo " "

## test_docker_[pattern] Run all end-to-end tests with docker that match pattern
Expand Down
112 changes: 112 additions & 0 deletions tests/e2e/crictl_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
// Copyright (c) 2023-2026, Nubificus LTD
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package urunce2etesting

import (
"fmt"
"os"

. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
)

const testCrictl = "TestCrictl"

var _ = Describe("Crictl", Ordered, ContinueOnFailure, func() {
var tool *crictlInfo

BeforeAll(func() {
cases := crictlTestCases()
images := getTestImages(cases)
err := pullAllImages(testCrictl, images)
Expect(err).NotTo(HaveOccurred(), "Failed to pull crictl images")

DeferCleanup(func() {
removeAllImages(testCrictl, images)
})
})

BeforeEach(func() {
setupTestDir()
})

ReportAfterEach(func(report SpecReport) {
if report.Failed() && tool != nil {
AddReportEntry("test-args", tool.getTestArgs())
}
})

DescribeTable("unikernel containers",
func(tc containerTestArgs) {
for _, vol := range tc.Volumes {
if _, err := os.Stat(vol.Source); err != nil {
Skip(fmt.Sprintf("Could not find %s", vol.Source))
}
}

tool = newCrictlTool(tc)

By("Creating pod")
pID, err := tool.createPod()
Expect(err).NotTo(HaveOccurred(), "Failed to create pod: %s", pID)
tool.setPodID(pID)

DeferCleanup(func() {
if tool != nil && tool.getPodID() != "" {
By("Stopping pod")
if err := tool.stopPod(); err != nil {
GinkgoLogr.Error(err, "Failed to stop pod")
}
By("Removing pod")
if err := tool.rmPod(); err != nil {
GinkgoLogr.Error(err, "Failed to remove pod")
}
}
})

By("Creating container")
cID, err := tool.createContainer()
Expect(err).NotTo(HaveOccurred(), "Failed to create container: %s", cID)
tool.setContainerID(cID)

DeferCleanup(func() {
if tool != nil && tool.getContainerID() != "" {
By("Stopping container")
if err := tool.stopContainer(); err != nil {
GinkgoLogr.Error(err, "Failed to stop container")
}
By("Removing container")
if err := tool.rmContainer(); err != nil {
GinkgoLogr.Error(err, "Failed to remove container")
}
By("Verifying container removal")
if err := testVerifyRm(tool); err != nil {
GinkgoLogr.Error(err, "Failed to verify removal")
}
}
})

By("Starting container")
output, err := tool.startContainer(true)
Expect(err).NotTo(HaveOccurred(), "Failed to start container: %s", output)

By("Running test function")
Eventually(func() error {
return tc.TestFunc(tool)
}, defaultTimeout, defaultInterval).Should(Succeed())
},
toTableEntries(crictlTestCases()),
)
})
10 changes: 0 additions & 10 deletions tests/e2e/e2e_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,6 @@ import (
"testing"
)

func TestCrictl(t *testing.T) {
tests := crictlTestCases()
for _, tc := range tests {
t.Run(tc.Name, func(t *testing.T) {
crictlTool := newCrictlTool(tc)
runTest(crictlTool, t)
})
}
}

func TestDocker(t *testing.T) {
tests := dockerTestCases()
for _, tc := range tests {
Expand Down
4 changes: 0 additions & 4 deletions tests/e2e/setup_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ import (

const (
testE2E = "TestE2E"
testCrictl = "TestCrictl"
testDocker = "TestDocker"
maxPullRetries = 5
pullRetryDelay = 2 * time.Second
Expand Down Expand Up @@ -71,13 +70,10 @@ func getTestCases(testFunc string) []containerTestArgs {
case testE2E:
// Images managed by BeforeAll in Ginkgo specs
return []containerTestArgs{}
case testCrictl:
return crictlTestCases()
case testDocker:
return dockerTestCases()
default:
var allCases []containerTestArgs
allCases = append(allCases, crictlTestCases()...)
allCases = append(allCases, dockerTestCases()...)
return allCases
}
Expand Down