Skip to content

Commit

Permalink
Be able to run individual e2e tests in Intellij (googleforgames#1506)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
markmandel authored and ilkercelikyilmaz committed Oct 23, 2020
1 parent a85102f commit aad9d70
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 0 deletions.
6 changes: 6 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 5 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -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=
Expand Down
30 changes: 30 additions & 0 deletions test/e2e/framework/framework.go
Original file line number Diff line number Diff line change
Expand Up @@ -144,15 +144,21 @@ 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], "___") {
logrus.Info("Running test via Intellij. Skipping Test Flag Parsing")
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.") {
Expand All @@ -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
Expand Down Expand Up @@ -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
}
Expand Down Expand Up @@ -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
}

Expand Down

0 comments on commit aad9d70

Please sign in to comment.