Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update installation/uninstallation package process in system tests #1845

Closed
wants to merge 34 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
dd53426
Install/Uninstall once package per data stream folder
mrodm May 20, 2024
6c448c9
Add setup and teardown runner methods to Runner interface
mrodm May 20, 2024
0c40417
Avoid re-creating runner
mrodm May 20, 2024
6221c2e
Debug - show timestamp first doc
mrodm May 20, 2024
0e4e8e1
Remove unused context
mrodm May 20, 2024
d85ce79
Check timestamps
mrodm May 20, 2024
dedb517
Add condition to check if hits is zero to finish loop
mrodm May 21, 2024
3c18264
Move first check inside loop
mrodm May 21, 2024
3e80680
Set different waiting times
mrodm May 21, 2024
da98733
Create policy for no-provision - missing to re-assign policy
mrodm May 23, 2024
dd9bf60
Ensure test policy is re-assigned
mrodm May 23, 2024
df6268a
Delete agent policies created for each test
mrodm May 23, 2024
ed1411e
delete datastream created for testing
mrodm May 23, 2024
1c55b1c
Apply changes to all scenarios
mrodm May 24, 2024
2bca8d8
Skip tests with terraform
mrodm May 24, 2024
60c34da
Fix env. variable name
mrodm May 24, 2024
402b631
Change order tear down handlers
mrodm May 28, 2024
e7ea9ff
Exit loop if getDocs returns zero documents
mrodm May 28, 2024
8e95b4d
Reorder handlers and change condition
mrodm May 28, 2024
a421e83
Add new tear down handler
mrodm May 28, 2024
8c9c5d8
Update comment
mrodm May 28, 2024
c11361f
Add one more test package
mrodm May 28, 2024
7d71562
Remove exceptions in wait loop to delete docs
mrodm May 28, 2024
e4e8751
Update some logger calls to use the right formats
mrodm May 28, 2024
f43dc77
Restore packages skipped
mrodm May 28, 2024
df1835c
Remove empty line
mrodm May 28, 2024
d9e8000
Remove mustBeZero parameter from delete docs function
mrodm May 28, 2024
7769e3c
Add handler to clean test scenario - test only stage
mrodm May 28, 2024
91676d7
Skip handlers that should not be executed with --no-provision
mrodm May 28, 2024
6ea15b3
Merge create-policy-per-test onto instal-package-once-system-tests
mrodm May 30, 2024
8f4a52a
Reuse same runner instance
mrodm May 31, 2024
4bf6049
Add pointers
mrodm May 31, 2024
e59151c
Add pointer to static runner receiver
mrodm May 31, 2024
31e421b
Remove uninstall step in tearDown test
mrodm May 31, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .buildkite/pipeline.trigger.integration.tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,6 @@ for package in $(find . -maxdepth 1 -mindepth 1 -type d) ; do
label_suffix=" (independent agent)"
fi
package_name=$(basename "${package}")

if [[ "$independent_agent" == "false" && "$package_name" == "oracle" ]]; then
echoerr "Package \"${package_name}\" skipped: not supported with Elastic Agent running in the stack (missing required software)."
continue
Expand Down
46 changes: 29 additions & 17 deletions cmd/testrunner.go
Original file line number Diff line number Diff line change
Expand Up @@ -337,25 +337,31 @@ func testTypeCommandActionFactory(runner testrunner.TestRunner) cobraext.Command
fmt.Printf("Running tests per stages (technical preview)\n")
}

runnerOptions := testrunner.TestOptions{
Profile: profile,
PackageRootPath: packageRootPath,
GenerateTestResult: generateTestResult,
API: esAPI,
KibanaClient: kibanaClient,
DeferCleanup: deferCleanup,
ServiceVariant: variantFlag,
WithCoverage: testCoverage,
CoverageType: testCoverageFormat,
ConfigFilePath: configFileFlag,
RunSetup: runSetup,
RunTearDown: runTearDown,
RunTestsOnly: runTestsOnly,
RunIndependentElasticAgent: false,
}
err = runner.SetupRunner(ctx, runnerOptions)
if err != nil {
return fmt.Errorf("failed to run setup runner process: %w", err)
}

