Skip to content

Commit 90c582b

Browse files
Merge pull request #6081 from ptalgulk01/migrate-mco-layering
MCO-2275: Migrate OS layering tests from openshift-tests-private
2 parents fb5bfe2 + 9fac87e commit 90c582b

5 files changed

Lines changed: 1533 additions & 0 deletions

File tree

test/extended-priv/const.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,10 @@ const (
3939
LayeringBaseImageReleaseInfo = "rhel-coreos"
4040
// LayeringBaseImageReleaseInfoRhel10 is the name of the RHEL10 layering base image in release info
4141
LayeringBaseImageReleaseInfoRhel10 = "rhel-coreos-10"
42+
// CoreExtensionsImageReleaseInfo is the name of the core extensions image in release info
43+
CoreExtensionsImageReleaseInfo = "rhel-coreos-extensions"
44+
// CoreExtensionsImageReleaseInfoRhel10 is the name of the RHEL10 core extensions image in release info
45+
CoreExtensionsImageReleaseInfoRhel10 = "rhel-coreos-10-extensions"
4246
// GenericMCTemplate is the name of a MachineConfig template that can be fully configured by parameters
4347
GenericMCTemplate = "generic-machine-config-template.yml"
4448

test/extended-priv/jsondata.go

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,9 +116,24 @@ func (jd *JSONData) ItemSafe(index int) (*JSONData, error) {
116116
if !ok {
117117
return nil, fmt.Errorf("data is not a list: %v", jd.data)
118118
}
119+
120+
if index < 0 || index >= len(listData) {
121+
return nil, fmt.Errorf("Index %d out of range for list of length %d", index, len(listData))
122+
}
123+
119124
return &JSONData{listData[index]}, nil
120125
}
121126

127+
// Item returns the value of a given item in a list, in case of error it fails the test
128+
func (jd *JSONData) Item(index int) *JSONData {
129+
value, err := jd.ItemSafe(index)
130+
if err != nil {
131+
e2e.Failf("Could not get item [%d]. Error: %v", index, err)
132+
}
133+
134+
return value
135+
}
136+
122137
// Get returns the value of a key in the data, in case of error the returned value is nil
123138
func (jd *JSONData) Get(key string) *JSONData {
124139
value, err := jd.GetSafe(key)

test/extended-priv/machineconfigpool.go

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -851,6 +851,38 @@ func (mcp *MachineConfigPool) waitForPinComplete(timeToWait time.Duration) error
851851
return err
852852
}
853853

854+
// GetReportedOsImageOverrideValue gets the os_image_url_override metric value for this MCP
855+
func (mcp *MachineConfigPool) GetReportedOsImageOverrideValue() (string, error) {
856+
query := fmt.Sprintf(`os_image_url_override{pool="%s"}`, strings.ToLower(mcp.GetName()))
857+
858+
mon, err := exutil.NewMonitor(mcp.oc.AsAdmin())
859+
if err != nil {
860+
return "", err
861+
}
862+
863+
osImageOverride, err := mon.SimpleQuery(query)
864+
if err != nil {
865+
return "", err
866+
}
867+
868+
jsonOsImageOverride := JSON(osImageOverride)
869+
status := jsonOsImageOverride.Get("status").ToString()
870+
if status != "success" {
871+
return "", fmt.Errorf("Query %s execution failed: %s", query, osImageOverride)
872+
}
873+
874+
logger.Infof("%s metric is:%s", query, osImageOverride)
875+
876+
results := jsonOsImageOverride.Get("data").Get("result")
877+
resultList := results.ToList()
878+
if len(resultList) == 0 {
879+
return "", fmt.Errorf("Query %s returned no results", query)
880+
}
881+
882+
metricValue := results.Item(0).Get("value").Item(1).ToString()
883+
return metricValue, nil
884+
}
885+
854886
// RecoverFromDegraded updates the current and desired machine configs so that the pool can recover from degraded state once the offending MC is deleted
855887
func (mcp *MachineConfigPool) RecoverFromDegraded() error {
856888
logger.Infof("Recovering %s pool from degraded status", mcp.GetName())

0 commit comments

Comments
 (0)