Skip to content

Instantly share code, notes, and snippets.

@kuritka
Last active July 16, 2021 10:57
Show Gist options
  • Save kuritka/36ce6d2118b8f625dc88fa11ac4b3ea3 to your computer and use it in GitHub Desktop.
Save kuritka/36ce6d2118b8f625dc88fa11ac4b3ea3 to your computer and use it in GitHub Desktop.
k8gb test abstraction
package test
import (
"github.com/stretchr/testify/require"
"k8gbterratest/utils"
"testing"
)
func TestMyDemo(t *testing.T) {
const host= "terratest-failover.cloud.example.com"
const gslbPath = "../examples/failover.yaml"
i1, _ := utils.NewWorkflow(t,"k3d-test-gslb1",5053).WithGslb(gslbPath,host).WithTestApp("eu").Start()
defer i1.Kill()
i2, _ := utils.NewWorkflow(t,"k3d-test-gslb2",5054).WithGslb(gslbPath,host).WithTestApp("us").Start()
defer i2.Kill()
lt2 := i2.GetLocalTargets()
t.Run("wait until apps are started", func(t *testing.T) {
require.NoError(t, i1.WaitForAppIsRunning())
require.NoError(t,i2.WaitForAppIsRunning())
})
t.Run("stop testapp on the first cluster", func(t *testing.T){
i1.StopTestApp()
i1.WaitForExpected(lt2)
i2.WaitForExpected(lt2)
require.True(t, utils.EqualStringSlices(i1.Dig(), lt2))
require.True(t, utils.EqualStringSlices(i2.Dig(), lt2))
})
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment