github.com/windmilleng/tilt@v0.13.6/integration/onewatch_test.go (about) 1 //+build integration 2 3 package integration 4 5 import ( 6 "context" 7 "testing" 8 "time" 9 10 "github.com/stretchr/testify/assert" 11 ) 12 13 func TestOneWatch(t *testing.T) { 14 f := newK8sFixture(t, "onewatch") 15 defer f.TearDown() 16 f.SetRestrictedCredentials() 17 18 f.TiltWatch() 19 20 ctx, cancel := context.WithTimeout(f.ctx, time.Minute) 21 defer cancel() 22 oneUpPods := f.WaitForAllPodsReady(ctx, "app=onewatch") 23 24 ctx, cancel = context.WithTimeout(f.ctx, time.Minute) 25 defer cancel() 26 f.CurlUntil(ctx, "http://localhost:31234", "🍄 One-Up! 🍄") 27 28 // Introduce a syntax error 29 f.ReplaceContents("compile.sh", "One-Up", "One-Up\"") 30 31 f.WaitUntil(ctx, "live_update syntax error", func() (string, error) { 32 return f.logs.String(), nil 33 }, "Failed to update container") 34 35 f.ReplaceContents("compile.sh", "One-Up\"", "Two-Up") 36 37 ctx, cancel = context.WithTimeout(f.ctx, time.Minute) 38 defer cancel() 39 f.CurlUntil(ctx, "http://localhost:31234", "🍄 Two-Up! 🍄") 40 41 twoUpPods := f.WaitForAllPodsReady(ctx, "app=onewatch") 42 43 // Assert that the pods were changed in-place, and not that we 44 // created new pods. 45 assert.Equal(t, oneUpPods, twoUpPods) 46 47 if len(twoUpPods) != 1 { 48 t.Fatalf("Expected one pod, actual: %v", twoUpPods) 49 } 50 51 // Delete the pod and make sure it got replaced with something that prints the 52 // same thing (crash rebuild). 53 f.runCommandSilently("kubectl", "delete", "pod", twoUpPods[0], namespaceFlag) 54 55 ctx, cancel = context.WithTimeout(f.ctx, time.Minute) 56 defer cancel() 57 f.CurlUntil(ctx, "http://localhost:31234", "🍄 Two-Up! 🍄") 58 59 newTwoUpPods := f.WaitForAllPodsReady(ctx, "app=onewatch") 60 assert.NotEqual(t, twoUpPods, newTwoUpPods) 61 }