github.com/smartcontractkit/chainlink-testing-framework/libs@v0.0.0-20240227141906-ec710b4eb1a3/k8s/e2e/remote-runner/remote_runner_envs_test.go (about) 1 package e2e_remote_runner_test 2 3 import ( 4 "fmt" 5 "testing" 6 "time" 7 8 "github.com/go-resty/resty/v2" 9 "github.com/rs/zerolog/log" 10 "github.com/stretchr/testify/assert" 11 "github.com/stretchr/testify/require" 12 13 "github.com/smartcontractkit/chainlink-testing-framework/libs/k8s/config" 14 "github.com/smartcontractkit/chainlink-testing-framework/libs/k8s/e2e/common" 15 "github.com/smartcontractkit/chainlink-testing-framework/libs/k8s/environment" 16 "github.com/smartcontractkit/chainlink-testing-framework/libs/k8s/pkg/helm/chainlink" 17 "github.com/smartcontractkit/chainlink-testing-framework/libs/k8s/pkg/helm/ethereum" 18 "github.com/smartcontractkit/chainlink-testing-framework/libs/k8s/pkg/helm/mockserver" 19 mockservercfg "github.com/smartcontractkit/chainlink-testing-framework/libs/k8s/pkg/helm/mockserver-cfg" 20 "github.com/smartcontractkit/chainlink-testing-framework/libs/k8s/presets" 21 ) 22 23 func TestMultiStageMultiManifestConnection(t *testing.T) { 24 common.TestMultiStageMultiManifestConnection(t) 25 } 26 27 func TestConnectWithoutManifest(t *testing.T) { 28 common.TestConnectWithoutManifest(t) 29 } 30 31 func Test5NodesSoakEnvironmentWithPVCs(t *testing.T) { 32 common.Test5NodesSoakEnvironmentWithPVCs(t) 33 } 34 35 func TestWithSingleNodeEnv(t *testing.T) { 36 common.TestWithSingleNodeEnvParallel(t) 37 } 38 39 func TestWithSingleNodeEnvLocalCharts(t *testing.T) { 40 t.Setenv(config.EnvVarLocalCharts, "true") 41 common.TestWithSingleNodeEnv(t) 42 } 43 44 func TestMultipleNodeWithDiffDBVersionEnv(t *testing.T) { 45 common.TestMultipleNodeWithDiffDBVersionEnv(t) 46 } 47 48 func TestMinResources5NodesEnv(t *testing.T) { 49 common.TestMinResources5NodesEnv(t) 50 } 51 52 func TestMinResources5NodesEnvWithBlockscout(t *testing.T) { 53 common.TestMinResources5NodesEnvWithBlockscout(t) 54 } 55 56 func TestMultipleInstancesOfTheSameType(t *testing.T) { 57 common.TestMultipleInstancesOfTheSameType(t) 58 } 59 60 func Test5NodesPlus2MiningGethsReorgEnv(t *testing.T) { 61 common.Test5NodesPlus2MiningGethsReorgEnv(t) 62 } 63 64 func TestWithChaos(t *testing.T) { 65 common.TestWithChaos(t) 66 } 67 68 func TestFundReturnShutdownLogic(t *testing.T) { 69 t.Parallel() 70 testEnvConfig := common.GetTestEnvConfig(t) 71 e := presets.EVMMinimalLocal(testEnvConfig) 72 err := e.Run() 73 if e.WillUseRemoteRunner() { 74 require.Error(t, err, "Should return an error") 75 return 76 } 77 t.Cleanup(func() { 78 assert.NoError(t, e.Shutdown()) 79 }) 80 require.NoError(t, err) 81 fmt.Println(environment.FAILED_FUND_RETURN) 82 } 83 84 func TestFailedTestLogic(t *testing.T) { 85 t.Skip("This test is meant to fail, and can only be evaluated by looking at the logs. Only turn on if checking this specific logic.") 86 t.Parallel() 87 testEnvConfig := common.GetTestEnvConfig(t) 88 e := presets.OnlyRemoteRunner(testEnvConfig) 89 err := e.Run() 90 if e.WillUseRemoteRunner() { 91 fmt.Println("Inside K8s?", e.Cfg.InsideK8s) 92 fmt.Println("Test Failed?", e.Cfg.Test.Failed()) 93 require.True(t, e.Cfg.Test.Failed(), "Test should have failed") 94 fmt.Println("This is a test-of-a-test and is confusing. The test that this tests should fail. But that also means this tests fails. If you're reading this, the test has actually passed.") 95 return 96 } 97 t.Cleanup(func() { 98 assert.NoError(t, e.Shutdown()) 99 }) 100 require.NoError(t, err) 101 fmt.Println("Inside K8s?", e.Cfg.InsideK8s) 102 fmt.Println(environment.TEST_FAILED) 103 } 104 105 func TestRemoteRunnerOneSetupWithMultipeTests(t *testing.T) { 106 t.Parallel() 107 testEnvConfig := common.GetTestEnvConfig(t) 108 ethChart := ethereum.New(nil) 109 e := environment.New(testEnvConfig). 110 AddHelm(mockservercfg.New(nil)). 111 AddHelm(mockserver.New(nil)). 112 AddHelm(ethChart). 113 AddHelm(chainlink.New(0, map[string]any{ 114 "replicas": 5, 115 "toml": presets.BaseToml, 116 })) 117 err := e.Run() 118 t.Cleanup(func() { 119 assert.NoError(t, e.Shutdown()) 120 }) 121 require.NoError(t, err) 122 if e.WillUseRemoteRunner() { 123 return 124 } 125 126 // setup of variables to use for verification in a t.Run 127 ethNetworkName := ethChart.GetProps().(*ethereum.Props).NetworkName 128 urls := make([]string, 0) 129 if e.Cfg.InsideK8s { 130 urls = append(urls, e.URLs[chainlink.NodesInternalURLsKey]...) 131 urls = append(urls, e.URLs[ethNetworkName+"_internal_http"]...) 132 } else { 133 urls = append(urls, e.URLs[chainlink.NodesLocalURLsKey]...) 134 urls = append(urls, e.URLs[ethNetworkName+"_http"]...) 135 } 136 137 log.Info().Str("Test", "Before").Msg("Before Tests") 138 139 // This test will verify we can connect a t.Run to the env of the parent test 140 t.Run("do one", func(t1 *testing.T) { 141 t1.Parallel() 142 test1EnvConfig := common.GetTestEnvConfig(t1) 143 test1EnvConfig.Namespace = e.Cfg.Namespace 144 test1EnvConfig.NoManifestUpdate = true 145 e1 := presets.EVMMinimalLocal(test1EnvConfig) 146 err := e1.Run() 147 require.NoError(t1, err) 148 log.Info().Str("Test", "One").Msg("Inside test") 149 time.Sleep(1 * time.Second) 150 }) 151 152 // This test will verify the sub t.Run properly uses the variables from the parent test 153 t.Run("do two", func(t2 *testing.T) { 154 t2.Parallel() 155 log.Info().Str("Test", "Two").Msg("Inside test") 156 r := resty.New() 157 for _, u := range urls { 158 log.Info().Str("URL", u).Send() 159 res, err := r.R().Get(u) 160 require.NoError(t2, err) 161 require.Equal(t2, "200 OK", res.Status()) 162 } 163 }) 164 165 log.Info().Str("Test", "After").Msg("After Tests") 166 } 167 168 func TestEmptyEnvironmentStartup(t *testing.T) { 169 common.TestEmptyEnvironmentStartup(t) 170 } 171 172 func TestRolloutRestartUpdate(t *testing.T) { 173 common.TestRolloutRestart(t, true) 174 } 175 176 func TestRolloutRestartBySelector(t *testing.T) { 177 common.TestRolloutRestart(t, false) 178 } 179 180 func TestReplaceHelm(t *testing.T) { 181 common.TestReplaceHelm(t) 182 } 183 184 func TestRunTimeout(t *testing.T) { 185 common.TestRunTimeout(t) 186 } 187 188 func TestReallyLongLogs(t *testing.T) { 189 common.TestReallyLongLogs(t) 190 }