Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ccip-4333 Handle all test setups with unified interface for memory and docker tests #15581

Merged
merged 17 commits into from
Dec 10, 2024

Conversation

AnieeG
Copy link
Contributor

@AnieeG AnieeG commented Dec 9, 2024

This introduces a common interface for TestEnvironment and standardizes NewEnvironment creation by taking TestEnvironment as parameter.
Reduces the need of creating separate set up code for memory and docker environment from integration tests. Both kind of environments can now be constructed from NewIntegrationEnvironment by passing applicable TestOps - WithEnvironmentType(memory/docker)

I followed this -
If called from chainlink/deployments - Use NewMemoryEnvironment with TestOps to create test environments.
If called from chainlink/integration-tests - Use NewIntegrationEnvironment with TestOps . NewIntegrationEnvironment is capable of creating memory and docker both based on provided EnvironmentType

@AnieeG AnieeG requested review from a team as code owners December 9, 2024 22:42
Copy link
Contributor

github-actions bot commented Dec 9, 2024

Flakeguard Summary

Setting Value
Project github.com/smartcontractkit/chainlink/deployment/deployment
Max Pass Ratio 100.00%
Test Run Count 3
Race Detection false
Excluded Tests TestAddLane

Found Flaky Tests ❌

Category Total
Tests 15
Panicked Tests 0
Raced Tests 0
Flaky Tests 8
Flaky Test Ratio 53.33%
Runs 42
Passes 18
Failures 24
Skips 3
Pass Ratio 42.85%
Name Pass Ratio Panicked? Timed Out? Race? Runs Successes Failures Skips Package Package Panicked? Avg Duration Code Owners
TestAddChainInbound 0.00% false false false 3 0 3 0 github.com/smartcontractkit/chainlink/deployment/ccip/changeset false 86.666666ms Unknown
TestDeployCCIPContracts 0.00% false false false 3 0 3 0 github.com/smartcontractkit/chainlink/deployment/ccip/changeset false 46.666666ms Unknown
TestSmokeState 0.00% false false false 3 0 3 0 github.com/smartcontractkit/chainlink/deployment/ccip/changeset false 66.666666ms Unknown
TestSmokeView 0.00% false false false 3 0 3 0 github.com/smartcontractkit/chainlink/deployment/ccip/changeset false 63.333333ms Unknown
TestUpdateRMNConfig 0.00% false false false 3 0 3 0 github.com/smartcontractkit/chainlink/deployment/ccip/changeset false 126.666666ms Unknown
TestUpdateRMNConfig/with_MCMS 0.00% false false false 3 0 3 0 github.com/smartcontractkit/chainlink/deployment/ccip/changeset false 73.333333ms Unknown
TestUpdateRMNConfig/without_MCMS 0.00% false false false 3 0 3 0 github.com/smartcontractkit/chainlink/deployment/ccip/changeset false 46.666666ms Unknown
Test_NewAcceptOwnershipChangeset 0.00% false false false 3 0 3 0 github.com/smartcontractkit/chainlink/deployment/ccip/changeset false 50ms Unknown

Copy link
Contributor

github-actions bot commented Dec 9, 2024

Flakeguard Summary

Setting Value
Project github.com/smartcontractkit/chainlink/deployment/deployment
Max Pass Ratio 100.00%
Test Run Count 3
Race Detection false
Excluded Tests TestAddLane

Found Flaky Tests ❌

Category Total
Tests 1
Panicked Tests 1
Raced Tests 0
Flaky Tests 1
Flaky Test Ratio 100.00%
Runs 3
Passes 0
Failures 3
Skips 0
Pass Ratio 0.00%
Name Pass Ratio Panicked? Timed Out? Race? Runs Successes Failures Skips Package Package Panicked? Avg Duration Code Owners
Test_NewAcceptOwnershipChangeset 0.00% true false false 3 0 3 0 github.com/smartcontractkit/chainlink/deployment/ccip/changeset true 0s Unknown

Copy link
Contributor

github-actions bot commented Dec 9, 2024

AER Report: CI Core ran successfully ✅

aer_workflow , commit

AER Report: Operator UI CI ran successfully ✅

aer_workflow , commit

