e2e.go 2.3 KB

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