From 98f67555d1ec65da83ada9e83d508a6c6dc9fc48 Mon Sep 17 00:00:00 2001 From: dhrubabasu <7675102+dhrubabasu@users.noreply.github.com> Date: Mon, 16 May 2022 21:04:06 -0400 Subject: [PATCH] nits --- scripts/run.sh | 4 +- tests/e2e/e2e_test.go | 94 ++++++++++++++++--------------------------- 2 files changed, 38 insertions(+), 60 deletions(-) diff --git a/scripts/run.sh b/scripts/run.sh index f50981f7..e29f90ea 100755 --- a/scripts/run.sh +++ b/scripts/run.sh @@ -119,7 +119,9 @@ PID=${!} echo "running e2e tests" ./tests/e2e/e2e.test \ --ginkgo.v \ ---log-level debug || EXIT_CODE=$? +--log-level debug \ +--network-runner-avalanchego-path=${AVALANCHEGO_PATH} \ +--network-runner-avalanchego-log-level=${AVALANCHE_LOG_LEVEL} || EXIT_CODE=$? # "e2e.test" already terminates the cluster # just in case tests are aborted, manually terminate them again diff --git a/tests/e2e/e2e_test.go b/tests/e2e/e2e_test.go index bd34dfd8..c2eac670 100644 --- a/tests/e2e/e2e_test.go +++ b/tests/e2e/e2e_test.go @@ -6,8 +6,6 @@ package e2e_test import ( "context" "flag" - "os" - "strings" "testing" "time" @@ -17,6 +15,9 @@ import ( ginkgo "github.com/onsi/ginkgo/v2" "github.com/onsi/gomega" + + // ensure test packages are scanned by ginkgo + _ "github.com/ava-labs/avalanche-rosetta/tests/e2e/transfer" ) func TestE2E(t *testing.T) { @@ -34,8 +35,6 @@ var ( uris string ) -// TODO: support existing keys - func init() { flag.StringVar( &logLevel, @@ -43,13 +42,6 @@ func init() { "info", "log level", ) - - flag.StringVar( - &networkRunnerGRPCEp, - "network-runner-grpc-endpoint", - "", - "[optional] gRPC server endpoint for network-runner (only required for local network-runner tests)", - ) flag.StringVar( &networkRunnerAvalancheGoExecPath, "network-runner-avalanchego-path", @@ -65,58 +57,42 @@ func init() { } var _ = ginkgo.BeforeSuite(func() { - if networkRunnerAvalancheGoExecPath != "" { - _, err := os.Stat(networkRunnerAvalancheGoExecPath) - gomega.Expect(err).Should(gomega.BeNil()) - } - - // run with local network-runner - if networkRunnerGRPCEp != "" { - gomega.Expect(uris).Should(gomega.BeEmpty()) - - runnerCli, err := e2e.SetRunnerClient(logLevel, networkRunnerGRPCEp) - gomega.Expect(err).Should(gomega.BeNil()) - - ctx, cancel := context.WithTimeout(context.Background(), 15*time.Second) - presp, err := runnerCli.Ping(ctx) - cancel() - gomega.Expect(err).Should(gomega.BeNil()) - tests.Outf("{{green}}network-runner running in PID %d{{/}}\n", presp.Pid) - - tests.Outf("{{magenta}}starting network-runner with %q{{/}}\n", networkRunnerAvalancheGoExecPath) - ctx, cancel = context.WithTimeout(context.Background(), 15*time.Second) - resp, err := runnerCli.Start(ctx, networkRunnerAvalancheGoExecPath, - runner_sdk.WithNumNodes(5), - runner_sdk.WithLogLevel(networkRunnerAvalancheGoLogLevel), - ) - cancel() - gomega.Expect(err).Should(gomega.BeNil()) - tests.Outf("{{green}}successfully started network-runner :{{/}} %+v\n", resp.ClusterInfo.NodeNames) - - // start is async, so wait some time for cluster health - time.Sleep(time.Minute) + gomega.Expect(uris).Should(gomega.BeEmpty()) + + runnerCli, err := e2e.SetRunnerClient(logLevel, networkRunnerGRPCEp) + gomega.Expect(err).Should(gomega.BeNil()) + + ctx, cancel := context.WithTimeout(context.Background(), 15*time.Second) + presp, err := runnerCli.Ping(ctx) + cancel() + gomega.Expect(err).Should(gomega.BeNil()) + tests.Outf("{{green}}network-runner running in PID %d{{/}}\n", presp.Pid) + + tests.Outf("{{magenta}}starting network-runner with %q{{/}}\n", networkRunnerAvalancheGoExecPath) + ctx, cancel = context.WithTimeout(context.Background(), 15*time.Second) + resp, err := runnerCli.Start(ctx, networkRunnerAvalancheGoExecPath, + runner_sdk.WithNumNodes(5), + runner_sdk.WithLogLevel(networkRunnerAvalancheGoLogLevel), + ) + cancel() + gomega.Expect(err).Should(gomega.BeNil()) + tests.Outf("{{green}}successfully started network-runner :{{/}} %+v\n", resp.ClusterInfo.NodeNames) - ctx, cancel = context.WithTimeout(context.Background(), 2*time.Minute) - _, err = runnerCli.Health(ctx) - cancel() - gomega.Expect(err).Should(gomega.BeNil()) + // start is async, so wait some time for cluster health + time.Sleep(time.Minute) - var uriSlice []string - ctx, cancel = context.WithTimeout(context.Background(), 2*time.Minute) - uriSlice, err = runnerCli.URIs(ctx) - cancel() - gomega.Expect(err).Should(gomega.BeNil()) - e2e.SetURIs(uriSlice) - } + ctx, cancel = context.WithTimeout(context.Background(), 2*time.Minute) + _, err = runnerCli.Health(ctx) + cancel() + gomega.Expect(err).Should(gomega.BeNil()) - // connect directly to existing cluster - if uris != "" { - gomega.Expect(networkRunnerGRPCEp).Should(gomega.BeEmpty()) + var uriSlice []string + ctx, cancel = context.WithTimeout(context.Background(), 2*time.Minute) + uriSlice, err = runnerCli.URIs(ctx) + cancel() + gomega.Expect(err).Should(gomega.BeNil()) + e2e.SetURIs(uriSlice) - uriSlice := strings.Split(uris, ",") - e2e.SetURIs(uriSlice) - } - uriSlice := e2e.GetURIs() tests.Outf("{{green}}URIs:{{/}} %q\n", uriSlice) })