e2e_test.go 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. /*
  2. Copyright 2015 The Kubernetes Authors.
  3. Licensed under the Apache License, Version 2.0 (the "License");
  4. you may not use this file except in compliance with the License.
  5. You may obtain a copy of the License at
  6. http://www.apache.org/licenses/LICENSE-2.0
  7. Unless required by applicable law or agreed to in writing, software
  8. distributed under the License is distributed on an "AS IS" BASIS,
  9. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  10. See the License for the specific language governing permissions and
  11. limitations under the License.
  12. */
  13. package e2e
  14. import (
  15. "flag"
  16. "fmt"
  17. "math/rand"
  18. "os"
  19. "testing"
  20. "time"
  21. // Never, ever remove the line with "/ginkgo". Without it,
  22. // the ginkgo test runner will not detect that this
  23. // directory contains a Ginkgo test suite.
  24. // See https://github.com/kubernetes/kubernetes/issues/74827
  25. // "github.com/onsi/ginkgo"
  26. "k8s.io/kubernetes/test/e2e/framework"
  27. "k8s.io/kubernetes/test/e2e/framework/config"
  28. "k8s.io/kubernetes/test/e2e/framework/testfiles"
  29. "k8s.io/kubernetes/test/e2e/generated"
  30. "k8s.io/kubernetes/test/utils/image"
  31. // test sources
  32. _ "k8s.io/kubernetes/test/e2e/apimachinery"
  33. _ "k8s.io/kubernetes/test/e2e/apps"
  34. _ "k8s.io/kubernetes/test/e2e/auth"
  35. _ "k8s.io/kubernetes/test/e2e/autoscaling"
  36. _ "k8s.io/kubernetes/test/e2e/cloud"
  37. _ "k8s.io/kubernetes/test/e2e/common"
  38. _ "k8s.io/kubernetes/test/e2e/instrumentation"
  39. _ "k8s.io/kubernetes/test/e2e/kubectl"
  40. _ "k8s.io/kubernetes/test/e2e/lifecycle"
  41. _ "k8s.io/kubernetes/test/e2e/lifecycle/bootstrap"
  42. _ "k8s.io/kubernetes/test/e2e/network"
  43. _ "k8s.io/kubernetes/test/e2e/node"
  44. _ "k8s.io/kubernetes/test/e2e/scheduling"
  45. _ "k8s.io/kubernetes/test/e2e/servicecatalog"
  46. _ "k8s.io/kubernetes/test/e2e/storage"
  47. _ "k8s.io/kubernetes/test/e2e/storage/external"
  48. _ "k8s.io/kubernetes/test/e2e/ui"
  49. _ "k8s.io/kubernetes/test/e2e/windows"
  50. )
  51. var viperConfig = flag.String("viper-config", "", "The name of a viper config file (https://github.com/spf13/viper#what-is-viper). All e2e command line parameters can also be configured in such a file. May contain a path and may or may not contain the file suffix. The default is to look for an optional file with `e2e` as base name. If a file is specified explicitly, it must be present.")
  52. // handleFlags sets up all flags and parses the command line.
  53. func handleFlags() {
  54. config.CopyFlags(config.Flags, flag.CommandLine)
  55. framework.RegisterCommonFlags(flag.CommandLine)
  56. framework.RegisterClusterFlags(flag.CommandLine)
  57. flag.Parse()
  58. }
  59. func TestMain(m *testing.M) {
  60. // Register test flags, then parse flags.
  61. handleFlags()
  62. // Now that we know which Viper config (if any) was chosen,
  63. // parse it and update those options which weren't already set via command line flags
  64. // (which have higher priority).
  65. if err := viperizeFlags(*viperConfig, "e2e", flag.CommandLine); err != nil {
  66. fmt.Fprintln(os.Stderr, err)
  67. os.Exit(1)
  68. }
  69. if framework.TestContext.ListImages {
  70. for _, v := range image.GetImageConfigs() {
  71. fmt.Println(v.GetE2EImage())
  72. }
  73. os.Exit(0)
  74. }
  75. framework.AfterReadingAllFlags(&framework.TestContext)
  76. // TODO: Deprecating repo-root over time... instead just use gobindata_util.go , see #23987.
  77. // Right now it is still needed, for example by
  78. // test/e2e/framework/ingress/ingress_utils.go
  79. // for providing the optional secret.yaml file and by
  80. // test/e2e/framework/util.go for cluster/log-dump.
  81. if framework.TestContext.RepoRoot != "" {
  82. testfiles.AddFileSource(testfiles.RootFileSource{Root: framework.TestContext.RepoRoot})
  83. }
  84. // Enable bindata file lookup as fallback.
  85. testfiles.AddFileSource(testfiles.BindataFileSource{
  86. Asset: generated.Asset,
  87. AssetNames: generated.AssetNames,
  88. })
  89. rand.Seed(time.Now().UnixNano())
  90. os.Exit(m.Run())
  91. }
  92. func TestE2E(t *testing.T) {
  93. RunE2ETests(t)
  94. }