Skip to content

Commit

Permalink
Fix E2E's logWslProServiceJournal
Browse files Browse the repository at this point in the history
It fixes a couple issues in the logs and makes it more similar to the
new logWindowsAgentJournal.
  • Loading branch information
EduardGomezEscandell committed Nov 16, 2023
1 parent 180ea6e commit a661b9c
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 14 deletions.
6 changes: 1 addition & 5 deletions end-to-end/manual_token_input_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,7 @@ func TestManualTokenInput(t *testing.T) {
name := registerFromTestImage(t, ctx)
d := wsl.NewDistro(ctx, name)

defer func() {
if t.Failed() {
logWslProServiceJournal(t, ctx, d)
}
}()
defer logWslProServiceJournal(t, ctx, true, d)

out, err := d.Command(ctx, "exit 0").CombinedOutput()
require.NoErrorf(t, err, "Setup: could not wake distro up: %v. %s", err, out)
Expand Down
2 changes: 1 addition & 1 deletion end-to-end/organization_token_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ func TestOrganizationProvidedToken(t *testing.T) {
name := registerFromTestImage(t, ctx)
d := wsl.NewDistro(ctx, name)

defer logWslProServiceJournal(t, ctx, d)
defer logWslProServiceJournal(t, ctx, true, d)

out, err := d.Command(ctx, "exit 0").CombinedOutput()
require.NoErrorf(t, err, "Setup: could not wake distro up: %v. %s", err, out)
Expand Down
6 changes: 1 addition & 5 deletions end-to-end/purchase_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,11 +109,7 @@ func TestPurchase(t *testing.T) {
name := registerFromTestImage(t, ctx)
d := wsl.NewDistro(ctx, name)

defer func() {
if t.Failed() {
logWslProServiceJournal(t, ctx, d)
}
}()
defer logWslProServiceJournal(t, ctx, true, d)

out, err := d.Command(ctx, "exit 0").CombinedOutput()
require.NoErrorf(t, err, "Setup: could not wake distro up: %v. %s", err, out)
Expand Down
11 changes: 8 additions & 3 deletions end-to-end/utils_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -171,14 +171,19 @@ func distroIsProAttached(t *testing.T, ctx context.Context, d gowsl.Distro) (boo
}

//nolint:revive // testing.T must precede the context
func logWslProServiceJournal(t *testing.T, ctx context.Context, d gowsl.Distro) {
func logWslProServiceJournal(t *testing.T, ctx context.Context, skipOnSuccess bool, d gowsl.Distro) {
t.Helper()

if skipOnSuccess && !t.Failed() {
return
}

out, err := d.Command(ctx, "journalctl -b --no-pager -u wsl-pro.service").CombinedOutput()
if err != nil {
t.Logf("could not access logs: %v\n%s\n", err, out)
t.Logf("could not access WSL Pro Service logs: %v\n%s\n", err, out)
return
}
t.Logf("wsl-pro-service logs:\n%s\n", out)
t.Logf("WSL Pro Service logs:\n%s\n", out)
}

func logWindowsAgentJournal(t *testing.T, skipOnSuccess bool) {
Expand Down

0 comments on commit a661b9c

Please sign in to comment.