From eef4a0a5964e221e1b096aa4994ff8d251cc7330 Mon Sep 17 00:00:00 2001 From: Steve Kuznetsov Date: Tue, 28 May 2024 08:31:26 -0600 Subject: [PATCH] test/e2e: resolve dump dir once Signed-off-by: Steve Kuznetsov --- test/e2e/util/fixture.go | 9 ++++----- test/e2e/util/hypershift_framework.go | 7 ++++--- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/test/e2e/util/fixture.go b/test/e2e/util/fixture.go index 19482996cc..8950c61608 100644 --- a/test/e2e/util/fixture.go +++ b/test/e2e/util/fixture.go @@ -269,26 +269,25 @@ func newClusterDumper(hc *hyperv1.HostedCluster, opts *core.CreateOptions, artif t.Logf("Skipping cluster dump because no artifact directory was provided") return nil } - dumpDir := filepath.Join(artifactDir, artifactSubdirFor(t)) switch hc.Spec.Platform.Type { case hyperv1.AWSPlatform: var dumpErrors []error - err := dump.DumpMachineConsoleLogs(ctx, hc, opts.AWSPlatform.AWSCredentialsOpts, dumpDir) + err := dump.DumpMachineConsoleLogs(ctx, hc, opts.AWSPlatform.AWSCredentialsOpts, artifactDir) if err != nil { t.Logf("Failed saving machine console logs; this is nonfatal: %v", err) } - err = dump.DumpHostedCluster(ctx, t, hc, dumpGuestCluster, dumpDir) + err = dump.DumpHostedCluster(ctx, t, hc, dumpGuestCluster, artifactDir) if err != nil { dumpErrors = append(dumpErrors, fmt.Errorf("failed to dump hosted cluster: %w", err)) } - err = dump.DumpJournals(t, ctx, hc, dumpDir, opts.AWSPlatform.AWSCredentialsOpts.AWSCredentialsFile) + err = dump.DumpJournals(t, ctx, hc, artifactDir, opts.AWSPlatform.AWSCredentialsOpts.AWSCredentialsFile) if err != nil { t.Logf("Failed to dump machine journals; this is nonfatal: %v", err) } return utilerrors.NewAggregate(dumpErrors) default: - err := dump.DumpHostedCluster(ctx, t, hc, dumpGuestCluster, dumpDir) + err := dump.DumpHostedCluster(ctx, t, hc, dumpGuestCluster, artifactDir) if err != nil { return fmt.Errorf("failed to dump hosted cluster: %w", err) } diff --git a/test/e2e/util/hypershift_framework.go b/test/e2e/util/hypershift_framework.go index 4597f7f9da..02c9eaf91c 100644 --- a/test/e2e/util/hypershift_framework.go +++ b/test/e2e/util/hypershift_framework.go @@ -52,6 +52,8 @@ func NewHypershiftTest(t *testing.T, ctx context.Context, test hypershiftTestFun } func (h *hypershiftTest) Execute(opts *core.CreateOptions, platform hyperv1.PlatformType, artifactDir string, serviceAccountSigningKey []byte) { + artifactDir = filepath.Join(artifactDir, artifactSubdirFor(h.T)) + // create a hypershift cluster for the test hostedCluster := h.createHostedCluster(opts, platform, serviceAccountSigningKey, artifactDir) @@ -261,8 +263,7 @@ func (h *hypershiftTest) createHostedCluster(opts *core.CreateOptions, platform g.Expect(err).NotTo(HaveOccurred(), "failed to generate platform specific cluster options") // Dump the output from rendering the cluster objects for posterity - dumpDir := filepath.Join(artifactDir, artifactSubdirFor(h.T)) - if err := os.MkdirAll(dumpDir, 0755); err != nil { + if err := os.MkdirAll(artifactDir, 0755); err != nil { h.Errorf("failed to create dump directory: %v", err) } @@ -270,7 +271,7 @@ func (h *hypershiftTest) createHostedCluster(opts *core.CreateOptions, platform opts.Render = false opts.RenderInto = "" h.Logf("Creating a new cluster. Options: %v", opts) - if err := createCluster(h.ctx, hc, opts, dumpDir); err != nil { + if err := createCluster(h.ctx, hc, opts, artifactDir); err != nil { h.Errorf("failed to create cluster, tearing down: %v", err) return hc }