From aad9d705ace059915fb102950b8303cd858575f7 Mon Sep 17 00:00:00 2001 From: Mark Mandel Date: Fri, 1 May 2020 13:56:37 -0700 Subject: [PATCH] Be able to run individual e2e tests in Intellij (#1506) Had an issue with running a single e2e test within IntelliJ, because of flag parsing. Updating the pflag library, and making a small tweak to the framework library seems to have done the trick. --- go.mod | 6 ++++++ go.sum | 5 +++++ test/e2e/framework/framework.go | 30 ++++++++++++++++++++++++++++++ 3 files changed, 41 insertions(+) diff --git a/go.mod b/go.mod index 24c717a169..b9468221ac 100644 --- a/go.mod +++ b/go.mod @@ -21,9 +21,15 @@ require ( github.com/munnerz/goautoneg v0.0.0-20120707110453-a547fc61f48d github.com/pkg/errors v0.8.1 github.com/prometheus/client_golang v0.9.2 +<<<<<<< HEAD github.com/sirupsen/logrus v1.4.2 github.com/spf13/pflag v1.0.5 github.com/spf13/viper v1.3.2 +======= + github.com/sirupsen/logrus v1.2.0 + github.com/spf13/pflag v1.0.5 + github.com/spf13/viper v1.3.1 +>>>>>>> 40103599 (Be able to run individual e2e tests in Intellij (#1506)) github.com/stretchr/testify v1.5.0 go.opencensus.io v0.22.3 golang.org/x/net v0.0.0-20191004110552-13f9640d40b9 diff --git a/go.sum b/go.sum index 902e523593..1929d37416 100644 --- a/go.sum +++ b/go.sum @@ -293,8 +293,13 @@ github.com/spf13/pflag v1.0.3 h1:zPAT6CGy6wXeQ7NtTnaTerfKOsV6V6F8agHXFiazDkg= github.com/spf13/pflag v1.0.3/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4= github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA= github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg= +<<<<<<< HEAD github.com/spf13/viper v1.3.2 h1:VUFqw5KcqRf7i70GOzW7N+Q7+gxVBkSSqiXB12+JQ4M= github.com/spf13/viper v1.3.2/go.mod h1:ZiWeW+zYFKm7srdB9IoDzzZXaJaI5eL9QjNiN/DMA2s= +======= +github.com/spf13/viper v1.3.1 h1:5+8j8FTpnFV4nEImW/ofkzEt8VoOiLXxdYIDsB73T38= +github.com/spf13/viper v1.3.1/go.mod h1:ZiWeW+zYFKm7srdB9IoDzzZXaJaI5eL9QjNiN/DMA2s= +>>>>>>> 40103599 (Be able to run individual e2e tests in Intellij (#1506)) github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/objx v0.1.1 h1:2vfRuCMp5sSVIDSqO8oNnWJq7mPa6KVP3iPIwFBuy8A= github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= diff --git a/test/e2e/framework/framework.go b/test/e2e/framework/framework.go index 446ed18592..13c26e9024 100644 --- a/test/e2e/framework/framework.go +++ b/test/e2e/framework/framework.go @@ -144,6 +144,9 @@ const ( // https://github.com/spf13/pflag/issues/238 func ParseTestFlags() error { <<<<<<< HEAD +<<<<<<< HEAD +======= +>>>>>>> 40103599 (Be able to run individual e2e tests in Intellij (#1506)) // if we have a "___" in the arguments path, then this is IntelliJ running the test, so ignore this, as otherwise // it breaks. if strings.Contains(os.Args[0], "___") { @@ -151,8 +154,11 @@ func ParseTestFlags() error { return nil } +<<<<<<< HEAD ======= >>>>>>> ba8cd737 (Pass FEATURE_GATES flag to e2e tests (#1445)) +======= +>>>>>>> 40103599 (Be able to run individual e2e tests in Intellij (#1506)) var testFlags []string for _, f := range os.Args[1:] { if strings.HasPrefix(f, "-test.") { @@ -164,6 +170,7 @@ func ParseTestFlags() error { // NewFromFlags sets up the testing framework with the standard command line flags. func NewFromFlags() (*Framework, error) { +<<<<<<< HEAD usr, err := user.Current() if err != nil { return nil, err @@ -201,6 +208,21 @@ func NewFromFlags() (*Framework, error) { runtime.Must(runtime.ParseFeaturesFromEnv()) framework, err := New(viper.GetString(kubeconfigFlag)) +======= + usr, _ := user.Current() + kubeconfig := flag.String("kubeconfig", filepath.Join(usr.HomeDir, "/.kube/config"), + "kube config path, e.g. $HOME/.kube/config") + gsimage := flag.String("gameserver-image", "gcr.io/agones-images/udp-server:0.18", + "gameserver image to use for those tests, gcr.io/agones-images/udp-server:0.18") + pullSecret := flag.String("pullsecret", "", + "optional secret to be used for pulling the gameserver and/or Agones SDK sidecar images") + stressTestLevel := flag.Int("stress", 0, "enable stress test at given level 0-100") + perfOutputDir := flag.String("perf-output", "", "write performance statistics to the specified directory") + version := flag.String("version", "", "agones controller version to be tested, consists of release version plus a short hash of the latest commit") + + flag.Parse() + framework, err := New(*kubeconfig) +>>>>>>> 40103599 (Be able to run individual e2e tests in Intellij (#1506)) if err != nil { return framework, err } @@ -228,6 +250,14 @@ func NewFromFlags() (*Framework, error) { framework.Version = *version >>>>>>> ba8cd737 (Pass FEATURE_GATES flag to e2e tests (#1445)) + logrus.WithField("gameServerImage", framework.GameServerImage). + WithField("pullSecret", framework.PullSecret). + WithField("stressTestLevel", framework.StressTestLevel). + WithField("perfOutputDir", framework.PerfOutputDir). + WithField("version", framework.Version). + WithField("featureGates", runtime.EncodeFeatures()). + Info("Starting e2e test(s)") + return framework, nil }