diff --git a/test/integration/image_test.go b/test/integration/image_test.go new file mode 100644 index 000000000000..f91fae18fbd2 --- /dev/null +++ b/test/integration/image_test.go @@ -0,0 +1,70 @@ +// +build integration + +/* +Copyright 2021 The Kubernetes Authors All rights reserved. + +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 integration + +import ( + "context" + "os/exec" + "path/filepath" + "testing" +) + +// TestImage tests minikube image +func TestImage(t *testing.T) { + profile := UniqueProfileName("image") + ctx, cancel := context.WithTimeout(context.Background(), Minutes(5)) + defer CleanupWithLogs(t, profile, cancel) + + args := append([]string{"start", "-p", profile, "--memory=2048"}, StartArgs()...) + rr, err := Run(t, exec.CommandContext(ctx, Target(), args...)) + if err != nil { + t.Fatalf("starting minikube: %v\n%s", err, rr.Output()) + } + + tests := []struct { + command string + args []string + }{ + { + command: "image", + args: []string{"load", filepath.Join(*testdataDir, "hello-world.tar")}, + }, { + command: "image", + args: []string{"list"}, + }, { + command: "image", + args: []string{"rm", "hello-world"}, + }, { + command: "image", + args: []string{"build", filepath.Join(*testdataDir, "build")}, + }, + } + + for _, test := range tests { + t.Run(test.command, func(t *testing.T) { + args := []string{test.command, "-p", profile} + args = append(args, test.args...) + + rr, err := Run(t, exec.CommandContext(ctx, Target(), args...)) + if err != nil { + t.Errorf("failed to clean up: args %q: %v", rr.Command(), err) + } + }) + } +} diff --git a/test/integration/testdata/build/Dockerfile b/test/integration/testdata/build/Dockerfile new file mode 100644 index 000000000000..4c3d9eb324c1 --- /dev/null +++ b/test/integration/testdata/build/Dockerfile @@ -0,0 +1,3 @@ +FROM busybox +RUN true +ADD content.txt diff --git a/test/integration/testdata/build/content.txt b/test/integration/testdata/build/content.txt new file mode 100644 index 000000000000..63817ba73c81 --- /dev/null +++ b/test/integration/testdata/build/content.txt @@ -0,0 +1 @@ +Content for image build diff --git a/test/integration/testdata/hello-world.tar b/test/integration/testdata/hello-world.tar new file mode 100644 index 000000000000..b7c198148468 Binary files /dev/null and b/test/integration/testdata/hello-world.tar differ