Skip to content

Commit 7654680

Browse files
authored
Merge pull request #1445 from saschagrunert/e2e-tests
Update e2e test suite
2 parents 6c92933 + 37e0b57 commit 7654680

File tree

11 files changed

+78
-315
lines changed

11 files changed

+78
-315
lines changed

.github/workflows/crio.yml

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: critest CRI-O
1+
name: CRI-O
22
on:
33
push:
44
tags:
@@ -7,14 +7,13 @@ on:
77
- master
88
pull_request:
99
jobs:
10-
#
11-
# Run CRI tests against CRI-O
12-
#
13-
linux-build-and-critest-cri-o:
10+
test:
1411
strategy:
1512
matrix:
16-
version: [main]
17-
name: ${{matrix.version}} / linux amd64
13+
suite:
14+
- e2e
15+
- critest
16+
name: ${{matrix.suite}}
1817
runs-on: ubuntu-22.04
1918
steps:
2019
- name: Install go
@@ -50,21 +49,13 @@ jobs:
5049
sudo sysctl -w net.ipv4.ip_forward=1
5150
sudo iptables -t nat -I POSTROUTING -s 127.0.0.0/8 ! -d 127.0.0.0/8 -j MASQUERADE
5251
53-
# enable criu support
54-
sudo apt-get update
55-
sudo apt-get install -y criu
56-
5752
- name: Install ginkgo
5853
run: |
5954
go install github.com/onsi/ginkgo/v2/ginkgo@latest
6055
ginkgo version
6156
sudo cp $(command -v ginkgo) /usr/local/bin
6257
63-
- name: Setup GCloud
64-
uses: google-github-actions/setup-gcloud@v2
65-
6658
- name: Install CRI-O latest main
67-
if: ${{matrix.version == 'main'}}
6859
run: |
6960
curl https://raw.githubusercontent.com/cri-o/packaging/main/get | sudo bash
7061
@@ -88,13 +79,21 @@ jobs:
8879
working-directory: ${{ github.workspace }}/src/github.com/kubernetes-sigs/cri-tools
8980

9081
- name: Run critest
82+
if: ${{matrix.suite == 'critest'}}
9183
run: |
9284
sudo -E PATH=$PATH critest \
9385
--runtime-endpoint=unix:///var/run/crio/crio.sock \
9486
--ginkgo.flakeAttempts=3 \
9587
--parallel=$(nproc)
9688
sudo journalctl -u crio > cri-o.log
9789
90+
- name: Run crictl e2e tests
91+
if: ${{matrix.suite == 'e2e'}}
92+
run: |
93+
sudo -E PATH=$PATH make test-e2e \
94+
TESTFLAGS="-crictl-runtime-endpoint=unix://var/run/crio/crio.sock"
95+
working-directory: ${{ github.workspace }}/src/github.com/kubernetes-sigs/cri-tools
96+
9897
- name: Upload CRI-O logs
9998
uses: actions/upload-artifact@v4
10099
with:

.github/workflows/e2e.yml

Lines changed: 0 additions & 79 deletions
This file was deleted.

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,3 +33,4 @@ Session.vim
3333

3434
/build
3535
release-notes.md
36+
test/e2e/e2e.test

Makefile

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -130,12 +130,14 @@ release-notes:
130130

131131
# needs to run as root to work
132132
test-e2e: $(GINKGO)
133-
$(GINKGO) $(TESTFLAGS) \
134-
-r -p \
135-
--randomizeAllSpecs \
136-
--randomizeSuites \
137-
--slowSpecThreshold 60 \
138-
test
133+
$(GINKGO) \
134+
-r \
135+
--randomize-all \
136+
--randomize-suites \
137+
--slow-spec-threshold 60s \
138+
test \
139+
-- \
140+
$(TESTFLAGS)
139141

140142
test-crictl: $(GINKGO)
141143
# Run go test for templates_test.go and util_test.go

test/e2e/events_test.go

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ import (
2020
. "github.com/onsi/ginkgo/v2"
2121
. "github.com/onsi/gomega"
2222
. "github.com/onsi/gomega/gbytes"
23-
. "github.com/onsi/gomega/gexec"
2423
)
2524

