Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion cmd/skaffold/app/cmd/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -675,7 +675,7 @@ The build result from a previous 'skaffold build --file-output' run can be used
{
Name: "docker-network",
Shorthand: "",
Usage: "Run verify tests in the specified docker network",
Usage: "Name of an existing docker network to use when running the verify tests. If not specified, Skaffold will create a new network to use of the form 'skaffold-network-<uuid>'",
Value: &opts.VerifyDockerNetwork,
DefValue: "",
FlagAddMethod: "StringVar",
Expand Down
8 changes: 8 additions & 0 deletions integration/verify_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,14 @@ func TestLocalVerifyPassingTestsWithEnvVar(t *testing.T) {
// TODO(aaron-prindle) verify that SUCCEEDED event is found where expected
}

func TestVerifyWithNotCreatedNetwork(t *testing.T) {
MarkIntegrationTest(t, CanRunWithoutGcp)
// `--default-repo=` is used to cancel the default repo that is set by default.
logs, err := skaffold.Verify("--default-repo=", "--env-file", "verify.env", "--docker-network", "not-created-network").InDir("testdata/verify-succeed").RunWithCombinedOutput(t)
testutil.CheckError(t, true, err)
testutil.CheckContains(t, "network not-created-network not found", string(logs))
}

func TestLocalVerifyOneTestFailsWithEnvVar(t *testing.T) {
MarkIntegrationTest(t, CanRunWithoutGcp)
tmp := t.TempDir()
Expand Down
13 changes: 8 additions & 5 deletions pkg/skaffold/verify/docker/verify.go
Original file line number Diff line number Diff line change
Expand Up @@ -118,11 +118,14 @@ func (v *Verifier) TrackContainerFromBuild(artifact graph.Artifact, container tr
// from each specified image, executing them, and waiting for execution to complete.
func (v *Verifier) Verify(ctx context.Context, out io.Writer, allbuilds []graph.Artifact) error {
var err error
v.once.Do(func() {
err = v.client.NetworkCreate(ctx, v.network)
})
if err != nil {
return fmt.Errorf("creating skaffold network %s: %w", v.network, err)

if !v.networkFlagPassed {
v.once.Do(func() {
err = v.client.NetworkCreate(ctx, v.network)
})
if err != nil {
return fmt.Errorf("creating skaffold network %s: %w", v.network, err)
}
}

builds := []graph.Artifact{}
Expand Down