From c82bcb641ebac1263efc73e204e262c993aadb53 Mon Sep 17 00:00:00 2001 From: Colin Walters Date: Mon, 21 Aug 2023 14:28:23 -0400 Subject: [PATCH] tests: Drop `ostree.basic` This test was trying to cross-check `ostree admin status` and `rpm-ostree status` which is well-intentioned but parsing the former with regexps is just not sustainable and actively broke with trying to switch to a container deployment in https://github.com/openshift/os/pull/657 I don't think this check is really worth maintaining; if we somehow broke `ostree admin status` a whole lot of other upstream tests would start failing. --- mantle/kola/tests/ostree/basic.go | 137 ------------------------------ 1 file changed, 137 deletions(-) diff --git a/mantle/kola/tests/ostree/basic.go b/mantle/kola/tests/ostree/basic.go index 5430484cf4..22aa088493 100644 --- a/mantle/kola/tests/ostree/basic.go +++ b/mantle/kola/tests/ostree/basic.go @@ -15,32 +15,16 @@ package ostree import ( - "fmt" "regexp" "strings" - "time" "github.com/coreos/coreos-assembler/mantle/kola" "github.com/coreos/coreos-assembler/mantle/kola/cluster" "github.com/coreos/coreos-assembler/mantle/kola/register" - "github.com/coreos/coreos-assembler/mantle/kola/tests/util" "github.com/coreos/coreos-assembler/mantle/platform" ) -// the "basic" test is only supported on 'rhcos' for now because of how -// the refs are defined. if 'fcos' goes in the same direction, we can -// expand support there. func init() { - register.RegisterTest(®ister.Test{ - Run: ostreeBasicTest, - ClusterSize: 1, - Name: "ostree.basic", - Description: "Verify the ostree basic functions work.", - Distros: []string{"rhcos"}, - FailFast: true, - Tags: []string{"ostree"}, - }) - register.RegisterTest(®ister.Test{ Run: ostreeRemoteTest, ClusterSize: 1, @@ -51,12 +35,6 @@ func init() { }) } -type ostreeAdminStatus struct { - Checksum string - Origin string - Version string -} - // getOstreeRemotes returns the current number of ostree remotes on a machine func getOstreeRemotes(c cluster.TestCluster, m platform.Machine) (int, []string) { remoteListOut := string(c.MustSSH(m, "ostree remote list")) @@ -71,121 +49,6 @@ func getOstreeRemotes(c cluster.TestCluster, m platform.Machine) (int, []string) return numRemotes, remoteListRaw } -// getOstreeAdminStatus stuffs the important output of `ostree admin status` -// into an `ostreeAdminStatus` struct -func getOstreeAdminStatus(c cluster.TestCluster, m platform.Machine) (ostreeAdminStatus, error) { - oaStatus := ostreeAdminStatus{} - - oasOutput, err := c.SSH(m, "ostree admin status") - if err != nil { - return oaStatus, fmt.Errorf(`Could not get "ostree admin status": %v`, err) - } - - oasSplit := strings.Split(string(oasOutput), "\n") - if len(oasSplit) < 3 { - return oaStatus, fmt.Errorf(`Unexpected output from "ostree admin status": %v`, string(oasOutput)) - } - - // we use a bunch of regexps to find the content in each line of output - // from "ostree admin status". the `match` for each line sticks the - // captured group as the last element of the array; that is used as the - // value for each field of the struct - reCsum, _ := regexp.Compile(`^\* [\w\-]+ ([0-9a-f]+)\.\d`) - csumMatch := reCsum.FindStringSubmatch(oasSplit[0]) - if csumMatch == nil { - return oaStatus, fmt.Errorf(`Could not parse first line from "ostree admin status": %q`, oasSplit[0]) - } - oaStatus.Checksum = csumMatch[len(csumMatch)-1] - - reVersion, _ := regexp.Compile(`^Version: (.*)`) - versionMatch := reVersion.FindStringSubmatch(strings.TrimSpace(oasSplit[1])) - if versionMatch == nil { - return oaStatus, fmt.Errorf(`Could not parse second line from "ostree admin status": %q`, oasSplit[1]) - } - oaStatus.Version = versionMatch[len(versionMatch)-1] - - reOrigin, _ := regexp.Compile(`^origin refspec: (.*)`) - originMatch := reOrigin.FindStringSubmatch(strings.TrimSpace(oasSplit[2])) - if originMatch == nil { - return oaStatus, fmt.Errorf(`Could not parse third line from "ostree admin status": %q`, oasSplit[2]) - } - oaStatus.Origin = originMatch[len(originMatch)-1] - - return oaStatus, nil -} - -// ostreeBasicTest performs sanity checks on the output from `ostree admin status`, -// `ostree rev-parse`, and `ostree show` by comparing to the output from `rpm-ostree status` -func ostreeBasicTest(c cluster.TestCluster) { - m := c.Machines()[0] - - ros, err := util.GetRpmOstreeStatusJSON(c, m) - if err != nil { - c.Fatal(err) - } - - oas, err := getOstreeAdminStatus(c, m) - if err != nil { - c.Fatal(err) - } - - if len(ros.Deployments) < 1 { - c.Fatalf(`Did not find any deployments?!`) - } - - // verify the output from `ostree admin status` - c.RunLogged("admin status", func(c cluster.TestCluster) { - if oas.Checksum != ros.Deployments[0].Checksum { - c.Fatalf(`Checksums do not match; expected %q, got %q`, ros.Deployments[0].Checksum, oas.Checksum) - } - if oas.Version != ros.Deployments[0].Version { - c.Fatalf(`Versions do not match; expected %q, got %q`, ros.Deployments[0].Version, oas.Version) - } - if oas.Origin != ros.Deployments[0].Origin { - c.Fatalf(`Origins do not match; expected %q, got %q`, ros.Deployments[0].Origin, oas.Origin) - } - }) - - // verify the output from `ostree rev-parse` - // this is kind of moot since the origin for RHCOS is just - // the checksum now - c.RunLogged("rev-parse", func(c cluster.TestCluster) { - // check the output of `ostree rev-parse` - c.AssertCmdOutputContains(m, ("ostree rev-parse " + oas.Origin), oas.Checksum) - }) - - // verify the output of 'ostree show' - c.RunLogged("show", func(c cluster.TestCluster) { - oShowOut := c.MustSSH(m, ("ostree show " + oas.Checksum)) - oShowOutSplit := strings.Split(string(oShowOut), "\n") - // we need at least the first 4 lines (commit, ContentChecksum, Date, Version) - // to proceed safely - if len(oShowOutSplit) < 4 { - c.Fatalf(`Unexpected output from "ostree show": %q`, string(oShowOut)) - } - - // convert the 'timestamp' from `rpm-ostree status` into a date that - // we can compare to the date in `ostree admin status` - // also, wtf is up with formatting date/time in golang?! - timeFormat := "2006-01-02 15:04:05 +0000" - tsUnix := time.Unix(ros.Deployments[0].Timestamp, 0).UTC() - tsFormatted := tsUnix.Format(timeFormat) - oShowDate := strings.TrimPrefix(oShowOutSplit[2], "Date: ") - - if oShowDate != tsFormatted { - c.Fatalf(`Dates do not match; expected %q, got %q`, tsFormatted, oShowDate) - } - - oVersionSplit := strings.Fields(oShowOutSplit[3]) - if len(oVersionSplit) < 2 { - c.Fatalf(`Unexpected content in "Version" field of "ostree show" output: %q`, oShowOutSplit[3]) - } - if oVersionSplit[1] != ros.Deployments[0].Version { - c.Fatalf(`Versions do not match; expected %q, got %q`, ros.Deployments[0].Version, oVersionSplit[1]) - } - }) -} - // ostreeRemoteTest verifies the `ostree remote` functionality; // specifically: `add`, `delete`, `list`, `refs`, `show-url`, `summary` func ostreeRemoteTest(c cluster.TestCluster) {