Skip to content

Commit

Permalink
Add skeleton for minikube image integration test
Browse files Browse the repository at this point in the history
  • Loading branch information
afbjorklund committed Apr 21, 2021
1 parent 943561b commit a267c60
Show file tree
Hide file tree
Showing 4 changed files with 74 additions and 0 deletions.
70 changes: 70 additions & 0 deletions test/integration/image_test.go
Original file line number Diff line number Diff line change
@@ -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)
}
})
}
}
3 changes: 3 additions & 0 deletions test/integration/testdata/build/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
FROM busybox
RUN true
ADD content.txt
1 change: 1 addition & 0 deletions test/integration/testdata/build/content.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Content for image build
Binary file added test/integration/testdata/hello-world.tar
Binary file not shown.

0 comments on commit a267c60

Please sign in to comment.