Skip to content

Commit

Permalink
test/e2e: resolve dump dir once
Browse files Browse the repository at this point in the history
Signed-off-by: Steve Kuznetsov <[email protected]>
  • Loading branch information
stevekuznetsov committed May 28, 2024
1 parent dbbdfe0 commit eef4a0a
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
9 changes: 4 additions & 5 deletions test/e2e/util/fixture.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down
7 changes: 4 additions & 3 deletions test/e2e/util/hypershift_framework.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down Expand Up @@ -261,16 +263,15 @@ 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)
}

// Try and create the cluster. If it fails, mark test as failed and return.
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
}
Expand Down

0 comments on commit eef4a0a

Please sign in to comment.