Skip to content
Open
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: 6 additions & 4 deletions cmd/machine-config-tests-ext/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ import (
"github.com/openshift-eng/openshift-tests-extension/pkg/cmd"
v "github.com/openshift-eng/openshift-tests-extension/pkg/version"
"github.com/openshift/machine-config-operator/pkg/version"
exutil "github.com/openshift/machine-config-operator/test/extended/util"
exutil "github.com/openshift/origin/test/extended/util"
compat_otp "github.com/openshift/origin/test/extended/util/compat_otp"
e2e "k8s.io/kubernetes/test/e2e/framework"

"github.com/spf13/cobra"
Expand Down Expand Up @@ -54,14 +55,15 @@ func main() {
Long: "MCO Extended Test Suite (OTE Based)",
}

exutil.InitStandardFlags()
exutil.WithCleanup(func() {})
compat_otp.InitStandardFlags()
specs.AddBeforeAll(func() {
if err := exutil.InitTest(false); err != nil {
panic(err)
}
e2e.AfterReadingAllFlags(exutil.TestContext)
e2e.AfterReadingAllFlags(compat_otp.TestContext)
e2e.TestContext.DumpLogsOnFailure = true
exutil.TestContext.DumpLogsOnFailure = true
compat_otp.TestContext.DumpLogsOnFailure = true
})

root.AddCommand(
Expand Down
256 changes: 178 additions & 78 deletions go.mod

Large diffs are not rendered by default.

510 changes: 378 additions & 132 deletions go.sum

Large diffs are not rendered by default.

46 changes: 46 additions & 0 deletions test/extended/assertions.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
package extended

import (
"context"
"fmt"
"strings"
"time"

exutil "github.com/openshift/origin/test/extended/util"
compat_otp "github.com/openshift/origin/test/extended/util/compat_otp"
logger "github.com/openshift/origin/test/extended/util/compat_otp/logext"

"k8s.io/apimachinery/pkg/util/wait"
)

// AssertAllPodsToBeReadyWithPollerParams assert all pods in NS are in ready state until timeout in a given namespace
// Pros: allow user to customize poller parameters
func AssertAllPodsToBeReadyWithPollerParams(oc *exutil.CLI, namespace string, interval, timeout time.Duration, selector string) {
err := wait.PollUntilContextTimeout(context.Background(), interval, timeout, false, func(_ context.Context) (bool, error) {

// get the status flag for all pods
// except the ones which are in Complete Status.
// it use 'ne' operator which is only compatible with 4.10+ oc versions
template := "'{{- range .items -}}{{- range .status.conditions -}}{{- if ne .reason \"PodCompleted\" -}}{{- if eq .type \"Ready\" -}}{{- .status}} {{\" \"}}{{- end -}}{{- end -}}{{- end -}}{{- end -}}'"
baseArgs := []string{"pods", "-n", namespace}
if selector != "" {
baseArgs = append(baseArgs, "-l", selector)
}
stdout, err := oc.AsAdmin().Run("get").Args(baseArgs...).Template(template).Output()
if err != nil {
logger.Infof("the err:%v, and try next round", err)
return false, nil
}
if strings.Contains(stdout, "False") {
return false, nil
}
return true, nil
})
compat_otp.AssertWaitPollNoErr(err, fmt.Sprintf("Some Pods are not ready in NS %s!", namespace))
}

// AssertAllPodsToBeReadyWithSelector assert all pods in NS are in ready state until timeout in a given namespace
// The selector parameter follows the regular oc/kubectl format for the --selector option.
func AssertAllPodsToBeReadyWithSelector(oc *exutil.CLI, namespace, selector string) {
AssertAllPodsToBeReadyWithPollerParams(oc, namespace, 10*time.Second, 4*time.Minute, selector)
}
2 changes: 1 addition & 1 deletion test/extended/boot_image.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import (
machineclient "github.com/openshift/client-go/machine/clientset/versioned"
machineconfigclient "github.com/openshift/client-go/machineconfiguration/clientset/versioned"
mcopclient "github.com/openshift/client-go/operator/clientset/versioned"
exutil "github.com/openshift/machine-config-operator/test/extended/util"
exutil "github.com/openshift/origin/test/extended/util"

o "github.com/onsi/gomega"

Expand Down
2 changes: 1 addition & 1 deletion test/extended/boot_image_update_agnostic.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"time"

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

o "github.com/onsi/gomega"

Expand Down
5 changes: 3 additions & 2 deletions test/extended/boot_image_update_azure.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ import (

g "github.com/onsi/ginkgo/v2"
o "github.com/onsi/gomega"
exutil "github.com/openshift/machine-config-operator/test/extended/util"
exutil "github.com/openshift/origin/test/extended/util"
compat_otp "github.com/openshift/origin/test/extended/util/compat_otp"

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

oc = exutil.NewCLI("mco-bootimage", exutil.KubeConfigPath()).AsAdmin()
oc = compat_otp.NewCLI("mco-bootimage", compat_otp.KubeConfigPath()).AsAdmin()
)

g.BeforeEach(func() {
Expand Down
2 changes: 1 addition & 1 deletion test/extended/configmap.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"encoding/json"

o "github.com/onsi/gomega"
exutil "github.com/openshift/machine-config-operator/test/extended/util"
exutil "github.com/openshift/origin/test/extended/util"
)

// ConfigMap struct encapsulates the functionalities regarding ocp configmaps
Expand Down
4 changes: 2 additions & 2 deletions test/extended/containers.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package extended

import (
exutil "github.com/openshift/machine-config-operator/test/extended/util"
logger "github.com/openshift/machine-config-operator/test/extended/util/logext"
exutil "github.com/openshift/origin/test/extended/util"
logger "github.com/openshift/origin/test/extended/util/compat_otp/logext"
)

func getImageFromReleaseInfo(oc *exutil.CLI, imageName, dockerConfigFile string) (string, error) {
Expand Down
7 changes: 4 additions & 3 deletions test/extended/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@ import (
"strings"
"time"

exutil "github.com/openshift/machine-config-operator/test/extended/util"
logger "github.com/openshift/machine-config-operator/test/extended/util/logext"
exutil "github.com/openshift/origin/test/extended/util"
compat_otp "github.com/openshift/origin/test/extended/util/compat_otp"
logger "github.com/openshift/origin/test/extended/util/compat_otp/logext"
)

// Controller handles the functinalities related to the MCO controller pod
Expand Down Expand Up @@ -81,7 +82,7 @@ func (mcc Controller) GetRawLogs() (string, error) {
logger.Errorf("Error getting controller pod name. Error: %s", err)
return "", err
}
podAllLogs, err := exutil.GetSpecificPodLogs(mcc.oc, MachineConfigNamespace, ControllerContainer, cachedPodName, "")
podAllLogs, err := compat_otp.GetSpecificPodLogs(mcc.oc, MachineConfigNamespace, ControllerContainer, cachedPodName, "")
if err != nil {
logger.Errorf("Error getting log lines. Error: %s", err)
return "", err
Expand Down
8 changes: 4 additions & 4 deletions test/extended/generic_behaviour_validation.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import (

o "github.com/onsi/gomega"
"github.com/onsi/gomega/types"
exutil "github.com/openshift/machine-config-operator/test/extended/util"
logger "github.com/openshift/machine-config-operator/test/extended/util/logext"
compat_otp "github.com/openshift/origin/test/extended/util/compat_otp"
logger "github.com/openshift/origin/test/extended/util/compat_otp/logext"
)

type Checker interface {
Expand All @@ -25,7 +25,7 @@ func (cOutChecker CommandOutputChecker) Check(checkedNodes ...Node) {
if cOutChecker.Desc != "" {
msg = cOutChecker.Desc
}
exutil.By(msg)
compat_otp.By(msg)
o.Expect(checkedNodes).NotTo(o.BeEmpty(), "Refuse to check an empty list of nodes")

for _, node := range checkedNodes {
Expand All @@ -51,7 +51,7 @@ func (rfc RemoteFileChecker) Check(checkedNodes ...Node) {
if rfc.Desc != "" {
msg = rfc.Desc
}
exutil.By(msg)
compat_otp.By(msg)
o.Expect(checkedNodes).NotTo(o.BeEmpty(), "Refuse to check an empty list of nodes")

for _, node := range checkedNodes {
Expand Down
2 changes: 1 addition & 1 deletion test/extended/gomega_matchers.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"encoding/json"
"fmt"

logger "github.com/openshift/machine-config-operator/test/extended/util/logext"
logger "github.com/openshift/origin/test/extended/util/compat_otp/logext"

g "github.com/onsi/ginkgo/v2"
gomegamatchers "github.com/onsi/gomega/matchers"
Expand Down
2 changes: 1 addition & 1 deletion test/extended/jsondata.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"fmt"
"strings"

logger "github.com/openshift/machine-config-operator/test/extended/util/logext"
logger "github.com/openshift/origin/test/extended/util/compat_otp/logext"

e2e "k8s.io/kubernetes/test/e2e/framework"
)
Expand Down
9 changes: 5 additions & 4 deletions test/extended/machineconfig.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,9 @@ import (
"strings"
"time"

exutil "github.com/openshift/machine-config-operator/test/extended/util"
logger "github.com/openshift/machine-config-operator/test/extended/util/logext"
exutil "github.com/openshift/origin/test/extended/util"
compat_otp "github.com/openshift/origin/test/extended/util/compat_otp"
logger "github.com/openshift/origin/test/extended/util/compat_otp/logext"

"k8s.io/apimachinery/pkg/util/wait"
)
Expand Down Expand Up @@ -39,7 +40,7 @@ func (mc *MachineConfig) SetTemplate(template Template) *MachineConfig {
}

func (mc *MachineConfig) create() {
mc.name = mc.name + "-" + exutil.GetRandomString()
mc.name = mc.name + "-" + compat_otp.GetRandomString()
params := []string{"-p", "NAME=" + mc.name, "POOL=" + mc.pool}
params = append(params, mc.parameters...)
mc.Create(params...)
Expand All @@ -56,7 +57,7 @@ func (mc *MachineConfig) create() {
}
return false, nil
})
exutil.AssertWaitPollNoErr(pollerr, fmt.Sprintf("create machine config %v failed", mc.name))
compat_otp.AssertWaitPollNoErr(pollerr, fmt.Sprintf("create machine config %v failed", mc.name))

if !mc.skipWaitForMcp {
mcp := NewMachineConfigPool(mc.oc, mc.pool)
Expand Down
2 changes: 1 addition & 1 deletion test/extended/machineconfignode.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package extended

import (
exutil "github.com/openshift/machine-config-operator/test/extended/util"
exutil "github.com/openshift/origin/test/extended/util"
)

// MachineConfigNode resource type declaration
Expand Down
7 changes: 4 additions & 3 deletions test/extended/machineconfigpool.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,9 @@ import (

g "github.com/onsi/ginkgo/v2"
o "github.com/onsi/gomega"
exutil "github.com/openshift/machine-config-operator/test/extended/util"
logger "github.com/openshift/machine-config-operator/test/extended/util/logext"
exutil "github.com/openshift/origin/test/extended/util"
compat_otp "github.com/openshift/origin/test/extended/util/compat_otp"
logger "github.com/openshift/origin/test/extended/util/compat_otp/logext"
"k8s.io/apimachinery/pkg/util/wait"
e2e "k8s.io/kubernetes/test/e2e/framework"
)
Expand Down Expand Up @@ -52,7 +53,7 @@ func NewMachineConfigPoolList(oc *exutil.CLI) *MachineConfigPoolList {
// String implements the Stringer interface

func (mcp *MachineConfigPool) create() {
exutil.CreateClusterResourceFromTemplate(mcp.oc, "--ignore-unknown-parameters=true", "-f", mcp.template, "-p", "NAME="+mcp.name)
compat_otp.CreateClusterResourceFromTemplate(mcp.oc, "--ignore-unknown-parameters=true", "-f", mcp.template, "-p", "NAME="+mcp.name)
mcp.waitForComplete()
}

Expand Down
2 changes: 1 addition & 1 deletion test/extended/machineosbuild.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package extended
import (
"fmt"

exutil "github.com/openshift/machine-config-operator/test/extended/util"
exutil "github.com/openshift/origin/test/extended/util"
)

// MachineOSBuild resource type declaration
Expand Down
15 changes: 8 additions & 7 deletions test/extended/machineosconfig.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,9 @@ import (

g "github.com/onsi/ginkgo/v2"
o "github.com/onsi/gomega"
exutil "github.com/openshift/machine-config-operator/test/extended/util"
logger "github.com/openshift/machine-config-operator/test/extended/util/logext"
exutil "github.com/openshift/origin/test/extended/util"
compat_otp "github.com/openshift/origin/test/extended/util/compat_otp"
logger "github.com/openshift/origin/test/extended/util/compat_otp/logext"
"github.com/tidwall/sjson"
)

Expand Down Expand Up @@ -106,7 +107,7 @@ func CopySecretToMCONamespace(secret *Secret, newName string) (*Secret, error) {
func CreateMachineOSConfigUsingInternalRegistry(oc *exutil.CLI, namespace, moscAndMcpName string, containerFile []ContainerFile, defaultPullSecret bool) (*MachineOSConfig, error) {

// We use the builder SA secret in the namespace to push the images to the internal registry
renderedImagePushSecret, err := CreateInternalRegistrySecretFromSA(oc, "builder", namespace, "cloned-push-secret"+exutil.GetRandomString(), MachineConfigNamespace)
renderedImagePushSecret, err := CreateInternalRegistrySecretFromSA(oc, "builder", namespace, "cloned-push-secret"+compat_otp.GetRandomString(), MachineConfigNamespace)
if err != nil {
return NewMachineOSConfig(oc, moscAndMcpName), err
}
Expand All @@ -118,7 +119,7 @@ func CreateMachineOSConfigUsingInternalRegistry(oc *exutil.CLI, namespace, moscA

// TODO: HERE WE NEED TO ADD THE NAMESPACE PULL SECRET TO THE CLUSTER'S PULL-SECRET SO THAT WE CAN PULL THE RESULTING IMAGE STORED IN A DIFFERENT NAMESPACE THAN MCO
// We use the default SA secret in MCO to pull the current image from the internal registry
namespacedPullSecret, err := CreateInternalRegistrySecretFromSA(oc, "default", namespace, "cloned-currentpull-secret"+exutil.GetRandomString(), namespace)
namespacedPullSecret, err := CreateInternalRegistrySecretFromSA(oc, "default", namespace, "cloned-currentpull-secret"+compat_otp.GetRandomString(), namespace)
if err != nil {
return NewMachineOSConfig(oc, moscAndMcpName), err
}
Expand Down Expand Up @@ -157,7 +158,7 @@ func CreateMachineOSConfigUsingInternalRegistry(oc *exutil.CLI, namespace, moscA
if !defaultPullSecret {
// We use a copy of the cluster's pull secret to pull the images
pullSecret := NewSecret(oc.AsAdmin(), "openshift-config", "pull-secret")
baseImagePullSecret, err := CopySecretToMCONamespace(pullSecret, "cloned-basepull-secret-"+exutil.GetRandomString())
baseImagePullSecret, err := CopySecretToMCONamespace(pullSecret, "cloned-basepull-secret-"+compat_otp.GetRandomString())
if err != nil {
return NewMachineOSConfig(oc, moscAndMcpName), err
}
Expand All @@ -173,12 +174,12 @@ func CreateMachineOSConfigUsingExternalRegistry(oc *exutil.CLI, moscAndMcpName s
// We use a copy of the cluster's pull secret to pull the images
pullSecret = NewSecret(oc.AsAdmin(), "openshift-config", "pull-secret")
)
copyPullSecret, err := CopySecretToMCONamespace(pullSecret, "cloned-pull-secret-"+exutil.GetRandomString())
copyPullSecret, err := CopySecretToMCONamespace(pullSecret, "cloned-pull-secret-"+compat_otp.GetRandomString())
if err != nil {
return NewMachineOSConfig(oc, moscAndMcpName), err
}

clusterName, err := exutil.GetInfraID(oc)
clusterName, err := compat_otp.GetInfraID(oc)
if err != nil {
return NewMachineOSConfig(oc, moscAndMcpName), err
}
Expand Down
10 changes: 5 additions & 5 deletions test/extended/mco.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ package extended

import (
o "github.com/onsi/gomega"
exutil "github.com/openshift/machine-config-operator/test/extended/util"
logger "github.com/openshift/machine-config-operator/test/extended/util/logext"
compat_otp "github.com/openshift/origin/test/extended/util/compat_otp"
logger "github.com/openshift/origin/test/extended/util/compat_otp/logext"
)

func checkDegraded(mcp *MachineConfigPool, expectedMessage, expectedReason, degradedConditionType string, checkCODegraded bool, offset int) {
Expand All @@ -13,15 +13,15 @@ func checkDegraded(mcp *MachineConfigPool, expectedMessage, expectedReason, degr
expectedNumDegradedMachines = 1
}

exutil.By("Wait until MCP becomes degraded")
compat_otp.By("Wait until MCP becomes degraded")
o.EventuallyWithOffset(offset, mcp, mcp.estimateWaitDuration().String(), "30s").Should(BeDegraded(),
"The '%s' MCP should become degraded when we try to create an invalid MC, but it didn't.", mcp.GetName())
o.EventuallyWithOffset(offset, mcp.getDegradedMachineCount, "5m", "30s").Should(o.Equal(expectedNumDegradedMachines),
"The '%s' MCP should report '%d' degraded machine count, but it doesn't.", expectedNumDegradedMachines, mcp.GetName())

logger.Infof("OK!\n")

exutil.By("Validate the reported error")
compat_otp.By("Validate the reported error")
degradedCondition := mcp.GetConditionByType(degradedConditionType)

o.ExpectWithOffset(offset, mcp).Should(HaveConditionField(degradedConditionType, "status", o.Equal("True")),
Expand All @@ -34,7 +34,7 @@ func checkDegraded(mcp *MachineConfigPool, expectedMessage, expectedReason, degr
"'worker' MCP is not reporting the expected reason in the NodeDegraded condition: %s", degradedConditionType, degradedCondition)
logger.Infof("OK!\n")

exutil.By("Get co machine config to verify status and reason for Upgradeable type")
compat_otp.By("Get co machine config to verify status and reason for Upgradeable type")

// If the pool is degraded, then co/machine-config should not be upgradeable
// It's unlikely, but it can happen that the MCP is degraded, but the CO has not been already updated with the right error message.
Expand Down
Loading