@AnieeG AnieeG requested a review from a team as a code owner December 10, 2024 00:18
@@ -805,35 +566,6 @@ func ConfirmRequestOnSourceAndDest(t *testing.T, env deployment.Environment, sta
return nil
}

// TODO: Remove this to replace with ApplyChangeset
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

unused func

tenv, _ := testsetups.NewIntegrationEnvironment(
t,
changeset.WithMultiCall3(),
changeset.WithEnvironmentType(changeset.Memory),
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder whether that should be driven by the code or some sort of env variable. I think all of the tests using testsetups.NewIntegrationEnvironment should be executable with both inmem and docker env. That way, you don't need to recompile everything to switch the env. I can imagine sth like this (don't focus on the names or the impl details, it's to show the high level ideas)

func Test_Sth(t *testing.T) {
	tenv, _ := testsetups.NewIntegrationEnvironment(
		t,
		changeset.WithMultiCall3(),
		changeset.WithEnvironmentType(changeset.EnvDriven) // probably needs a better name
}


func NewIntegrationEnvironment(t *testing.T, opts ...changeset.TestOps) {
       // ...
       if testCfg.Type == changeset.EnvDriven {
             envType := os.Getenv("CCIP_INT_TESTS_ENV")
             if envType == "docker"{
                  return docker
             } else { // default to inmem
                  return inmem 
             }
      }

Copy link
Collaborator

@mateusz-sekara mateusz-sekara Dec 10, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That enables a couple of nice things:

  • fast tests on the CI checks, but we can run everything in docker upon merge to main (it requires only a different ENV variable in CI configuration)
  • doesn't require re-compilation if you want to debug locally using inmem instead of the docker hardcoded

I can imagine the CI setup in which in-memory tests run always (every PR, merge queue, etc), for both repositories: chainlink, chainlink-ccip. However, additionally we can have some sanity nightly runs using docker being reported to our channel (or maybe after merge to main)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's stops us from doing something like this in the tests:

func Test_Something(t *testing.T) {
  tenv, _ := testsetups.NewIntegrationEnvironment(
		t,
		changeset.WithMultiCall3(),
                 changeset.WithEnvironmentType(testhelpers.MustGetEnvTypeOrDefault(t)),
  )
  // .. rest of test code
}

// in package testhelpers
func MustGetEnvTypeOrDefault(t *testing.T) EnvType {
  envType := os.Getenv("CCIP_V16_TEST_ENV")
  if envType == "" || envType == "in-memory" {
    return EnvTypeMemory
  } else if envType == "docker" {
    return EnvTypeDocker
  }
  
  t.Fatalf("env var CCIP_V16_TEST_ENV must be either 'in-memory' or 'docker', defaults to 'in-memory' if unset, got: %s", envType)
}

@@ -59,6 +60,16 @@ type CCIPOCRParams struct {
ExecuteOffChainConfig pluginconfig.ExecuteOffchainConfig
}

// Override overrides non-empty dst CCIPOCRParams attributes with non-empty src CCIPOCRParams attributes values
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Idea is we will use DefaultOCRParams and only mention the non-nil param values to override from chainlink-deployments

@@ -59,6 +60,16 @@ type CCIPOCRParams struct {
ExecuteOffChainConfig pluginconfig.ExecuteOffchainConfig
}

// Override overrides non-empty dst CCIPOCRParams attributes with non-empty src CCIPOCRParams attributes values
// and returns the updated CCIPOCRParams.
func (c CCIPOCRParams) Override(overrides CCIPOCRParams) (CCIPOCRParams, error) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not particularly against this approach but we already have a paradigm (if we want to call it that) of overriding via a func(c CCIPOCRParams) CCIPOCRParams that noufel added, I think. Preferably we don't have two ways to do the same thing.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Think I prefer the approach we have now due to no new dependency and less magic / reflection, which it seems like this mergo package would be doing.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I did not know we already have one. Should I completely remove this?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh you mean the one in test config. ah I see okay cool I can remove this and make it similar to what used in test config

@AnieeG AnieeG added this pull request to the merge queue Dec 10, 2024
Merged via the queue into develop with commit 9d8d9f4 Dec 10, 2024
190 checks passed
@AnieeG AnieeG deleted the CCIP-4333-interface-test branch December 10, 2024 17:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants