Skip to content

Commit 36a61b3

Browse files
committed
Use compat_otp library in extended test cases
1 parent c6faace commit 36a61b3

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+623
-2552
lines changed

cmd/machine-config-tests-ext/main.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import (
99
"github.com/openshift-eng/openshift-tests-extension/pkg/cmd"
1010
v "github.com/openshift-eng/openshift-tests-extension/pkg/version"
1111
"github.com/openshift/machine-config-operator/pkg/version"
12-
exutil "github.com/openshift/machine-config-operator/test/extended/util"
12+
compat_otp "github.com/openshift/origin/test/extended/util/compat_otp"
1313
e2e "k8s.io/kubernetes/test/e2e/framework"
1414

1515
"github.com/spf13/cobra"
@@ -54,14 +54,14 @@ func main() {
5454
Long: "MCO Extended Test Suite (OTE Based)",
5555
}
5656

57-
exutil.InitStandardFlags()
57+
compat_otp.InitStandardFlags()
5858
specs.AddBeforeAll(func() {
59-
if err := exutil.InitTest(false); err != nil {
59+
if err := compat_otp.InitTest(false); err != nil {
6060
panic(err)
6161
}
62-
e2e.AfterReadingAllFlags(exutil.TestContext)
62+
e2e.AfterReadingAllFlags(compat_otp.TestContext)
6363
e2e.TestContext.DumpLogsOnFailure = true
64-
exutil.TestContext.DumpLogsOnFailure = true
64+
compat_otp.TestContext.DumpLogsOnFailure = true
6565
})
6666

6767
root.AddCommand(

go.mod

Lines changed: 135 additions & 40 deletions
Large diffs are not rendered by default.

go.sum

Lines changed: 326 additions & 81 deletions
Large diffs are not rendered by default.

test/extended/assertions.go

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
package extended
2+
3+
import (
4+
"context"
5+
"fmt"
6+
"strings"
7+
"time"
8+
9+
exutil "github.com/openshift/origin/test/extended/util"
10+
compat_otp "github.com/openshift/origin/test/extended/util/compat_otp"
11+
logger "github.com/openshift/origin/test/extended/util/compat_otp/logext"
12+
13+
"k8s.io/apimachinery/pkg/util/wait"
14+
)
15+
16+
// AssertAllPodsToBeReadyWithPollerParams assert all pods in NS are in ready state until timeout in a given namespace
17+
// Pros: allow user to customize poller parameters
18+
func AssertAllPodsToBeReadyWithPollerParams(oc *exutil.CLI, namespace string, interval, timeout time.Duration, selector string) {
19+
err := wait.PollUntilContextTimeout(context.Background(), interval, timeout, false, func(_ context.Context) (bool, error) {
20+
21+
// get the status flag for all pods
22+
// except the ones which are in Complete Status.
23+
// it use 'ne' operator which is only compatible with 4.10+ oc versions
24+
template := "'{{- range .items -}}{{- range .status.conditions -}}{{- if ne .reason \"PodCompleted\" -}}{{- if eq .type \"Ready\" -}}{{- .status}} {{\" \"}}{{- end -}}{{- end -}}{{- end -}}{{- end -}}'"
25+
baseArgs := []string{"pods", "-n", namespace}
26+
if selector != "" {
27+
baseArgs = append(baseArgs, "-l", selector)
28+
}
29+
stdout, err := oc.AsAdmin().Run("get").Args(baseArgs...).Template(template).Output()
30+
if err != nil {
31+
logger.Infof("the err:%v, and try next round", err)
32+
return false, nil
33+
}
34+
if strings.Contains(stdout, "False") {
35+
return false, nil
36+
}
37+
return true, nil
38+
})
39+
compat_otp.AssertWaitPollNoErr(err, fmt.Sprintf("Some Pods are not ready in NS %s!", namespace))
40+
}
41+
42+
// AssertAllPodsToBeReadyWithSelector assert all pods in NS are in ready state until timeout in a given namespace
43+
// The selector parameter follows the regular oc/kubectl format for the --selector option.
44+
func AssertAllPodsToBeReadyWithSelector(oc *exutil.CLI, namespace, selector string) {
45+
AssertAllPodsToBeReadyWithPollerParams(oc, namespace, 10*time.Second, 4*time.Minute, selector)
46+
}

test/extended/boot_image.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ import (
1717
machineclient "github.com/openshift/client-go/machine/clientset/versioned"
1818
machineconfigclient "github.com/openshift/client-go/machineconfiguration/clientset/versioned"
1919
mcopclient "github.com/openshift/client-go/operator/clientset/versioned"
20-
exutil "github.com/openshift/machine-config-operator/test/extended/util"
20+
exutil "github.com/openshift/origin/test/extended/util"
2121

2222
o "github.com/onsi/gomega"
2323

test/extended/boot_image_update_agnostic.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import (
55
"time"
66

77
machineclient "github.com/openshift/client-go/machine/clientset/versioned"
8-
exutil "github.com/openshift/machine-config-operator/test/extended/util"
8+
exutil "github.com/openshift/origin/test/extended/util"
99

1010
o "github.com/onsi/gomega"
1111

test/extended/boot_image_update_azure.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@ import (
1111

1212
g "github.com/onsi/ginkgo/v2"
1313
o "github.com/onsi/gomega"
14-
exutil "github.com/openshift/machine-config-operator/test/extended/util"
14+
exutil "github.com/openshift/origin/test/extended/util"
15+
compat_otp "github.com/openshift/origin/test/extended/util/compat_otp"
1516

1617
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
1718
"k8s.io/kubernetes/test/e2e/framework"
@@ -26,7 +27,7 @@ var _ = g.Describe("[sig-mco][Suite:openshift/machine-config-operator/disruptive
2627
PartialMachineSetFixture = filepath.Join("machineconfigurations", "managedbootimages-partial.yaml")
2728
EmptyMachineSetFixture = filepath.Join("machineconfigurations", "managedbootimages-empty.yaml")
2829

29-
oc = exutil.NewCLI("mco-bootimage", exutil.KubeConfigPath()).AsAdmin()
30+
oc = compat_otp.NewCLI("mco-bootimage", compat_otp.KubeConfigPath()).AsAdmin()
3031
)
3132

3233
g.BeforeEach(func() {

test/extended/configmap.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import (
44
"encoding/json"
55

66
o "github.com/onsi/gomega"
7-
exutil "github.com/openshift/machine-config-operator/test/extended/util"
7+
exutil "github.com/openshift/origin/test/extended/util"
88
)
99

1010
// ConfigMap struct encapsulates the functionalities regarding ocp configmaps

test/extended/containers.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
package extended
22

33
import (
4-
exutil "github.com/openshift/machine-config-operator/test/extended/util"
5-
logger "github.com/openshift/machine-config-operator/test/extended/util/logext"
4+
exutil "github.com/openshift/origin/test/extended/util"
5+
logger "github.com/openshift/origin/test/extended/util/compat_otp/logext"
66
)
77

88
func getImageFromReleaseInfo(oc *exutil.CLI, imageName, dockerConfigFile string) (string, error) {

test/extended/controller.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,9 @@ import (
55
"strings"
66
"time"
77

8-
exutil "github.com/openshift/machine-config-operator/test/extended/util"
9-
logger "github.com/openshift/machine-config-operator/test/extended/util/logext"
8+
exutil "github.com/openshift/origin/test/extended/util"
9+
compat_otp "github.com/openshift/origin/test/extended/util/compat_otp"
10+
logger "github.com/openshift/origin/test/extended/util/compat_otp/logext"
1011
)
1112

1213
// Controller handles the functinalities related to the MCO controller pod
@@ -81,7 +82,7 @@ func (mcc Controller) GetRawLogs() (string, error) {
8182
logger.Errorf("Error getting controller pod name. Error: %s", err)
8283
return "", err
8384
}
84-
podAllLogs, err := exutil.GetSpecificPodLogs(mcc.oc, MachineConfigNamespace, ControllerContainer, cachedPodName, "")
85+
podAllLogs, err := compat_otp.GetSpecificPodLogs(mcc.oc, MachineConfigNamespace, ControllerContainer, cachedPodName, "")
8586
if err != nil {
8687
logger.Errorf("Error getting log lines. Error: %s", err)
8788
return "", err

0 commit comments

Comments
 (0)