Skip to content

Commit f3a668a

Browse files
authored
Merge pull request #534 from openSUSE/pull-tests
Add `crictl pull` e2e tests
2 parents 84b8540 + 7edbab2 commit f3a668a

File tree

3 files changed

+77
-2
lines changed

3 files changed

+77
-2
lines changed

Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,7 @@ test-e2e: $(GINKGO)
110110
--randomizeAllSpecs \
111111
--randomizeSuites \
112112
--succinct \
113+
--slowSpecThreshold 60 \
113114
test
114115

115116
vendor:

test/e2e/pull_test.go

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
/*
2+
Copyright 2017 The Kubernetes Authors.
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
*/
16+
17+
package e2e
18+
19+
import (
20+
. "github.com/onsi/ginkgo"
21+
. "github.com/onsi/gomega/gexec"
22+
)
23+
24+
// The actual test suite
25+
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+
38+
const imageSuccessText = "Image is up to date"
39+
40+
It("should succeed without tag or digest", func() {
41+
t.CrictlExpectSuccessWithEndpoint(endpoint,
42+
"pull gcr.io/cri-tools/test-image-1",
43+
imageSuccessText)
44+
})
45+
46+
It("should succeed with tag", func() {
47+
t.CrictlExpectSuccessWithEndpoint(endpoint,
48+
"pull gcr.io/cri-tools/test-image-1:latest",
49+
imageSuccessText)
50+
})
51+
52+
It("should succeed with digest", func() {
53+
t.CrictlExpectSuccessWithEndpoint(endpoint,
54+
"pull gcr.io/cri-tools/test-image-digest"+
55+
"@sha256:9179135b4b4cc5a8721e09379244807553c318d92fa3111a65133241551ca343",
56+
imageSuccessText)
57+
})
58+
59+
It("should succeed to show the help", func() {
60+
t.CrictlExpectSuccess("pull -h", "Pull an image")
61+
})
62+
63+
It("should fail on not existing image", func() {
64+
t.CrictlExpectFailureWithEndpoint(endpoint, "pull localhost/wrong",
65+
"", "pulling image failed")
66+
})
67+
})

test/framework/framework.go

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ func (t *TestFramework) Crictl(args string) *Session {
8787

8888
// Run crictl on the specified endpoint and return the resulting session
8989
func (t *TestFramework) CrictlWithEndpoint(endpoint, args string) *Session {
90-
return lcmd("crictl --runtime-endpoint=%s %s", endpoint, args).Wait()
90+
return lcmd("crictl --runtime-endpoint=%s %s", endpoint, args).Wait(time.Minute)
9191
}
9292

9393
// Run crictl and expect success containing the specified output
@@ -109,9 +109,16 @@ func (t *TestFramework) CrictlExpectSuccessWithEndpoint(endpoint, args, expected
109109
// Run crictl and expect error containing the specified outputs
110110
func (t *TestFramework) CrictlExpectFailure(
111111
args string, expectedOut, expectedErr string,
112+
) {
113+
t.CrictlExpectFailureWithEndpoint("", args, expectedOut, expectedErr)
114+
}
115+
116+
// Run crictl and expect failure containing the specified output
117+
func (t *TestFramework) CrictlExpectFailureWithEndpoint(
118+
endpoint, args, expectedOut, expectedErr string,
112119
) {
113120
// When
114-
res := t.Crictl(args)
121+
res := t.CrictlWithEndpoint(endpoint, args)
115122

116123
// Then
117124
Expect(res).To(Exit(1))

0 commit comments

Comments
 (0)