-
Notifications
You must be signed in to change notification settings - Fork 129
add command line flag for system test result dumps #2967
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -221,6 +221,7 @@ type tester struct { | |
| dataStreamManifest *packages.DataStreamManifest | ||
| withCoverage bool | ||
| coverageType string | ||
| dumpPrefix string | ||
|
|
||
| serviceStateFilePath string | ||
|
|
||
|
|
@@ -253,6 +254,7 @@ type SystemTesterOptions struct { | |
| GlobalTestConfig testrunner.GlobalRunnerTestConfig | ||
| WithCoverage bool | ||
| CoverageType string | ||
| DumpPrefix string | ||
|
|
||
| RunSetup bool | ||
| RunTearDown bool | ||
|
|
@@ -705,7 +707,6 @@ func (r *tester) runTestPerVariant(ctx context.Context, stackConfig stack.Config | |
| logger.Debugf("Using config: %q", testConfig.Name()) | ||
|
|
||
| partial, err := r.runTest(ctx, testConfig, stackConfig, svcInfo) | ||
|
|
||
| tdErr := r.tearDownTest(ctx) | ||
| if err != nil { | ||
| return partial, err | ||
|
|
@@ -1817,32 +1818,26 @@ func (r *tester) runTest(ctx context.Context, config *testConfig, stackConfig st | |
| return results, nil | ||
| } | ||
|
|
||
| if dump, ok := os.LookupEnv(dumpScenarioDocsEnv); ok && dump != "" { | ||
| err := dumpScenarioDocs(scenario.docs) | ||
| var dumpPath string | ||
| switch { | ||
| case r.dumpPrefix != "": | ||
| dumpPath = fmt.Sprintf("%s-%s.json", r.dumpPrefix, time.Now().Format("20060102150405")) | ||
| case os.Getenv(dumpScenarioDocsEnv) != "": | ||
| dumpPath = filepath.Join(os.TempDir(), fmt.Sprintf("elastic-package-test-docs-dump-%s.json", time.Now().Format("20060102150405"))) | ||
| } | ||
| var dumpErr error | ||
| if dumpPath != "" { | ||
| err := dumpScenarioDocs(scenario.docs, dumpPath) | ||
| if err != nil { | ||
| return nil, fmt.Errorf("failed to dump scenario docs: %w", err) | ||
| dumpErr = fmt.Errorf("failed to dump scenario docs: %w", err) | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. just for understanding, why we change the behavior, so now the error is not thrown but joined to the result of validateTestScenario. Does it make sense to run There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why would it be relevant to the success of the test if some aspect of the dump fails? As an example, if the dump fails because of an fs error, do we now not care that the validation is not valid? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. that is the question i asked in order to understand the change. before, the test was failing if dump failed, isn't it? i am just asking to understand, lacking context here. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes. I think that behaviour was unhelpful. (see this for context) |
||
| } | ||
| } | ||
|
|
||
| return r.validateTestScenario(ctx, result, scenario, config) | ||
| } | ||
|
|
||
| func (r *tester) isTestUsingOTELCollectorInput(policyTemplateInput string) bool { | ||
| // Just supported for input packages currently | ||
| if r.pkgManifest.Type != "input" { | ||
| return false | ||
| } | ||
|
|
||
| if policyTemplateInput != otelCollectorInputName { | ||
| return false | ||
| } | ||
|
|
||
| return true | ||
| results, err := r.validateTestScenario(ctx, result, scenario, config) | ||
| return results, errors.Join(err, dumpErr) | ||
| } | ||
|
|
||
| func dumpScenarioDocs(docs any) error { | ||
| timestamp := time.Now().Format("20060102150405") | ||
| path := filepath.Join(os.TempDir(), fmt.Sprintf("elastic-package-test-docs-dump-%s.json", timestamp)) | ||
| func dumpScenarioDocs(docs any, path string) error { | ||
| f, err := os.Create(path) | ||
| if err != nil { | ||
| return fmt.Errorf("failed to create dump file: %w", err) | ||
|
|
@@ -1860,6 +1855,19 @@ func dumpScenarioDocs(docs any) error { | |
| return nil | ||
| } | ||
|
|
||
| func (r *tester) isTestUsingOTELCollectorInput(policyTemplateInput string) bool { | ||
| // Just supported for input packages currently | ||
| if r.pkgManifest.Type != "input" { | ||
| return false | ||
| } | ||
|
|
||
| if policyTemplateInput != otelCollectorInputName { | ||
| return false | ||
| } | ||
|
|
||
| return true | ||
| } | ||
|
|
||
| func (r *tester) checkEnrolledAgents(ctx context.Context, agentInfo agentdeployer.AgentInfo, svcInfo servicedeployer.ServiceInfo) (*kibana.Agent, error) { | ||
| var agents []kibana.Agent | ||
|
|
||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.