@@ -186,6 +186,7 @@ type tester struct {
186
186
dataStreamManifest * packages.DataStreamManifest
187
187
withCoverage bool
188
188
coverageType string
189
+ dumpPrefix string
189
190
190
191
serviceStateFilePath string
191
192
@@ -218,6 +219,7 @@ type SystemTesterOptions struct {
218
219
GlobalTestConfig testrunner.GlobalRunnerTestConfig
219
220
WithCoverage bool
220
221
CoverageType string
222
+ DumpPrefix string
221
223
222
224
RunSetup bool
223
225
RunTearDown bool
@@ -672,7 +674,6 @@ func (r *tester) runTestPerVariant(ctx context.Context, stackConfig stack.Config
672
674
logger .Debugf ("Using config: %q" , testConfig .Name ())
673
675
674
676
partial , err := r .runTest (ctx , testConfig , stackConfig , svcInfo )
675
-
676
677
tdErr := r .tearDownTest (ctx )
677
678
if err != nil {
678
679
return partial , err
@@ -1814,32 +1815,26 @@ func (r *tester) runTest(ctx context.Context, config *testConfig, stackConfig st
1814
1815
return results , nil
1815
1816
}
1816
1817
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 )
1819
1828
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 )
1821
1830
}
1822
1831
}
1823
1832
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 )
1838
1835
}
1839
1836
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 {
1843
1838
f , err := os .Create (path )
1844
1839
if err != nil {
1845
1840
return fmt .Errorf ("failed to create dump file: %w" , err )
@@ -1857,6 +1852,19 @@ func dumpScenarioDocs(docs any) error {
1857
1852
return nil
1858
1853
}
1859
1854
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
+
1860
1868
func (r * tester ) checkEnrolledAgents (ctx context.Context , agentInfo agentdeployer.AgentInfo , svcInfo servicedeployer.ServiceInfo ) (* kibana.Agent , error ) {
1861
1869
var agents []kibana.Agent
1862
1870
0 commit comments