func()

in cmd/e2e-test/rune2e/command.go [100:169]


func (c *command) Run(log *zap.Logger, opts *cli.GlobalOptions) error {
	ctx := context.Background()
	logger := e2e.NewLogger(e2e.LoggerConfig{NoColor: c.noColor})

	awsCfg, err := e2e.NewAWSConfig(ctx,
		config.WithRegion(c.region),
		// We use a custom AppId so the requests show that they were
		// made by this command in the user-agent
		config.WithAppID("nodeadm-e2e-test-run-cmd"),
	)
	if err != nil {
		return fmt.Errorf("reading AWS configuration: %w", err)
	}
	if c.region == "" {
		c.region = awsCfg.Region
	}

	testResources, err := c.loadSetupConfig(logger)
	if err != nil {
		return fmt.Errorf("loading test resources configuration: %w", err)
	}

	testConfig, err := c.loadTestConfig(testResources, logger)
	if err != nil {
		return fmt.Errorf("loading test configuration: %w", err)
	}

	artifactsDir, err := c.getArtifactsDir(c.artifactsDir, logger)
	if err != nil {
		return fmt.Errorf("getting artifacts directory: %w", err)
	}

	testConfig.ArtifactsFolder = artifactsDir

	ginkgoBinaryPath, err := c.getGinkgoBinaryPath()
	if err != nil {
		return fmt.Errorf("getting ginkgo binary path: %w", err)
	}

	// Run E2E tests
	e2e := run.E2E{
		AwsCfg:  awsCfg,
		Logger:  logger,
		NoColor: c.noColor,
		Paths: run.E2EPaths{
			Ginkgo:              ginkgoBinaryPath,
			TestsBinaryOrSource: c.testsBinaryOrPath,
		},
		TestConfig:      testConfig,
		TestLabelFilter: c.testLabelFilter,
		TestProcs:       c.testProcs,
		Timeout:         c.timeout,
		TestResources:   testResources,
		SkipCleanup:     c.skipCleanup,
		SkippedTests:    c.skippedTests,
	}

	e2eResult, testErr := e2e.Run(ctx)

	// Always try to output the results
	outputErr := e2e.PrintResults(ctx, e2eResult)
	if outputErr != nil {
		logger.Error(outputErr, "outputting E2E results")
	}
	if testErr != nil {
		return fmt.Errorf("running E2E tests: %w", testErr)
	}

	return nil
}