Skip to content

Commit

Permalink
tests/blackbox: allow skipping critical logging check
Browse files Browse the repository at this point in the history
In the context of the test added in the previous patch, it's normal for
the first `sgdisk --zap-all` invocation to fail. Add a knob to allow the
harness to tolerate this and make use of it in the new test.
  • Loading branch information
jlebon committed Oct 25, 2023
1 parent 5717a50 commit bc737f0
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 12 deletions.
20 changes: 10 additions & 10 deletions tests/blackbox_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -278,24 +278,24 @@ func outer(t *testing.T, test types.Test, negativeTests bool) error {
appendEnv = append(appendEnv, "IGNITION_SYSTEM_CONFIG_DIR="+systemConfigDir)

if !negativeTests {
if err := runIgnition(t, ctx, "fetch", "", tmpDirectory, appendEnv); err != nil {
if err := runIgnition(t, ctx, "fetch", "", tmpDirectory, appendEnv, test.SkipCriticalCheck); err != nil {
return err
}

if err := runIgnition(t, ctx, "disks", "", tmpDirectory, appendEnv); err != nil {
if err := runIgnition(t, ctx, "disks", "", tmpDirectory, appendEnv, test.SkipCriticalCheck); err != nil {
return err
}

if err := mountPartition(ctx, rootPartition); err != nil {
return err
}

if err := runIgnition(t, ctx, "mount", rootPartition.MountPath, tmpDirectory, appendEnv); err != nil {
if err := runIgnition(t, ctx, "mount", rootPartition.MountPath, tmpDirectory, appendEnv, test.SkipCriticalCheck); err != nil {
return err
}

filesErr := runIgnition(t, ctx, "files", rootPartition.MountPath, tmpDirectory, appendEnv)
if err := runIgnition(t, ctx, "umount", rootPartition.MountPath, tmpDirectory, appendEnv); err != nil {
filesErr := runIgnition(t, ctx, "files", rootPartition.MountPath, tmpDirectory, appendEnv, test.SkipCriticalCheck)
if err := runIgnition(t, ctx, "umount", rootPartition.MountPath, tmpDirectory, appendEnv, test.SkipCriticalCheck); err != nil {
return err
}
if err := umountPartition(rootPartition); err != nil {
Expand All @@ -318,24 +318,24 @@ func outer(t *testing.T, test types.Test, negativeTests bool) error {
}
return nil
} else {
if err := runIgnition(t, ctx, "fetch", "", tmpDirectory, appendEnv); err != nil {
if err := runIgnition(t, ctx, "fetch", "", tmpDirectory, appendEnv, test.SkipCriticalCheck); err != nil {
return nil // error is expected
}

if err := runIgnition(t, ctx, "disks", "", tmpDirectory, appendEnv); err != nil {
if err := runIgnition(t, ctx, "disks", "", tmpDirectory, appendEnv, test.SkipCriticalCheck); err != nil {
return nil // error is expected
}

if err := mountPartition(ctx, rootPartition); err != nil {
return err
}

if err := runIgnition(t, ctx, "mount", rootPartition.MountPath, tmpDirectory, appendEnv); err != nil {
if err := runIgnition(t, ctx, "mount", rootPartition.MountPath, tmpDirectory, appendEnv, test.SkipCriticalCheck); err != nil {
return nil // error is expected
}

filesErr := runIgnition(t, ctx, "files", rootPartition.MountPath, tmpDirectory, appendEnv)
if err := runIgnition(t, ctx, "umount", rootPartition.MountPath, tmpDirectory, appendEnv); err != nil {
filesErr := runIgnition(t, ctx, "files", rootPartition.MountPath, tmpDirectory, appendEnv, test.SkipCriticalCheck)
if err := runIgnition(t, ctx, "umount", rootPartition.MountPath, tmpDirectory, appendEnv, test.SkipCriticalCheck); err != nil {
return nil
}
if err := umountPartition(rootPartition); err != nil {
Expand Down
4 changes: 2 additions & 2 deletions tests/filesystem.go
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ func umountPartition(p *types.Partition) error {
}

// returns true if no error, false if error
func runIgnition(t *testing.T, ctx context.Context, stage, root, cwd string, appendEnv []string) error {
func runIgnition(t *testing.T, ctx context.Context, stage, root, cwd string, appendEnv []string, skipCriticalCheck bool) error {
args := []string{"-platform", "file", "-stage", stage,
"-root", root, "-log-to-stdout",
"-config-cache", filepath.Join(cwd, "ignition.json"),
Expand All @@ -141,7 +141,7 @@ func runIgnition(t *testing.T, ctx context.Context, stage, root, cwd string, app
if strings.Contains(string(out), "panic") {
return fmt.Errorf("ignition panicked")
}
if strings.Contains(string(out), "CRITICAL") {
if !skipCriticalCheck && strings.Contains(string(out), "CRITICAL") {
return fmt.Errorf("found critical ignition log")
}
return err
Expand Down
2 changes: 2 additions & 0 deletions tests/positive/partitions/wipe.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,5 +59,7 @@ func WipeBadTable() types.Test {
Out: out,
Config: config,
ConfigMinVersion: configMinVersion,
// the first `sgdisk --zap-all` is expected to fail
SkipCriticalCheck: true,
}
}
1 change: 1 addition & 0 deletions tests/types/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ type Test struct {
ConfigMinVersion string
ConfigVersion string
ConfigShouldBeBad bool // Set to true to skip config validation step
SkipCriticalCheck bool // Set to true to skip critical logging check
}

func (ps Partitions) GetPartition(label string) *Partition {
Expand Down

0 comments on commit bc737f0

Please sign in to comment.