Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions mantle/kola/cluster/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,16 @@ func (t *TestCluster) RunCmdSyncf(m platform.Machine, f string, args ...interfac
t.RunCmdSync(m, fmt.Sprintf(f, args...))
}

// AssertCmdOutputContains runs cmd via SSH and panics if stdout does not contain expected
func (t *TestCluster) AssertCmdOutputContains(m platform.Machine, cmd string, expected string) {
t.LogJournal(m, "+ "+cmd)
outputBuf := t.MustSSH(m, cmd)
output := string(outputBuf)
if !strings.Contains(output, expected) {
t.Fatalf("cmd %s did not output %s", cmd, expected)
}
}

// Synchronously write a log message from the syslog identifier `kola` into the target
// machine's journal (via ssh) as well as at a debug log level to the current process.
// This is useful for debugging test failures, as we always capture the target
Expand Down
10 changes: 2 additions & 8 deletions mantle/kola/tests/fips/fips.go
Original file line number Diff line number Diff line change
Expand Up @@ -132,12 +132,6 @@ func init() {
// Test: Run basic FIPS test
func fipsEnableTest(c cluster.TestCluster) {
m := c.Machines()[0]
status := c.MustSSH(m, `cat /proc/sys/crypto/fips_enabled`)
if string(status) != "1" {
c.Fatal("/proc/sys/crypto/fips_enabled is not set to 1")
}
policy := c.MustSSH(m, `update-crypto-policies --show`)
if string(policy) != "FIPS" {
c.Fatal("update-crypto-policies is not in FIPS mode")
}
c.AssertCmdOutputContains(m, `cat /proc/sys/crypto/fips_enabled`, "1")
c.AssertCmdOutputContains(m, `update-crypto-policies --show`, "FIPS")
}
5 changes: 1 addition & 4 deletions mantle/kola/tests/ignition/mount.go
Original file line number Diff line number Diff line change
Expand Up @@ -229,8 +229,5 @@ func mountValidate(c cluster.TestCluster, m platform.Machine, mountContents, pat
}

fPath := filepath.Join(path, "/hello.txt")
fileContents := c.MustSSH(m, "cat "+fPath)
if string(fileContents) != "hello world" {
c.Fatalf("Failed to write content to %s", fPath)
}
c.AssertCmdOutputContains(m, "cat "+fPath, "hello world")
}
9 changes: 1 addition & 8 deletions mantle/kola/tests/ignition/sethostname.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@
package ignition

import (
"strings"

"github.com/coreos/mantle/kola/cluster"
"github.com/coreos/mantle/kola/register"
"github.com/coreos/mantle/platform/conf"
Expand Down Expand Up @@ -57,10 +55,5 @@ func init() {

func setHostname(c cluster.TestCluster) {
m := c.Machines()[0]

out := c.MustSSH(m, "hostnamectl")

if !strings.Contains(string(out), "Static hostname: core1") {
c.Fatalf("hostname wasn't set correctly:\n%s", out)
}
c.AssertCmdOutputContains(m, "hostnamectl", "Static hostname: core1")
}
8 changes: 1 addition & 7 deletions mantle/kola/tests/ignition/symlink.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@
package ignition

import (
"strings"

"github.com/coreos/mantle/kola/cluster"
"github.com/coreos/mantle/kola/register"
"github.com/coreos/mantle/platform/conf"
Expand Down Expand Up @@ -56,9 +54,5 @@ func init() {
func writeAbsoluteSymlink(c cluster.TestCluster) {
m := c.Machines()[0]

out := c.MustSSH(m, "readlink /etc/localtime")

if strings.Compare(string(out), "/usr/share/zoneinfo/Europe/Zurich") != 0 {
c.Fatalf("write absolute symlink failed:\n%s", out)
}
c.AssertCmdOutputContains(m, "readlink /etc/localtime", "/usr/share/zoneinfo/Europe/Zurich")
}
7 changes: 1 addition & 6 deletions mantle/kola/tests/ignition/systemd.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@
package ignition

import (
"strings"

"github.com/coreos/mantle/kola/cluster"
"github.com/coreos/mantle/kola/register"
"github.com/coreos/mantle/platform/conf"
Expand Down Expand Up @@ -58,8 +56,5 @@ func init() {
func enableSystemdService(c cluster.TestCluster) {
m := c.Machines()[0]

out := c.MustSSH(m, "systemctl status nfs-server.service")
if strings.Contains(string(out), "inactive") {
c.Fatalf("service was not enabled or systemd-presets did not run")
}
c.AssertCmdOutputContains(m, "systemctl status nfs-server.service", "inactive")
}