mirror of
https://github.com/GoogleContainerTools/kaniko
synced 2026-10-21 02:49:07 +02:00
adding metadata tests back to integration tests (#185)
* adding metadata tests back to integration tests and fixing resulting bugs * fix onbuild and default env * removing old test files * adding the ArgsEscaped boolean on CMD commands * fix onbuild test * ignore failing test until container-diff is fixed * code comments * adding todo to remove uncomment failing test
This commit is contained in:
@@ -0,0 +1,8 @@
|
||||
FROM gcr.io/google-appengine/debian9
|
||||
EXPOSE 80
|
||||
EXPOSE 81/udp
|
||||
ENV protocol tcp
|
||||
EXPOSE 82/$protocol
|
||||
ENV port 83
|
||||
EXPOSE $port/udp
|
||||
EXPOSE $port/$protocol
|
||||
@@ -0,0 +1,7 @@
|
||||
FROM gcr.io/google-appengine/debian9
|
||||
LABEL foo=bar
|
||||
LABEL "baz"="bat"
|
||||
ENV label1 "mylabel"
|
||||
LABEL label1=$label1
|
||||
LABEL multilabel1=multilabel1 multilabel2=multilabel2 multilabel3=multilabel3
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
FROM gcr.io/distroless/base:latest
|
||||
COPY . .
|
||||
|
||||
FROM scratch as second
|
||||
ENV foopath context/foo
|
||||
COPY --from=0 $foopath context/b* /foo/
|
||||
|
||||
FROM gcr.io/distroless/base:latest
|
||||
ARG file
|
||||
COPY --from=second /foo $file
|
||||
@@ -17,3 +17,5 @@ RUN useradd testuser
|
||||
RUN groupadd testgroup
|
||||
USER testuser:testgroup
|
||||
RUN echo "hey" > /tmp/foo
|
||||
USER testuser:1001
|
||||
RUN echo "hey2" >> /tmp/foo
|
||||
@@ -44,14 +44,23 @@ const (
|
||||
buildContextPath = "/workspace"
|
||||
emptyContainerDiff = `[
|
||||
{
|
||||
"Image1": "%s:latest",
|
||||
"Image2": "%s:latest",
|
||||
"Image1": "%s",
|
||||
"Image2": "%s",
|
||||
"DiffType": "File",
|
||||
"Diff": {
|
||||
"Adds": null,
|
||||
"Dels": null,
|
||||
"Mods": null
|
||||
}
|
||||
},
|
||||
{
|
||||
"Image1": "%s",
|
||||
"Image2": "%s",
|
||||
"DiffType": "Metadata",
|
||||
"Diff": {
|
||||
"Adds": [],
|
||||
"Dels": []
|
||||
}
|
||||
}
|
||||
]`
|
||||
)
|
||||
@@ -76,7 +85,7 @@ func TestMain(m *testing.M) {
|
||||
}
|
||||
|
||||
func TestRun(t *testing.T) {
|
||||
dockerfiles, err := filepath.Glob(path.Join(dockerfilesPath, "Dockerfile*"))
|
||||
dockerfiles, err := filepath.Glob(path.Join(dockerfilesPath, "Dockerfile_test*"))
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
t.FailNow()
|
||||
@@ -93,16 +102,25 @@ func TestRun(t *testing.T) {
|
||||
"file=context/foo",
|
||||
"file3=context/b*",
|
||||
},
|
||||
"Dockerfile_test_multistage": {"file=/foo2"},
|
||||
}
|
||||
|
||||
bucketContextTests := []string{"Dockerfile_test_copy_bucket"}
|
||||
|
||||
// TODO: remove test_user_run from this when https://github.com/GoogleContainerTools/container-diff/issues/237 is fixed
|
||||
testsToIgnore := []string{"Dockerfile_test_user_run"}
|
||||
|
||||
_, ex, _, _ := runtime.Caller(0)
|
||||
cwd := filepath.Dir(ex)
|
||||
|
||||
for _, dockerfile := range dockerfiles {
|
||||
t.Run("test_"+dockerfile, func(t *testing.T) {
|
||||
dockerfile = dockerfile[len("dockerfile/")+1:]
|
||||
for _, d := range testsToIgnore {
|
||||
if dockerfile == d {
|
||||
t.SkipNow()
|
||||
}
|
||||
}
|
||||
t.Logf("%s\n", dockerfile)
|
||||
|
||||
var buildArgs []string
|
||||
@@ -151,11 +169,11 @@ func TestRun(t *testing.T) {
|
||||
daemonDockerImage := daemonPrefix + dockerImage
|
||||
containerdiffCmd := exec.Command("container-diff", "diff",
|
||||
daemonDockerImage, kanikoImage,
|
||||
"-q", "--type=file", "--json")
|
||||
"-q", "--type=file", "--type=metadata", "--json")
|
||||
diff := RunCommand(containerdiffCmd, t)
|
||||
t.Logf("diff = %s", string(diff))
|
||||
|
||||
expected := fmt.Sprintf(emptyContainerDiff, dockerImage, kanikoImage)
|
||||
expected := fmt.Sprintf(emptyContainerDiff, dockerImage, kanikoImage, dockerImage, kanikoImage)
|
||||
|
||||
// Let's compare the json objects themselves instead of strings to avoid
|
||||
// issues with spaces and indents
|
||||
|
||||
Reference in New Issue
Block a user