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