github.com/tilt-dev/tilt@v0.36.0/integration/onewatch_test.go (about) 1 //go:build integration 2 // +build integration 3 4 package integration 5 6 import ( 7 "context" 8 "testing" 9 "time" 10 11 "github.com/stretchr/testify/assert" 12 ) 13 14 func TestOneWatch(t *testing.T) { 15 f := newK8sFixture(t, "onewatch") 16 f.SetRestrictedCredentials() 17 18 f.TiltUp() 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 }