var results []testrunner.TestResult
for _, folder := range testFolders {
r, err := testrunner.Run(ctx, testType, testrunner.TestOptions{
Profile: profile,
TestFolder: folder,
PackageRootPath: packageRootPath,
GenerateTestResult: generateTestResult,
API: esAPI,
KibanaClient: kibanaClient,
DeferCleanup: deferCleanup,
ServiceVariant: variantFlag,
WithCoverage: testCoverage,
CoverageType: testCoverageFormat,
ConfigFilePath: configFileFlag,
RunSetup: runSetup,
RunTearDown: runTearDown,
RunTestsOnly: runTestsOnly,
RunIndependentElasticAgent: false,
})
runnerOptions.TestFolder = folder
r, err := testrunner.Run(ctx, runner, runnerOptions)

// Results must be appended even if there is an error, since there could be
// tests (e.g. system tests) that return both error and results.
Expand All @@ -367,6 +373,11 @@ func testTypeCommandActionFactory(runner testrunner.TestRunner) cobraext.Command

}

err = runner.TearDownRunner(ctx)
if err != nil {
return fmt.Errorf("failed to run tear down runner process: %w", err)
}

format := testrunner.TestReportFormat(reportFormat)
report, err := testrunner.FormatReport(format, results)
if err != nil {
Expand All @@ -390,6 +401,7 @@ func testTypeCommandActionFactory(runner testrunner.TestRunner) cobraext.Command
return errors.New("one or more test cases failed")
}
}

