Skip to content

Commit c82bcb6

Browse files
cgwaltersjmarrero
authored andcommitted
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 openshift/os#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.
1 parent 3d0c115 commit c82bcb6

File tree

1 file changed

+0
-137
lines changed

1 file changed

+0
-137
lines changed

mantle/kola/tests/ostree/basic.go

-137
Original file line numberDiff line numberDiff line change
@@ -15,32 +15,16 @@
1515
package ostree
1616

1717
import (
18-
"fmt"
1918
"regexp"
2019
"strings"
21-
"time"
2220

2321
"github.com/coreos/coreos-assembler/mantle/kola"
2422
"github.com/coreos/coreos-assembler/mantle/kola/cluster"
2523
"github.com/coreos/coreos-assembler/mantle/kola/register"
26-
"github.com/coreos/coreos-assembler/mantle/kola/tests/util"
2724
"github.com/coreos/coreos-assembler/mantle/platform"
2825
)
2926

30-
// the "basic" test is only supported on 'rhcos' for now because of how
31-
// the refs are defined. if 'fcos' goes in the same direction, we can
32-
// expand support there.
3327
func init() {
34-
register.RegisterTest(&register.Test{
35-
Run: ostreeBasicTest,
36-
ClusterSize: 1,
37-
Name: "ostree.basic",
38-
Description: "Verify the ostree basic functions work.",
39-
Distros: []string{"rhcos"},
40-
FailFast: true,
41-
Tags: []string{"ostree"},
42-
})
43-
4428
register.RegisterTest(&register.Test{
4529
Run: ostreeRemoteTest,
4630
ClusterSize: 1,
@@ -51,12 +35,6 @@ func init() {
5135
})
5236
}
5337

54-
type ostreeAdminStatus struct {
55-
Checksum string
56-
Origin string
57-
Version string
58-
}
59-
6038
// getOstreeRemotes returns the current number of ostree remotes on a machine
6139
func getOstreeRemotes(c cluster.TestCluster, m platform.Machine) (int, []string) {
6240
remoteListOut := string(c.MustSSH(m, "ostree remote list"))
@@ -71,121 +49,6 @@ func getOstreeRemotes(c cluster.TestCluster, m platform.Machine) (int, []string)
7149
return numRemotes, remoteListRaw
7250
}
7351

74-
// getOstreeAdminStatus stuffs the important output of `ostree admin status`
75-
// into an `ostreeAdminStatus` struct
76-
func getOstreeAdminStatus(c cluster.TestCluster, m platform.Machine) (ostreeAdminStatus, error) {
77-
oaStatus := ostreeAdminStatus{}
78-
79-
oasOutput, err := c.SSH(m, "ostree admin status")
80-
if err != nil {
81-
return oaStatus, fmt.Errorf(`Could not get "ostree admin status": %v`, err)
82-
}
83-
84-
oasSplit := strings.Split(string(oasOutput), "\n")
85-
if len(oasSplit) < 3 {
86-
return oaStatus, fmt.Errorf(`Unexpected output from "ostree admin status": %v`, string(oasOutput))
87-
}
88-
89-
// we use a bunch of regexps to find the content in each line of output
90-
// from "ostree admin status". the `match` for each line sticks the
91-
// captured group as the last element of the array; that is used as the
92-
// value for each field of the struct
93-
reCsum, _ := regexp.Compile(`^\* [\w\-]+ ([0-9a-f]+)\.\d`)
94-
csumMatch := reCsum.FindStringSubmatch(oasSplit[0])
95-
if csumMatch == nil {
96-
return oaStatus, fmt.Errorf(`Could not parse first line from "ostree admin status": %q`, oasSplit[0])
97-
}
98-
oaStatus.Checksum = csumMatch[len(csumMatch)-1]
99-
100-
reVersion, _ := regexp.Compile(`^Version: (.*)`)
101-
versionMatch := reVersion.FindStringSubmatch(strings.TrimSpace(oasSplit[1]))
102-
if versionMatch == nil {
103-
return oaStatus, fmt.Errorf(`Could not parse second line from "ostree admin status": %q`, oasSplit[1])
104-
}
105-
oaStatus.Version = versionMatch[len(versionMatch)-1]
106-
107-
reOrigin, _ := regexp.Compile(`^origin refspec: (.*)`)
108-
originMatch := reOrigin.FindStringSubmatch(strings.TrimSpace(oasSplit[2]))
109-
if originMatch == nil {
110-
return oaStatus, fmt.Errorf(`Could not parse third line from "ostree admin status": %q`, oasSplit[2])
111-
}
112-
oaStatus.Origin = originMatch[len(originMatch)-1]
113-
114-
return oaStatus, nil
115-
}
116-
117-
// ostreeBasicTest performs sanity checks on the output from `ostree admin status`,
118-
// `ostree rev-parse`, and `ostree show` by comparing to the output from `rpm-ostree status`
119-
func ostreeBasicTest(c cluster.TestCluster) {
120-
m := c.Machines()[0]
121-
122-
ros, err := util.GetRpmOstreeStatusJSON(c, m)
123-
if err != nil {
124-
c.Fatal(err)
125-
}
126-
127-
oas, err := getOstreeAdminStatus(c, m)
128-
if err != nil {
129-
c.Fatal(err)
130-
}
131-
132-
if len(ros.Deployments) < 1 {
133-
c.Fatalf(`Did not find any deployments?!`)
134-
}
135-
136-
// verify the output from `ostree admin status`
137-
c.RunLogged("admin status", func(c cluster.TestCluster) {
138-
if oas.Checksum != ros.Deployments[0].Checksum {
139-
c.Fatalf(`Checksums do not match; expected %q, got %q`, ros.Deployments[0].Checksum, oas.Checksum)
140-
}
141-
if oas.Version != ros.Deployments[0].Version {
142-
c.Fatalf(`Versions do not match; expected %q, got %q`, ros.Deployments[0].Version, oas.Version)
143-
}
144-
if oas.Origin != ros.Deployments[0].Origin {
145-
c.Fatalf(`Origins do not match; expected %q, got %q`, ros.Deployments[0].Origin, oas.Origin)
146-
}
147-
})
148-
149-
// verify the output from `ostree rev-parse`
150-
// this is kind of moot since the origin for RHCOS is just
151-
// the checksum now
152-
c.RunLogged("rev-parse", func(c cluster.TestCluster) {
153-
// check the output of `ostree rev-parse`
154-
c.AssertCmdOutputContains(m, ("ostree rev-parse " + oas.Origin), oas.Checksum)
155-
})
156-
157-
// verify the output of 'ostree show'
158-
c.RunLogged("show", func(c cluster.TestCluster) {
159-
oShowOut := c.MustSSH(m, ("ostree show " + oas.Checksum))
160-
oShowOutSplit := strings.Split(string(oShowOut), "\n")
161-
// we need at least the first 4 lines (commit, ContentChecksum, Date, Version)
162-
// to proceed safely
163-
if len(oShowOutSplit) < 4 {
164-
c.Fatalf(`Unexpected output from "ostree show": %q`, string(oShowOut))
165-
}
166-
167-
// convert the 'timestamp' from `rpm-ostree status` into a date that
168-
// we can compare to the date in `ostree admin status`
169-
// also, wtf is up with formatting date/time in golang?!
170-
timeFormat := "2006-01-02 15:04:05 +0000"
171-
tsUnix := time.Unix(ros.Deployments[0].Timestamp, 0).UTC()
172-
tsFormatted := tsUnix.Format(timeFormat)
173-
oShowDate := strings.TrimPrefix(oShowOutSplit[2], "Date: ")
174-
175-
if oShowDate != tsFormatted {
176-
c.Fatalf(`Dates do not match; expected %q, got %q`, tsFormatted, oShowDate)
177-
}
178-
179-
oVersionSplit := strings.Fields(oShowOutSplit[3])
180-
if len(oVersionSplit) < 2 {
181-
c.Fatalf(`Unexpected content in "Version" field of "ostree show" output: %q`, oShowOutSplit[3])
182-
}
183-
if oVersionSplit[1] != ros.Deployments[0].Version {
184-
c.Fatalf(`Versions do not match; expected %q, got %q`, ros.Deployments[0].Version, oVersionSplit[1])
185-
}
186-
})
187-
}
188-
18952
// ostreeRemoteTest verifies the `ostree remote` functionality;
19053
// specifically: `add`, `delete`, `list`, `refs`, `show-url`, `summary`
19154
func ostreeRemoteTest(c cluster.TestCluster) {

0 commit comments

Comments
 (0)