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

Add parameter allows Docker Setup without cleanup in special cases #903

Closed
anhductn2001 opened this issue Dec 13, 2023 · 5 comments · Fixed by #905
Closed

Add parameter allows Docker Setup without cleanup in special cases #903

anhductn2001 opened this issue Dec 13, 2023 · 5 comments · Fixed by #905

Comments

@anhductn2001
Copy link
Contributor

anhductn2001 commented Dec 13, 2023

For example, in this case of ibc-go, we want to run e2e in each suite using only 1 container chain and relayer from start to finish.

Func Suggestion:

func DockerSetup(t DockerSetupTestingT, cleanUp bool) (*client.Client, string) {
	t.Helper()
	cli, err := client.NewClientWithOpts(client.FromEnv)
	if err != nil {
		panic(fmt.Errorf("failed to create docker client: %v", err))
	}
        if cleanUp {
		// Clean up docker resources at end of test.
	        t.Cleanup(dockerCleanup(t, cli))

	        // Also eagerly clean up any leftover resources from a previous test run,
	        // e.g. if the test was interrupted.
	        dockerCleanup(t, cli)()
	}

	name := fmt.Sprintf("interchaintest-%s", RandLowerCaseLetterString(8))
	network, err := cli.NetworkCreate(context.TODO(), name, types.NetworkCreate{
		CheckDuplicate: true,
		Labels: map[string]string{CleanupLabel: t.Name()},
	})
	if err != nil {
		panic(fmt.Errorf("failed to create docker network: %v", err))
	}
	return cli, network.ID
}
@Reecepbcups
Copy link
Member

Our env options can be found here. This includes a KEEP_CONTAINERS=true to keep the containers alive and prevent testnet cleanup after completion.

Does this fit your need?

@anhductn2001
Copy link
Contributor Author

I will try it, is there any example of its usage?

@anhductn2001
Copy link
Contributor Author

OMG! I'm sure it's not working yet, we have a typo here.

@Reecepbcups
Copy link
Member

Good catch, will get a fix in for this now.

KEEP_CONTAINTERS=true will work for now then

@anhductn2001
Copy link
Contributor Author

Thanks @Reecepbcups

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 a pull request may close this issue.

2 participants