e2e.go 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. package e2e
  2. import (
  3. "testing"
  4. "github.com/onsi/ginkgo/v2"
  5. "github.com/onsi/gomega"
  6. "github.com/fatedier/frp/pkg/util/log"
  7. "github.com/fatedier/frp/test/e2e/framework"
  8. )
  9. var _ = ginkgo.SynchronizedBeforeSuite(func() []byte {
  10. setupSuite()
  11. return nil
  12. }, func(data []byte) {
  13. // Run on all Ginkgo nodes
  14. setupSuitePerGinkgoNode()
  15. })
  16. var _ = ginkgo.SynchronizedAfterSuite(func() {
  17. CleanupSuite()
  18. }, func() {
  19. AfterSuiteActions()
  20. })
  21. // RunE2ETests checks configuration parameters (specified through flags) and then runs
  22. // E2E tests using the Ginkgo runner.
  23. // If a "report directory" is specified, one or more JUnit test reports will be
  24. // generated in this directory, and cluster logs will also be saved.
  25. // This function is called on each Ginkgo node in parallel mode.
  26. func RunE2ETests(t *testing.T) {
  27. gomega.RegisterFailHandler(framework.Fail)
  28. suiteConfig, reporterConfig := ginkgo.GinkgoConfiguration()
  29. // Turn on EmitSpecProgress to get spec progress (especially on interrupt)
  30. suiteConfig.EmitSpecProgress = true
  31. // Randomize specs as well as suites
  32. suiteConfig.RandomizeAllSpecs = true
  33. log.Infof("Starting e2e run %q on Ginkgo node %d of total %d",
  34. framework.RunID, suiteConfig.ParallelProcess, suiteConfig.ParallelTotal)
  35. ginkgo.RunSpecs(t, "frp e2e suite", suiteConfig, reporterConfig)
  36. }
  37. // setupSuite is the boilerplate that can be used to setup ginkgo test suites, on the SynchronizedBeforeSuite step.
  38. // There are certain operations we only want to run once per overall test invocation
  39. // (such as deleting old namespaces, or verifying that all system pods are running.
  40. // Because of the way Ginkgo runs tests in parallel, we must use SynchronizedBeforeSuite
  41. // to ensure that these operations only run on the first parallel Ginkgo node.
  42. //
  43. // This function takes two parameters: one function which runs on only the first Ginkgo node,
  44. // returning an opaque byte array, and then a second function which runs on all Ginkgo nodes,
  45. // accepting the byte array.
  46. func setupSuite() {
  47. // Run only on Ginkgo node 1
  48. }
  49. // setupSuitePerGinkgoNode is the boilerplate that can be used to setup ginkgo test suites, on the SynchronizedBeforeSuite step.
  50. // There are certain operations we only want to run once per overall test invocation on each Ginkgo node
  51. // such as making some global variables accessible to all parallel executions
  52. // Because of the way Ginkgo runs tests in parallel, we must use SynchronizedBeforeSuite
  53. // Ref: https://onsi.github.io/ginkgo/#parallel-specs
  54. func setupSuitePerGinkgoNode() {
  55. // config.GinkgoConfig.ParallelNode
  56. }