@@ -221,6 +221,7 @@ type tester struct {
221221 dataStreamManifest * packages.DataStreamManifest
222222 withCoverage bool
223223 coverageType string
224+ dumpPrefix string
224225
225226 serviceStateFilePath string
226227
@@ -253,6 +254,7 @@ type SystemTesterOptions struct {
253254 GlobalTestConfig testrunner.GlobalRunnerTestConfig
254255 WithCoverage bool
255256 CoverageType string
257+ DumpPrefix string
256258
257259 RunSetup bool
258260 RunTearDown bool
@@ -705,7 +707,6 @@ func (r *tester) runTestPerVariant(ctx context.Context, stackConfig stack.Config
705707 logger .Debugf ("Using config: %q" , testConfig .Name ())
706708
707709 partial , err := r .runTest (ctx , testConfig , stackConfig , svcInfo )
708-
709710 tdErr := r .tearDownTest (ctx )
710711 if err != nil {
711712 return partial , err
@@ -1817,32 +1818,26 @@ func (r *tester) runTest(ctx context.Context, config *testConfig, stackConfig st
18171818 return results , nil
18181819 }
18191820
1820- if dump , ok := os .LookupEnv (dumpScenarioDocsEnv ); ok && dump != "" {
1821- err := dumpScenarioDocs (scenario .docs )
1821+ var dumpPath string
1822+ switch {
1823+ case r .dumpPrefix != "" :
1824+ dumpPath = fmt .Sprintf ("%s-%s.json" , r .dumpPrefix , time .Now ().Format ("20060102150405" ))
1825+ case os .Getenv (dumpScenarioDocsEnv ) != "" :
1826+ dumpPath = filepath .Join (os .TempDir (), fmt .Sprintf ("elastic-package-test-docs-dump-%s.json" , time .Now ().Format ("20060102150405" )))
1827+ }
1828+ var dumpErr error
1829+ if dumpPath != "" {
1830+ err := dumpScenarioDocs (scenario .docs , dumpPath )
18221831 if err != nil {
1823- return nil , fmt .Errorf ("failed to dump scenario docs: %w" , err )
1832+ dumpErr = fmt .Errorf ("failed to dump scenario docs: %w" , err )
18241833 }
18251834 }
18261835
1827- return r .validateTestScenario (ctx , result , scenario , config )
1828- }
1829-
1830- func (r * tester ) isTestUsingOTELCollectorInput (policyTemplateInput string ) bool {
1831- // Just supported for input packages currently
1832- if r .pkgManifest .Type != "input" {
1833- return false
1834- }
1835-
1836- if policyTemplateInput != otelCollectorInputName {
1837- return false
1838- }
1839-
1840- return true
1836+ results , err := r .validateTestScenario (ctx , result , scenario , config )
1837+ return results , errors .Join (err , dumpErr )
18411838}
18421839
1843- func dumpScenarioDocs (docs any ) error {
1844- timestamp := time .Now ().Format ("20060102150405" )
1845- path := filepath .Join (os .TempDir (), fmt .Sprintf ("elastic-package-test-docs-dump-%s.json" , timestamp ))
1840+ func dumpScenarioDocs (docs any , path string ) error {
18461841 f , err := os .Create (path )
18471842 if err != nil {
18481843 return fmt .Errorf ("failed to create dump file: %w" , err )
@@ -1860,6 +1855,19 @@ func dumpScenarioDocs(docs any) error {
18601855 return nil
18611856}
18621857
1858+ func (r * tester ) isTestUsingOTELCollectorInput (policyTemplateInput string ) bool {
1859+ // Just supported for input packages currently
1860+ if r .pkgManifest .Type != "input" {
1861+ return false
1862+ }
1863+
1864+ if policyTemplateInput != otelCollectorInputName {
1865+ return false
1866+ }
1867+
1868+ return true
1869+ }
1870+
18631871func (r * tester ) checkEnrolledAgents (ctx context.Context , agentInfo agentdeployer.AgentInfo , svcInfo servicedeployer.ServiceInfo ) (* kibana.Agent , error ) {
18641872 var agents []kibana.Agent
18651873
0 commit comments