From 5cc5088993f514c1f71eb1e45e4c97bac13c3fc0 Mon Sep 17 00:00:00 2001 From: Sergey Kudasov Date: Tue, 15 Aug 2023 01:56:24 +0300 Subject: [PATCH] TT-472 migration docker tests (#10199) --- .../migration/upgrade_version_test.go | 79 +++++-------------- 1 file changed, 19 insertions(+), 60 deletions(-) diff --git a/integration-tests/migration/upgrade_version_test.go b/integration-tests/migration/upgrade_version_test.go index b9c3ff01756..1f90bd123eb 100644 --- a/integration-tests/migration/upgrade_version_test.go +++ b/integration-tests/migration/upgrade_version_test.go @@ -1,78 +1,37 @@ package migration import ( - "fmt" - "strings" "testing" - "github.com/stretchr/testify/require" - "go.uber.org/zap/zapcore" - - "github.com/smartcontractkit/chainlink-env/environment" - "github.com/smartcontractkit/chainlink-env/pkg/helm/chainlink" - "github.com/smartcontractkit/chainlink-env/pkg/helm/ethereum" - "github.com/smartcontractkit/chainlink-testing-framework/blockchain" "github.com/smartcontractkit/chainlink-testing-framework/utils" + "github.com/stretchr/testify/require" - "github.com/smartcontractkit/chainlink/integration-tests/actions" - "github.com/smartcontractkit/chainlink/integration-tests/client" - "github.com/smartcontractkit/chainlink/integration-tests/config" - "github.com/smartcontractkit/chainlink/integration-tests/networks" + "github.com/smartcontractkit/chainlink/integration-tests/docker/test_env" + "os" ) func TestVersionUpgrade(t *testing.T) { t.Parallel() - testEnvironment, testNetwork := setupUpgradeTest(t) - if testEnvironment.WillUseRemoteRunner() { - return - } + env, err := test_env.NewCLTestEnvBuilder(). + WithGeth(). + WithCLNodes(1). + Build() + require.NoError(t, err) upgradeImage, err := utils.GetEnv("UPGRADE_IMAGE") require.NoError(t, err, "Error getting upgrade image") upgradeVersion, err := utils.GetEnv("UPGRADE_VERSION") require.NoError(t, err, "Error getting upgrade version") - chainClient, err := blockchain.NewEVMClient(testNetwork, testEnvironment) - require.NoError(t, err, "Connecting to blockchain nodes shouldn't fail") - chainlinkNodes, err := client.ConnectChainlinkNodes(testEnvironment) - require.NoError(t, err, "Connecting to chainlink nodes shouldn't fail") - - t.Cleanup(func() { - err := actions.TeardownSuite(t, testEnvironment, utils.ProjectRoot, chainlinkNodes, nil, zapcore.ErrorLevel, chainClient) - require.NoError(t, err, "Error tearing down environment") - }) - - err = actions.UpgradeChainlinkNodeVersions(testEnvironment, upgradeImage, upgradeVersion, chainlinkNodes[0]) - require.NoError(t, err, "Upgrading chainlink nodes shouldn't fail") -} - -func setupUpgradeTest(t *testing.T) ( - testEnvironment *environment.Environment, - testNetwork blockchain.EVMNetwork, -) { - testNetwork = networks.SelectedNetwork - evmConfig := ethereum.New(nil) - if !testNetwork.Simulated { - evmConfig = ethereum.New(ðereum.Props{ - NetworkName: testNetwork.Name, - Simulated: testNetwork.Simulated, - WsURLs: testNetwork.URLs, - }) - } - charts, err := chainlink.NewDeployment(1, map[string]any{ - "toml": client.AddNetworksConfig(config.BaseOCRP2PV1Config, testNetwork), - "db": map[string]any{ - "stateful": true, - }, - }) - require.NoError(t, err, "Error creating chainlink deployments") - testEnvironment = environment.New(&environment.Config{ - NamespacePrefix: fmt.Sprintf("upgrade-version-%s", strings.ReplaceAll(strings.ToLower(testNetwork.Name), " ", "-")), - Test: t, - }). - AddHelm(evmConfig). - AddHelmCharts(charts) - err = testEnvironment.Run() - require.NoError(t, err, "Error launching test environment") - return testEnvironment, testNetwork + _ = os.Setenv("CHAINLINK_IMAGE", upgradeImage) + _ = os.Setenv("CHAINLINK_VERSION", upgradeVersion) + + // just restarting CL container with the same name, DB is still the same + // + // [Database] + // MigrateOnStartup = true + // + // by default + err = env.CLNodes[0].Restart(env.CLNodes[0].NodeConfig) + require.NoError(t, err) }