@@ -186,6 +186,7 @@ type tester struct {
186186 dataStreamManifest * packages.DataStreamManifest
187187 withCoverage bool
188188 coverageType string
189+ dumpPrefix string
189190
190191 serviceStateFilePath string
191192
@@ -218,6 +219,7 @@ type SystemTesterOptions struct {
218219 GlobalTestConfig testrunner.GlobalRunnerTestConfig
219220 WithCoverage bool
220221 CoverageType string
222+ DumpPrefix string
221223
222224 RunSetup bool
223225 RunTearDown bool
@@ -672,7 +674,6 @@ func (r *tester) runTestPerVariant(ctx context.Context, stackConfig stack.Config
672674 logger .Debugf ("Using config: %q" , testConfig .Name ())
673675
674676 partial , err := r .runTest (ctx , testConfig , stackConfig , svcInfo )
675-
676677 tdErr := r .tearDownTest (ctx )
677678 if err != nil {
678679 return partial , err
@@ -1814,32 +1815,26 @@ func (r *tester) runTest(ctx context.Context, config *testConfig, stackConfig st
18141815 return results , nil
18151816 }
18161817
1817- if dump , ok := os .LookupEnv (dumpScenarioDocsEnv ); ok && dump != "" {
1818- err := dumpScenarioDocs (scenario .docs )
1818+ var dumpPath string
1819+ switch {
1820+ case r .dumpPrefix != "" :
1821+ dumpPath = fmt .Sprintf ("%s-%s.json" , r .dumpPrefix , time .Now ().Format ("20060102150405" ))
1822+ case os .Getenv (dumpScenarioDocsEnv ) != "" :
1823+ dumpPath = filepath .Join (os .TempDir (), fmt .Sprintf ("elastic-package-test-docs-dump-%s.json" , time .Now ().Format ("20060102150405" )))
1824+ }
1825+ var dumpErr error
1826+ if dumpPath != "" {
1827+ err := dumpScenarioDocs (scenario .docs , dumpPath )
18191828 if err != nil {
1820- return nil , fmt .Errorf ("failed to dump scenario docs: %w" , err )
1829+ dumpErr = fmt .Errorf ("failed to dump scenario docs: %w" , err )
18211830 }
18221831 }
18231832
1824- return r .validateTestScenario (ctx , result , scenario , config )
1825- }
1826-
1827- func (r * tester ) isTestUsingOTELCollectorInput (policyTemplateInput string ) bool {
1828- // Just supported for input packages currently
1829- if r .pkgManifest .Type != "input" {
1830- return false
1831- }
1832-
1833- if policyTemplateInput != otelCollectorInputName {
1834- return false
1835- }
1836-
1837- return true
1833+ results , err := r .validateTestScenario (ctx , result , scenario , config )
1834+ return results , errors .Join (err , dumpErr )
18381835}
18391836
1840- func dumpScenarioDocs (docs any ) error {
1841- timestamp := time .Now ().Format ("20060102150405" )
1842- path := filepath .Join (os .TempDir (), fmt .Sprintf ("elastic-package-test-docs-dump-%s.json" , timestamp ))
1837+ func dumpScenarioDocs (docs any , path string ) error {
18431838 f , err := os .Create (path )
18441839 if err != nil {
18451840 return fmt .Errorf ("failed to create dump file: %w" , err )
@@ -1857,6 +1852,19 @@ func dumpScenarioDocs(docs any) error {
18571852 return nil
18581853}
18591854
1855+ func (r * tester ) isTestUsingOTELCollectorInput (policyTemplateInput string ) bool {
1856+ // Just supported for input packages currently
1857+ if r .pkgManifest .Type != "input" {
1858+ return false
1859+ }
1860+
1861+ if policyTemplateInput != otelCollectorInputName {
1862+ return false
1863+ }
1864+
1865+ return true
1866+ }
1867+
18601868func (r * tester ) checkEnrolledAgents (ctx context.Context , agentInfo agentdeployer.AgentInfo , svcInfo servicedeployer.ServiceInfo ) (* kibana.Agent , error ) {
18611869 var agents []kibana.Agent
18621870
0 commit comments