-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
TT-472 migration docker tests (#10199)
- Loading branch information
Showing
1 changed file
with
19 additions
and
60 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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) | ||
} |