return nil
}
}
Expand Down
4 changes: 2 additions & 2 deletions internal/agentdeployer/agent.go
Original file line number Diff line number Diff line change
Expand Up @@ -391,12 +391,12 @@ func (s *dockerComposeDeployedAgent) TearDown(ctx context.Context) error {
defer func() {
// Remove the service logs dir for this agent
if err := os.RemoveAll(s.agentInfo.Logs.Folder.Local); err != nil {
logger.Errorf("could not remove the agent logs (path: %s): %w", s.agentInfo.Logs.Folder.Local, err)
logger.Errorf("could not remove the agent logs (path: %s): %v", s.agentInfo.Logs.Folder.Local, err)
}

// Remove the configuration dir for this agent (e.g. compose scenario files)
if err := os.RemoveAll(s.agentInfo.ConfigDir); err != nil {
logger.Errorf("could not remove the agent configuration directory (path: %s) %w", s.agentInfo.ConfigDir, err)
logger.Errorf("could not remove the agent configuration directory (path: %s) %v", s.agentInfo.ConfigDir, err)
}
}()

Expand Down
4 changes: 2 additions & 2 deletions internal/servicedeployer/compose.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ func (d *DockerComposeServiceDeployer) SetUp(ctx context.Context, svcInfo Servic
// service logs folder must no be deleted to avoid breaking log files written
// by the service. If this is required, those files should be rotated or truncated
// so the service can still write to them.
logger.Debug("Skipping removing service logs folder folder %s", svcInfo.Logs.Folder.Local)
logger.Debugf("Skipping removing service logs folder folder %s", svcInfo.Logs.Folder.Local)
} else {
err = files.RemoveContent(svcInfo.Logs.Folder.Local)
if err != nil {
Expand Down Expand Up @@ -242,7 +242,7 @@ func (s *dockerComposeDeployedService) TearDown(ctx context.Context) error {
}
// Remove the outputs generated by the service container
if err = os.RemoveAll(s.svcInfo.OutputDir); err != nil {
logger.Errorf("could not remove the temporary output files %w", err)
logger.Errorf("could not remove the temporary output files %s", err)
}
}()

Expand Down
2 changes: 1 addition & 1 deletion internal/servicedeployer/custom_agent.go
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ func (d *CustomAgentDeployer) SetUp(ctx context.Context, svcInfo ServiceInfo) (D
// service logs folder must no be deleted to avoid breaking log files written
// by the service. If this is required, those files should be rotated or truncated
// so the service can still write to them.
logger.Debug("Skipping removing service logs folder folder %s", svcInfo.Logs.Folder.Local)
logger.Debugf("Skipping removing service logs folder folder %s", svcInfo.Logs.Folder.Local)
} else {
err = files.RemoveContent(svcInfo.Logs.Folder.Local)
if err != nil {
Expand Down
25 changes: 18 additions & 7 deletions internal/testrunner/runners/asset/runner.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,24 @@ func (r runner) String() string {
return "asset loading"
}

// SetupRunner prepares global resources required by the test runner.
func (r *runner) SetupRunner(ctx context.Context, options testrunner.TestOptions) error {
r.packageRootPath = options.PackageRootPath
r.kibanaClient = options.KibanaClient

manager := resources.NewManager()
manager.RegisterProvider(resources.DefaultKibanaProviderName, &resources.KibanaProvider{Client: r.kibanaClient})

r.resourcesManager = manager
return nil
}

// TearDownRunner cleans up any global test runner resources. It must be called
// after the test runner has finished executing all its tests.
func (r runner) TearDownRunner(ctx context.Context) error {
return nil
}

// CanRunPerDataStream returns whether this test runner can run on individual
// data streams within the package.
func (r runner) CanRunPerDataStream() bool {
Expand All @@ -61,13 +79,6 @@ func (r *runner) CanRunSetupTeardownIndependent() bool {
// Run runs the asset loading tests
func (r *runner) Run(ctx context.Context, options testrunner.TestOptions) ([]testrunner.TestResult, error) {
r.testFolder = options.TestFolder
r.packageRootPath = options.PackageRootPath
r.kibanaClient = options.KibanaClient

manager := resources.NewManager()
manager.RegisterProvider(resources.DefaultKibanaProviderName, &resources.KibanaProvider{Client: r.kibanaClient})
r.resourcesManager = manager

return r.run(ctx)
}

Expand Down
14 changes: 13 additions & 1 deletion internal/testrunner/runners/pipeline/runner.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,21 @@ func (r *runner) String() string {
return "pipeline"
}

// SetupRunner prepares global resources required by the test runner.
func (r *runner) SetupRunner(ctx context.Context, options testrunner.TestOptions) error {
r.options = options
return nil
}

// TearDownRunner cleans up any global test runner resources. It must be called
// after the test runner has finished executing all its tests.
func (r *runner) TearDownRunner(ctx context.Context) error {
return nil
}

// Run runs the pipeline tests defined under the given folder
func (r *runner) Run(ctx context.Context, options testrunner.TestOptions) ([]testrunner.TestResult, error) {
r.options = options
r.options.TestFolder = options.TestFolder

stackConfig, err := stack.LoadConfig(r.options.Profile)
if err != nil {
Expand Down
14 changes: 13 additions & 1 deletion internal/testrunner/runners/static/runner.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,20 @@ func (r runner) String() string {
return "static files"
}

func (r runner) Run(ctx context.Context, options testrunner.TestOptions) ([]testrunner.TestResult, error) {
// SetupRunner prepares global resources required by the test runner.
func (r *runner) SetupRunner(ctx context.Context, options testrunner.TestOptions) error {
r.options = options
return nil
}

// TearDownRunner cleans up any global test runner resources. It must be called
// after the test runner has finished executing all its tests.
func (r *runner) TearDownRunner(ctx context.Context) error {
return nil
}

func (r runner) Run(ctx context.Context, options testrunner.TestOptions) ([]testrunner.TestResult, error) {
r.options.TestFolder = options.TestFolder
return r.run(ctx)
}

Expand Down
Loading