2625
// The actual test suite
@@ -40,20 +39,8 @@ var _ = t.Describe("events options validation", func() {
4039

4140
// The actual test suite
4241
var _ = t.Describe("events", func() {
43-
var (
44-
endpoint, testDir string
45-
crio *Session
46-
)
47-
BeforeEach(func() {
48-
endpoint, testDir, crio = t.StartCrio()
49-
})
50-
51-
AfterEach(func() {
52-
t.StopCrio(testDir, crio)
53-
})
54-
5542
It("should succeed", func() {
56-
session := t.CrictlWithEndpointNoWait(endpoint, "events")
43+
session := t.CrictlNoWait("events")
5744
defer session.Terminate()
5845
Expect(session.Out).ToNot(Say("unknown method GetContainerEvents")) // no errors
5946
})

test/e2e/help_test.go

Lines changed: 6 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ package e2e
1818

1919
import (
2020
. "github.com/onsi/ginkgo/v2"
21-
. "github.com/onsi/gomega/gexec"
2221
)
2322

2423
// The actual test suite
@@ -46,40 +45,27 @@ var _ = t.Describe("help", func() {
4645

4746
// The actual test suite
4847
var _ = t.Describe("help subcommand", func() {
49-
50-
var (
51-
endpoint, testDir string
52-
crio *Session
53-
)
54-
BeforeEach(func() {
55-
endpoint, testDir, crio = t.StartCrio()
56-
})
57-
58-
AfterEach(func() {
59-
t.StopCrio(testDir, crio)
60-
})
61-
6248
It("should show help running rm without params", func() {
63-
t.CrictlExpectSuccessWithEndpoint(endpoint, "rm", "crictl rm command")
49+
t.CrictlExpectSuccess("rm", "crictl rm command")
6450
})
6551

6652
It("should show help running rmi without params", func() {
67-
t.CrictlExpectSuccessWithEndpoint(endpoint, "rmi", "crictl rmi command")
53+
t.CrictlExpectSuccess("rmi", "crictl rmi command")
6854
})
6955

7056
It("should show help running rmp without params", func() {
71-
t.CrictlExpectSuccessWithEndpoint(endpoint, "rmp", "crictl rmp command")
57+
t.CrictlExpectSuccess("rmp", "crictl rmp command")
7258
})
7359

7460
It("should not show help running rm -a", func() {
75-
t.CrictlExpect(endpoint, "rm -a", 0, "", "No containers to remove")
61+
t.CrictlExpect("rm -a", 0, "", "No containers to remove")
7662
})
7763

7864
It("should not show help running rmi -a", func() {
79-
t.CrictlExpect(endpoint, "rmi -a", 0, "", "No images to remove")
65+
t.CrictlExpect("rmi -a", 0, "", "No images to remove")
8066
})
8167

8268
It("should not show help running rmp -a", func() {
83-
t.CrictlExpect(endpoint, "rmp -a", 0, "", "No pods to remove")
69+
t.CrictlExpect("rmp -a", 0, "", "No pods to remove")
8470
})
8571
})

test/e2e/info_test.go

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -18,26 +18,12 @@ package e2e
1818

1919
import (
2020
. "github.com/onsi/ginkgo/v2"
21-
. "github.com/onsi/gomega/gexec"
2221
)
2322

2423
// The actual test suite
2524
var _ = t.Describe("info", func() {
26-
27-
var (
28-
endpoint, testDir string
29-
crio *Session
30-
)
31-
BeforeEach(func() {
32-
endpoint, testDir, crio = t.StartCrio()
33-
})
34-
35-
AfterEach(func() {
36-
t.StopCrio(testDir, crio)
37-
})
38-
3925
It("should succeed", func() {
40-
t.CrictlExpectSuccessWithEndpoint(endpoint, "info", "NetworkReady")
26+
t.CrictlExpectSuccess("info", "NetworkReady")
4127
})
4228

4329
It("should fail with additional argument", func() {

test/e2e/pull_test.go

Lines changed: 9 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -18,42 +18,35 @@ package e2e
1818

1919
import (
2020
. "github.com/onsi/ginkgo/v2"
21+
. "github.com/onsi/gomega"
2122
. "github.com/onsi/gomega/gexec"
2223
)
2324

2425
// The actual test suite
2526
var _ = t.Describe("pull", func() {
26-
var (
27-
endpoint, testDir string
28-
crio *Session
29-
)
30-
BeforeEach(func() {
31-
endpoint, testDir, crio = t.StartCrio()
32-
})
33-
34-
AfterEach(func() {
35-
t.StopCrio(testDir, crio)
36-
})
37-
3827
const (
3928
imageSuccessText = "Image is up to date"
4029
registry = "gcr.io/k8s-staging-cri-tools/"
4130
)
4231

32+
AfterEach(func() {
33+
Expect(t.Crictl("rmi -a")).To(Exit(0))
34+
})
35+
4336
It("should succeed without tag or digest", func() {
44-
t.CrictlExpectSuccessWithEndpoint(endpoint,
37+
t.CrictlExpectSuccess(
4538
"pull "+registry+"test-image-1",
4639
imageSuccessText)
4740
})
4841

4942
It("should succeed with tag", func() {
50-
t.CrictlExpectSuccessWithEndpoint(endpoint,
43+
t.CrictlExpectSuccess(
5144
"pull "+registry+"test-image-1:latest",
5245
imageSuccessText)
5346
})
5447

5548
It("should succeed with digest", func() {
56-
t.CrictlExpectSuccessWithEndpoint(endpoint,
49+
t.CrictlExpectSuccess(
5750
"pull "+registry+"test-image-digest"+
5851
"@sha256:9700f9a2f5bf2c45f2f605a0bd3bce7cf37420ec9d3ed50ac2758413308766bf",
5952
imageSuccessText)
@@ -64,7 +57,6 @@ var _ = t.Describe("pull", func() {
6457
})
6558

6659
It("should fail on not existing image", func() {
67-
t.CrictlExpectFailureWithEndpoint(endpoint, "pull localhost/wrong",
68-
"", "pulling image")
60+
t.CrictlExpectFailure("pull localhost/wrong", "", "pulling image")
6961
})
7062
})

test/e2e/suite_test.go

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -32,14 +32,9 @@ func TestE2E(t *testing.T) {
3232

3333
var t *TestFramework
3434

35-
var _ = SynchronizedBeforeSuite(func() []byte {
36-
// Setup only once
37-
dir := SetupCrio()
38-
return []byte(dir)
39-
40-
}, func(dir []byte) {
35+
var _ = BeforeSuite(func() {
4136
t = NewTestFramework()
42-
t.Setup(string(dir))
37+
t.Setup()
4338
})
4439

4540
var _ = AfterSuite(func() {

test/e2e/version_test.go

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,6 @@ import (
2323
// The actual test suite
2424
var _ = t.Describe("version", func() {
2525
It("should succeed", func() {
26-
// Given
27-
endpoint, testDir, crio := t.StartCrio()
28-
29-
// When
30-
t.CrictlExpectSuccessWithEndpoint(endpoint, "version", "RuntimeName: cri-o")
31-
32-
// Then
33-
t.StopCrio(testDir, crio)
26+
t.CrictlExpectSuccess("version", "RuntimeName: ")
3427
})
3528
})

0 commit comments

Comments
 (0)