From 20d8b168d92bcfb54ac829dd02cd60c7616ad9ca Mon Sep 17 00:00:00 2001 From: Tate Date: Wed, 13 Dec 2023 10:14:37 -0700 Subject: [PATCH] Triage really long logs issues --- .github/workflows/k8s-e2e.yaml | 1 + k8s/e2e/common/test_common.go | 22 ++ k8s/e2e/local-runner/envs_test.go | 101 +++--- .../remote-runner/remote_runner_envs_test.go | 302 +++++++++--------- 4 files changed, 221 insertions(+), 205 deletions(-) diff --git a/.github/workflows/k8s-e2e.yaml b/.github/workflows/k8s-e2e.yaml index 40a450315..8a48dbb3e 100644 --- a/.github/workflows/k8s-e2e.yaml +++ b/.github/workflows/k8s-e2e.yaml @@ -1,6 +1,7 @@ name: (k8s package) E2E tests on: pull_request: + workflow_dispatch: concurrency: group: e2e-tests-k8s-${{ github.ref }} diff --git a/k8s/e2e/common/test_common.go b/k8s/e2e/common/test_common.go index 77dd09f77..385389439 100644 --- a/k8s/e2e/common/test_common.go +++ b/k8s/e2e/common/test_common.go @@ -18,6 +18,8 @@ import ( "github.com/smartcontractkit/chainlink-testing-framework/k8s/environment" "github.com/smartcontractkit/chainlink-testing-framework/k8s/pkg/helm/chainlink" "github.com/smartcontractkit/chainlink-testing-framework/k8s/pkg/helm/ethereum" + "github.com/smartcontractkit/chainlink-testing-framework/k8s/pkg/helm/mockserver" + mockservercfg "github.com/smartcontractkit/chainlink-testing-framework/k8s/pkg/helm/mockserver-cfg" "github.com/smartcontractkit/chainlink-testing-framework/k8s/presets" "github.com/smartcontractkit/chainlink-testing-framework/logging" "github.com/smartcontractkit/chainlink-testing-framework/utils/ptr" @@ -446,3 +448,23 @@ func TestRunTimeout(t *testing.T) { err = e.Run() require.Error(t, err) } + +func TestReallyLongLogs(t *testing.T) { + t.Parallel() + l := logging.GetTestLogger(t) + testEnvConfig := GetTestEnvConfig(t) + env := environment.New(testEnvConfig). + AddHelm(mockservercfg.New(nil)). + AddHelm(mockserver.New(nil)) + err := env.Run() + require.NoError(t, err) + if env.WillUseRemoteRunner() { + return + } + s := "" + for i := 0; i < 1000; i++ { + s = fmt.Sprintf("%s%s", s, "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") + l.Info().Int("count", len(s)).Msg("total characters") + l.Info().Str("string", s).Msg("string") + } +} diff --git a/k8s/e2e/local-runner/envs_test.go b/k8s/e2e/local-runner/envs_test.go index 608602859..9a1b4542d 100644 --- a/k8s/e2e/local-runner/envs_test.go +++ b/k8s/e2e/local-runner/envs_test.go @@ -3,71 +3,74 @@ package env_test import ( "testing" - "github.com/smartcontractkit/chainlink-testing-framework/k8s/config" "github.com/smartcontractkit/chainlink-testing-framework/k8s/e2e/common" ) -func TestMultiStageMultiManifestConnection(t *testing.T) { - common.TestMultiStageMultiManifestConnection(t) -} +// func TestMultiStageMultiManifestConnection(t *testing.T) { +// common.TestMultiStageMultiManifestConnection(t) +// } -func TestConnectWithoutManifest(t *testing.T) { - common.TestConnectWithoutManifest(t) -} +// func TestConnectWithoutManifest(t *testing.T) { +// common.TestConnectWithoutManifest(t) +// } -func Test5NodesSoakEnvironmentWithPVCs(t *testing.T) { - common.Test5NodesSoakEnvironmentWithPVCs(t) -} +// func Test5NodesSoakEnvironmentWithPVCs(t *testing.T) { +// common.Test5NodesSoakEnvironmentWithPVCs(t) +// } -func TestWithSingleNodeEnv(t *testing.T) { - common.TestWithSingleNodeEnvParallel(t) -} +// func TestWithSingleNodeEnv(t *testing.T) { +// common.TestWithSingleNodeEnvParallel(t) +// } -func TestWithSingleNodeEnvLocalCharts(t *testing.T) { - t.Setenv(config.EnvVarLocalCharts, "true") - common.TestWithSingleNodeEnv(t) -} +// func TestWithSingleNodeEnvLocalCharts(t *testing.T) { +// t.Setenv(config.EnvVarLocalCharts, "true") +// common.TestWithSingleNodeEnv(t) +// } -func TestMultipleNodeWithDiffDBVersionEnv(t *testing.T) { - common.TestMultipleNodeWithDiffDBVersionEnv(t) -} +// func TestMultipleNodeWithDiffDBVersionEnv(t *testing.T) { +// common.TestMultipleNodeWithDiffDBVersionEnv(t) +// } -func TestMinResources5NodesEnv(t *testing.T) { - common.TestMinResources5NodesEnv(t) -} +// func TestMinResources5NodesEnv(t *testing.T) { +// common.TestMinResources5NodesEnv(t) +// } -func TestMinResources5NodesEnvWithBlockscout(t *testing.T) { - common.TestMinResources5NodesEnvWithBlockscout(t) -} +// func TestMinResources5NodesEnvWithBlockscout(t *testing.T) { +// common.TestMinResources5NodesEnvWithBlockscout(t) +// } -func TestMultipleInstancesOfTheSameType(t *testing.T) { - common.TestMultipleInstancesOfTheSameType(t) -} +// func TestMultipleInstancesOfTheSameType(t *testing.T) { +// common.TestMultipleInstancesOfTheSameType(t) +// } -func Test5NodesPlus2MiningGethsReorgEnv(t *testing.T) { - common.Test5NodesPlus2MiningGethsReorgEnv(t) -} +// func Test5NodesPlus2MiningGethsReorgEnv(t *testing.T) { +// common.Test5NodesPlus2MiningGethsReorgEnv(t) +// } -func TestWithChaos(t *testing.T) { - common.TestWithChaos(t) -} +// func TestWithChaos(t *testing.T) { +// common.TestWithChaos(t) +// } -func TestEmptyEnvironmentStartup(t *testing.T) { - common.TestEmptyEnvironmentStartup(t) -} +// func TestEmptyEnvironmentStartup(t *testing.T) { +// common.TestEmptyEnvironmentStartup(t) +// } -func TestRolloutRestartUpdate(t *testing.T) { - common.TestRolloutRestart(t, true) -} +// func TestRolloutRestartUpdate(t *testing.T) { +// common.TestRolloutRestart(t, true) +// } -func TestRolloutRestartBySelector(t *testing.T) { - common.TestRolloutRestart(t, false) -} +// func TestRolloutRestartBySelector(t *testing.T) { +// common.TestRolloutRestart(t, false) +// } -func TestReplaceHelm(t *testing.T) { - common.TestReplaceHelm(t) -} +// func TestReplaceHelm(t *testing.T) { +// common.TestReplaceHelm(t) +// } + +// func TestRunTimeout(t *testing.T) { +// common.TestRunTimeout(t) +// } -func TestRunTimeout(t *testing.T) { - common.TestRunTimeout(t) +func TestReallyLongLogs(t *testing.T) { + common.TestReallyLongLogs(t) } diff --git a/k8s/e2e/remote-runner/remote_runner_envs_test.go b/k8s/e2e/remote-runner/remote_runner_envs_test.go index f0bb07b39..fcb52af97 100644 --- a/k8s/e2e/remote-runner/remote_runner_envs_test.go +++ b/k8s/e2e/remote-runner/remote_runner_envs_test.go @@ -1,165 +1,155 @@ package e2e_remote_runner_test import ( - "fmt" "testing" - "time" - "github.com/go-resty/resty/v2" - "github.com/rs/zerolog/log" - "github.com/stretchr/testify/assert" - "github.com/stretchr/testify/require" - - "github.com/smartcontractkit/chainlink-testing-framework/k8s/config" "github.com/smartcontractkit/chainlink-testing-framework/k8s/e2e/common" - "github.com/smartcontractkit/chainlink-testing-framework/k8s/environment" - "github.com/smartcontractkit/chainlink-testing-framework/k8s/pkg/helm/chainlink" - "github.com/smartcontractkit/chainlink-testing-framework/k8s/pkg/helm/ethereum" - "github.com/smartcontractkit/chainlink-testing-framework/k8s/pkg/helm/mockserver" - mockservercfg "github.com/smartcontractkit/chainlink-testing-framework/k8s/pkg/helm/mockserver-cfg" - "github.com/smartcontractkit/chainlink-testing-framework/k8s/presets" ) -func TestMultiStageMultiManifestConnection(t *testing.T) { - common.TestMultiStageMultiManifestConnection(t) -} - -func TestConnectWithoutManifest(t *testing.T) { - common.TestConnectWithoutManifest(t) -} - -func Test5NodesSoakEnvironmentWithPVCs(t *testing.T) { - common.Test5NodesSoakEnvironmentWithPVCs(t) -} - -func TestWithSingleNodeEnv(t *testing.T) { - common.TestWithSingleNodeEnvParallel(t) -} - -func TestWithSingleNodeEnvLocalCharts(t *testing.T) { - t.Setenv(config.EnvVarLocalCharts, "true") - common.TestWithSingleNodeEnv(t) -} - -func TestMultipleNodeWithDiffDBVersionEnv(t *testing.T) { - common.TestMultipleNodeWithDiffDBVersionEnv(t) -} - -func TestMinResources5NodesEnv(t *testing.T) { - common.TestMinResources5NodesEnv(t) -} - -func TestMinResources5NodesEnvWithBlockscout(t *testing.T) { - common.TestMinResources5NodesEnvWithBlockscout(t) -} - -func TestMultipleInstancesOfTheSameType(t *testing.T) { - common.TestMultipleInstancesOfTheSameType(t) -} - -func Test5NodesPlus2MiningGethsReorgEnv(t *testing.T) { - common.Test5NodesPlus2MiningGethsReorgEnv(t) -} - -func TestWithChaos(t *testing.T) { - common.TestWithChaos(t) -} - -func TestFundReturnShutdownLogic(t *testing.T) { - t.Parallel() - testEnvConfig := common.GetTestEnvConfig(t) - e := presets.EVMMinimalLocal(testEnvConfig) - err := e.Run() - if e.WillUseRemoteRunner() { - require.Error(t, err, "Should return an error") - return - } - t.Cleanup(func() { - assert.NoError(t, e.Shutdown()) - }) - require.NoError(t, err) - fmt.Println(environment.FAILED_FUND_RETURN) -} - -func TestRemoteRunnerOneSetupWithMultipeTests(t *testing.T) { - t.Parallel() - testEnvConfig := common.GetTestEnvConfig(t) - ethChart := ethereum.New(nil) - e := environment.New(testEnvConfig). - AddHelm(mockservercfg.New(nil)). - AddHelm(mockserver.New(nil)). - AddHelm(ethChart). - AddHelm(chainlink.New(0, map[string]any{ - "replicas": 5, - "toml": presets.BaseToml, - })) - err := e.Run() - t.Cleanup(func() { - assert.NoError(t, e.Shutdown()) - }) - require.NoError(t, err) - if e.WillUseRemoteRunner() { - return - } - - // setup of variables to use for verification in a t.Run - ethNetworkName := ethChart.GetProps().(*ethereum.Props).NetworkName - urls := make([]string, 0) - if e.Cfg.InsideK8s { - urls = append(urls, e.URLs[chainlink.NodesInternalURLsKey]...) - urls = append(urls, e.URLs[ethNetworkName+"_internal_http"]...) - } else { - urls = append(urls, e.URLs[chainlink.NodesLocalURLsKey]...) - urls = append(urls, e.URLs[ethNetworkName+"_http"]...) - } - - log.Info().Str("Test", "Before").Msg("Before Tests") - - // This test will verify we can connect a t.Run to the env of the parent test - t.Run("do one", func(t1 *testing.T) { - t1.Parallel() - test1EnvConfig := common.GetTestEnvConfig(t1) - test1EnvConfig.Namespace = e.Cfg.Namespace - test1EnvConfig.NoManifestUpdate = true - e1 := presets.EVMMinimalLocal(test1EnvConfig) - err := e1.Run() - require.NoError(t1, err) - log.Info().Str("Test", "One").Msg("Inside test") - time.Sleep(1 * time.Second) - }) - - // This test will verify the sub t.Run properly uses the variables from the parent test - t.Run("do two", func(t2 *testing.T) { - t2.Parallel() - log.Info().Str("Test", "Two").Msg("Inside test") - r := resty.New() - for _, u := range urls { - log.Info().Str("URL", u).Send() - res, err := r.R().Get(u) - require.NoError(t2, err) - require.Equal(t2, "200 OK", res.Status()) - } - }) - - log.Info().Str("Test", "After").Msg("After Tests") -} - -func TestEmptyEnvironmentStartup(t *testing.T) { - common.TestEmptyEnvironmentStartup(t) -} - -func TestRolloutRestartUpdate(t *testing.T) { - common.TestRolloutRestart(t, true) -} - -func TestRolloutRestartBySelector(t *testing.T) { - common.TestRolloutRestart(t, false) -} - -func TestReplaceHelm(t *testing.T) { - common.TestReplaceHelm(t) -} - -func TestRunTimeout(t *testing.T) { - common.TestRunTimeout(t) +// func TestMultiStageMultiManifestConnection(t *testing.T) { +// common.TestMultiStageMultiManifestConnection(t) +// } + +// func TestConnectWithoutManifest(t *testing.T) { +// common.TestConnectWithoutManifest(t) +// } + +// func Test5NodesSoakEnvironmentWithPVCs(t *testing.T) { +// common.Test5NodesSoakEnvironmentWithPVCs(t) +// } + +// func TestWithSingleNodeEnv(t *testing.T) { +// common.TestWithSingleNodeEnvParallel(t) +// } + +// func TestWithSingleNodeEnvLocalCharts(t *testing.T) { +// t.Setenv(config.EnvVarLocalCharts, "true") +// common.TestWithSingleNodeEnv(t) +// } + +// func TestMultipleNodeWithDiffDBVersionEnv(t *testing.T) { +// common.TestMultipleNodeWithDiffDBVersionEnv(t) +// } + +// func TestMinResources5NodesEnv(t *testing.T) { +// common.TestMinResources5NodesEnv(t) +// } + +// func TestMinResources5NodesEnvWithBlockscout(t *testing.T) { +// common.TestMinResources5NodesEnvWithBlockscout(t) +// } + +// func TestMultipleInstancesOfTheSameType(t *testing.T) { +// common.TestMultipleInstancesOfTheSameType(t) +// } + +// func Test5NodesPlus2MiningGethsReorgEnv(t *testing.T) { +// common.Test5NodesPlus2MiningGethsReorgEnv(t) +// } + +// func TestWithChaos(t *testing.T) { +// common.TestWithChaos(t) +// } + +// func TestFundReturnShutdownLogic(t *testing.T) { +// t.Parallel() +// testEnvConfig := common.GetTestEnvConfig(t) +// e := presets.EVMMinimalLocal(testEnvConfig) +// err := e.Run() +// if e.WillUseRemoteRunner() { +// require.Error(t, err, "Should return an error") +// return +// } +// t.Cleanup(func() { +// assert.NoError(t, e.Shutdown()) +// }) +// require.NoError(t, err) +// fmt.Println(environment.FAILED_FUND_RETURN) +// } + +// func TestRemoteRunnerOneSetupWithMultipeTests(t *testing.T) { +// t.Parallel() +// testEnvConfig := common.GetTestEnvConfig(t) +// ethChart := ethereum.New(nil) +// e := environment.New(testEnvConfig). +// AddHelm(mockservercfg.New(nil)). +// AddHelm(mockserver.New(nil)). +// AddHelm(ethChart). +// AddHelm(chainlink.New(0, map[string]any{ +// "replicas": 5, +// "toml": presets.BaseToml, +// })) +// err := e.Run() +// t.Cleanup(func() { +// assert.NoError(t, e.Shutdown()) +// }) +// require.NoError(t, err) +// if e.WillUseRemoteRunner() { +// return +// } + +// // setup of variables to use for verification in a t.Run +// ethNetworkName := ethChart.GetProps().(*ethereum.Props).NetworkName +// urls := make([]string, 0) +// if e.Cfg.InsideK8s { +// urls = append(urls, e.URLs[chainlink.NodesInternalURLsKey]...) +// urls = append(urls, e.URLs[ethNetworkName+"_internal_http"]...) +// } else { +// urls = append(urls, e.URLs[chainlink.NodesLocalURLsKey]...) +// urls = append(urls, e.URLs[ethNetworkName+"_http"]...) +// } + +// log.Info().Str("Test", "Before").Msg("Before Tests") + +// // This test will verify we can connect a t.Run to the env of the parent test +// t.Run("do one", func(t1 *testing.T) { +// t1.Parallel() +// test1EnvConfig := common.GetTestEnvConfig(t1) +// test1EnvConfig.Namespace = e.Cfg.Namespace +// test1EnvConfig.NoManifestUpdate = true +// e1 := presets.EVMMinimalLocal(test1EnvConfig) +// err := e1.Run() +// require.NoError(t1, err) +// log.Info().Str("Test", "One").Msg("Inside test") +// time.Sleep(1 * time.Second) +// }) + +// // This test will verify the sub t.Run properly uses the variables from the parent test +// t.Run("do two", func(t2 *testing.T) { +// t2.Parallel() +// log.Info().Str("Test", "Two").Msg("Inside test") +// r := resty.New() +// for _, u := range urls { +// log.Info().Str("URL", u).Send() +// res, err := r.R().Get(u) +// require.NoError(t2, err) +// require.Equal(t2, "200 OK", res.Status()) +// } +// }) + +// log.Info().Str("Test", "After").Msg("After Tests") +// } + +// func TestEmptyEnvironmentStartup(t *testing.T) { +// common.TestEmptyEnvironmentStartup(t) +// } + +// func TestRolloutRestartUpdate(t *testing.T) { +// common.TestRolloutRestart(t, true) +// } + +// func TestRolloutRestartBySelector(t *testing.T) { +// common.TestRolloutRestart(t, false) +// } + +// func TestReplaceHelm(t *testing.T) { +// common.TestReplaceHelm(t) +// } + +// func TestRunTimeout(t *testing.T) { +// common.TestRunTimeout(t) +// } + +func TestReallyLongLogs(t *testing.T) { + common.TestReallyLongLogs(t) }