Skip to content

Commit

Permalink
Merge pull request #2449 from dgageot/sync-notify-trigger
Browse files Browse the repository at this point in the history
Test Sync mode with both triggers
  • Loading branch information
balopat authored Jul 11, 2019
2 parents d8bf283 + 0db7e32 commit 2c9ed37
Showing 1 changed file with 37 additions and 19 deletions.
56 changes: 37 additions & 19 deletions integration/sync_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,30 +27,48 @@ import (
)

func TestDevSync(t *testing.T) {
if testing.Short() {
t.Skip("skipping integration test")
}
if ShouldRunGCPOnlyTests() {
t.Skip("skipping test that is not gcp only")
var tests = []struct {
description string
trigger string
}{
{
description: "sync with polling trigger",
trigger: "polling",
},
{
description: "sync with notify trigger",
trigger: "notify",
},
}
for _, test := range tests {
t.Run(test.description, func(t *testing.T) {
if testing.Short() {
t.Skip("skipping integration test")
}
if ShouldRunGCPOnlyTests() {
t.Skip("skipping test that is not gcp only")
}

ns, client, deleteNs := SetupNamespace(t)
defer deleteNs()
// Run skaffold build first to fail quickly on a build failure
skaffold.Build().InDir("testdata/file-sync").RunOrFail(t)

skaffold.Build().InDir("testdata/file-sync").InNs(ns.Name).RunOrFail(t)
ns, client, deleteNs := SetupNamespace(t)
defer deleteNs()

stop := skaffold.Dev().InDir("testdata/file-sync").InNs(ns.Name).RunBackground(t)
defer stop()
stop := skaffold.Dev("--trigger", test.trigger).InDir("testdata/file-sync").InNs(ns.Name).RunBackground(t)
defer stop()

client.WaitForPodsReady("test-file-sync")
client.WaitForPodsReady("test-file-sync")

Run(t, "testdata/file-sync", "mkdir", "-p", "test")
Run(t, "testdata/file-sync", "touch", "test/foobar")
defer Run(t, "testdata/file-sync", "rm", "-rf", "test")
Run(t, "testdata/file-sync", "mkdir", "-p", "test")
Run(t, "testdata/file-sync", "touch", "test/foobar")
defer Run(t, "testdata/file-sync", "rm", "-rf", "test")

err := wait.PollImmediate(time.Millisecond*500, 1*time.Minute, func() (bool, error) {
_, err := exec.Command("kubectl", "exec", "test-file-sync", "-n", ns.Name, "--", "ls", "/test").Output()
return err == nil, nil
})
testutil.CheckError(t, false, err)
err := wait.PollImmediate(time.Millisecond*500, 1*time.Minute, func() (bool, error) {
_, err := exec.Command("kubectl", "exec", "test-file-sync", "-n", ns.Name, "--", "ls", "/test").Output()
return err == nil, nil
})
testutil.CheckError(t, false, err)
})
}
}

0 comments on commit 2c9ed37

Please sign in to comment.