Skip to content

Commit

Permalink
vCore: keda test suite (#63)
Browse files Browse the repository at this point in the history
* vcore:keda test suite

* bump vendors
  • Loading branch information
elenagerman authored Jun 22, 2024
1 parent 90b294a commit d0ade6d
Show file tree
Hide file tree
Showing 29 changed files with 2,344 additions and 452 deletions.
8 changes: 4 additions & 4 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ require (
github.com/nmstate/kubernetes-nmstate/api v0.0.0-20240605150941-df565dd7bf35
github.com/onsi/ginkgo/v2 v2.19.0
github.com/onsi/gomega v1.33.1
github.com/openshift-kni/eco-goinfra v0.0.0-20240620154035-1f702e37c052 // release-4.15
github.com/openshift-kni/eco-goinfra v0.0.0-20240621192821-7c55fda74f32 // release-4.15
github.com/openshift-kni/k8sreporter v1.0.5
github.com/openshift/api v3.9.1-0.20191111211345-a27ff30ebf09+incompatible
github.com/openshift/assisted-service/api v0.0.0
Expand All @@ -41,10 +41,13 @@ require (
)

require (
github.com/kedacore/keda-olm-operator v0.0.0-20240501182040-762f6be5a942
github.com/kedacore/keda/v2 v2.14.0
github.com/openshift-kni/lifecycle-agent v0.0.0-20240606123201-0c45cd13c2f1
github.com/openshift/client-go v0.0.1
github.com/openshift/installer v0.0.0-00010101000000-000000000000
github.com/povsister/scp v0.0.0-20210427074412-33febfd9f13e
github.com/prometheus-operator/prometheus-operator/pkg/apis/monitoring v0.73.2
github.com/stretchr/testify v1.9.0
github.com/vmware-tanzu/velero v1.13.2
k8s.io/utils v0.0.0-20240310230437-4693a0247e57
Expand All @@ -63,16 +66,13 @@ require (
github.com/golang-collections/collections v0.0.0-20130729185459-604e922904d3 // indirect
github.com/gorilla/websocket v1.5.1 // indirect
github.com/kdomanski/iso9660 v0.2.1 // indirect
github.com/kedacore/keda-olm-operator v0.0.0-20240501182040-762f6be5a942 // indirect
github.com/kedacore/keda/v2 v2.14.0 // indirect
github.com/lib/pq v1.10.9 // indirect
github.com/metal3-io/baremetal-operator/pkg/hardwareutils v0.5.1 // indirect
github.com/mxk/go-flowrate v0.0.0-20140419014527-cca7078d478f // indirect
github.com/nutanix-cloud-native/prism-go-client v0.2.1-0.20220804130801-c8a253627c64 // indirect
github.com/openshift-kni/numaresources-operator v0.4.16-0rc0 // indirect
github.com/openshift/cluster-logging-operator v0.0.0-20240606085930-750f369019d4 // indirect
github.com/openshift/elasticsearch-operator v0.0.0-20220613183908-e1648e67c298 // indirect
github.com/prometheus-operator/prometheus-operator/pkg/apis/monitoring v0.73.2 // indirect
github.com/stmcginnis/gofish v0.15.1-0.20231121142100-22a60a77be91 // indirect
github.com/stolostron/cluster-lifecycle-api v0.0.0-20240109072430-f5fe6043d1f8 // indirect
github.com/stolostron/klusterlet-addon-controller v0.0.0-20240606130554-01338045271a // indirect
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -1691,8 +1691,8 @@ github.com/opencontainers/runtime-spec v1.2.0 h1:z97+pHb3uELt/yiAWD691HNHQIF07bE
github.com/opencontainers/runtime-spec v1.2.0/go.mod h1:jwyrGlmzljRJv/Fgzds9SsS/C5hL+LL3ko9hs6T5lQ0=
github.com/openshift-kni/cluster-group-upgrades-operator v0.0.0-20240423171335-f07cdbf8af2c h1:wAPCXsnAXOUAJ5DYlVgGUcV9YBSiVlH4o9tbQ9py8ZY=
github.com/openshift-kni/cluster-group-upgrades-operator v0.0.0-20240423171335-f07cdbf8af2c/go.mod h1:hkzqKpmQvh7vgPx8Hw6IExJorKPM0dEeJdOXjIW3gNw=
github.com/openshift-kni/eco-goinfra v0.0.0-20240620154035-1f702e37c052 h1:OHLKRTDEtuRkHeUmmKFRcJkVDQ4JdNsBsJGfqs7Ix1Q=
github.com/openshift-kni/eco-goinfra v0.0.0-20240620154035-1f702e37c052/go.mod h1:oGFnQMzZ/bqtnjdh9Rx44NzsMGWaZXgyQsoS0Q7faJ8=
github.com/openshift-kni/eco-goinfra v0.0.0-20240621192821-7c55fda74f32 h1:mLsBeu1cSEvCbJ2hEGDqoMA46leC6FD+V0zPLczkEVQ=
github.com/openshift-kni/eco-goinfra v0.0.0-20240621192821-7c55fda74f32/go.mod h1:oGFnQMzZ/bqtnjdh9Rx44NzsMGWaZXgyQsoS0Q7faJ8=
github.com/openshift-kni/k8sreporter v1.0.5 h1:1GYBc/BTZyVoXilHef43v9A8BSzw700zAPZ6zsZvo6Y=
github.com/openshift-kni/k8sreporter v1.0.5/go.mod h1:fg8HI9yxiKAi6UzR6NTtrmQmA2WKzUqmkRUHwQ1+Bj8=
github.com/openshift-kni/lifecycle-agent v0.0.0-20240606123201-0c45cd13c2f1 h1:y+0Ecc+MSZA/GNS3VOpKq+XK9x8qoNA7TlyHvqbVbpw=
Expand Down
7 changes: 5 additions & 2 deletions tests/system-tests/internal/mirroring/mirror-images.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"fmt"
"os"
"path/filepath"
"strings"

"github.com/golang/glog"
"github.com/openshift-kni/eco-goinfra/pkg/clients"
Expand Down Expand Up @@ -96,9 +97,11 @@ func CopyRegistryAuthLocally(host, user, pass, combinedPullSecretFile string) (s
return "", err
}

remoteRegistryPullSecretFilePath := filepath.Join(out, combinedPullSecretFile)
remoteUserHomeDir := strings.Trim(out, "\n")

remoteRegistryPullSecretFilePath := filepath.Join(remoteUserHomeDir, combinedPullSecretFile)
localRegistryPullSecretFilePath := filepath.Join("/tmp", combinedPullSecretFile)
remoteDockerDirectoryPath := filepath.Join(out, ".docker")
remoteDockerDirectoryPath := filepath.Join(remoteUserHomeDir, ".docker")
localDockerDirectoryPath := filepath.Join(homeDir, ".docker")

err = remote.ScpFileFrom(
Expand Down
30 changes: 28 additions & 2 deletions tests/system-tests/internal/ocpcli/ocpcli.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,8 @@ func DownloadAndExtractOcBinaryArchive(apiClient *clients.Settings) error {
return nil
}

// ApplyConfigFile applies config using shell method.
func ApplyConfigFile(
// ApplyConfig applies config using shell method.
func ApplyConfig(
templateDir,
fileName,
destinationDir,
Expand All @@ -101,6 +101,32 @@ func ApplyConfigFile(
return nil
}

// CreateConfig creates config using shell method.
func CreateConfig(
templateDir,
fileName,
destinationDir,
finalFileName string,
variablesToReplace map[string]interface{}) error {
err := template.SaveTemplate(
templateDir, fileName, destinationDir, finalFileName, variablesToReplace)

if err != nil {
return err
}

cfgFilePath := filepath.Join(destinationDir, finalFileName)

applyCmd := fmt.Sprintf("oc create -f %s", cfgFilePath)
_, err = shell.ExecuteCmd(applyCmd)

if err != nil {
return fmt.Errorf("failed to execute %s command due to: %w", applyCmd, err)
}

return nil
}

// PatchWithNamespace patches the resource using the given patch type, object belongs to the specific namespace
// The following patches are exactly the same patch but using different types, 'merge' and 'json'
// --type merge -p '{"spec": {"selector": {"app": "frommergepatch"}}}'
Expand Down
69 changes: 0 additions & 69 deletions tests/system-tests/vcore/internal/config-files/clo-instance.yaml

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
---
apiVersion: rbac.authorization.k8s.io/v1
kind: RoleBinding
metadata:
name: {{ .RoleBindingName }}
namespace: {{ .RoleBindingNamespace }}
subjects:
- kind: ServiceAccount
name: {{ .ServiceAccountName }}
roleRef:
kind: Role
name: {{ .RoleName }}
apiGroup: rbac.authorization.k8s.io
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
apiVersion: batch/v1
kind: Job
metadata:
generateName: generate-requests-
namespace: '{{ .KedaWatchNamespace }}'
spec:
template:
spec:
containers:
- image: {{ .AbImageURL }}
name: test
command: ["/bin/sh"]
args: ["-c", "for i in $(seq 1 100);do echo $i;ab -c 5 -n 120 -v 2 http://test-app.{{ .TestNamespace }}.svc/;sleep 1;done"]
securityContext:
allowPrivilegeEscalation: false
runAsNonRoot: true
capabilities:
drop:
- ALL
seccompProfile:
type: RuntimeDefault
restartPolicy: Never
activeDeadlineSeconds: 120
backoffLimit: 2
96 changes: 48 additions & 48 deletions tests/system-tests/vcore/internal/vcorecommon/cgroup-operator.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"fmt"
"time"

"github.com/openshift-kni/eco-goinfra/pkg/reportxml"
"github.com/openshift-kni/eco-gotests/tests/system-tests/internal/platform"

"github.com/openshift-kni/eco-gotests/tests/system-tests/internal/cgroup"
Expand All @@ -16,11 +17,57 @@ import (
. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"

"github.com/openshift-kni/eco-goinfra/pkg/reportxml"
. "github.com/openshift-kni/eco-gotests/tests/system-tests/vcore/internal/vcoreinittools"
"github.com/openshift-kni/eco-gotests/tests/system-tests/vcore/internal/vcoreparams"
)

// VerifyCGroupDefault container that contains tests for cgroup verification.
func VerifyCGroupDefault() {
Describe(
"cgroup verification",
Label(vcoreparams.LabelVCoreDeployment), func() {
BeforeAll(func() {
By("Check that the current cluster version is greater or equal to the 4.15")

isGreaterOrEqual, err := platform.CompareOCPVersionWithCurrent(APIClient,
"4.15",
true,
true)
Expect(err).ToNot(HaveOccurred(), fmt.Sprintf("failed to compare versions due to %v", err))

if isGreaterOrEqual {
currentOCPVersion, err := platform.GetOCPVersion(APIClient)
Expect(err).ToNot(HaveOccurred(), fmt.Sprintf("failed to get OCP version due to %v", err))

Skip(fmt.Sprintf("current OCP version %s is not greater or equal to the 4.15",
currentOCPVersion))
}

By("Insure cgroupv2 configured for the cluster")

err = cgroup.SetLinuxCGroupVersion(APIClient, configv1.CgroupModeV2)
Expect(err).ToNot(HaveOccurred(),
fmt.Sprintf("failed to change cluster cgroup mode to the %v due to %v",
configv1.CgroupModeV2, err))
})

It("Verifies cgroupv2 is a default for the cluster deployment",
Label("cgroupv2"), reportxml.ID("73370"), VerifyCGroupV2IsADefault)

It("Verifies that the cluster can be moved to the cgroupv1 and back",
Label("cgroupv2"), reportxml.ID("73371"), VerifySwitchBetweenCGroupVersions)

AfterAll(func() {
By("Restore cgroupv2 cluster configuration")

err := cgroup.SetLinuxCGroupVersion(APIClient, configv1.CgroupModeV2)
Expect(err).ToNot(HaveOccurred(),
fmt.Sprintf("failed to change cluster cgroup mode to the %v due to %v",
configv1.CgroupModeV2, err))
})
})
}

// VerifyCGroupV2IsADefault assert cGroupV2 is a default for the cluster deployment.
func VerifyCGroupV2IsADefault(ctx SpecContext) {
glog.V(vcoreparams.VCoreLogLevel).Infof("Verify cgroupv2 is a default for the cluster deployment")
Expand Down Expand Up @@ -69,50 +116,3 @@ func VerifySwitchBetweenCGroupVersions(ctx SpecContext) {
Expect(err).ToNot(HaveOccurred(), fmt.Sprintf("failed to change cluster cgroup mode to the %v due to %v",
configv1.CgroupModeV2, err))
} // func VerifySwitchBetweenCGroupVersions (ctx SpecContext)

// VerifyCGroupDefault container that contains tests for cgroup verification.
func VerifyCGroupDefault() {
Describe(
"cgroup verification",
Label(vcoreparams.LabelVCoreDeployment), func() {
BeforeAll(func() {
By("Check that the current cluster version is greater or equal to the 4.15")

isGreaterOrEqual, err := platform.CompareOCPVersionWithCurrent(APIClient,
"4.15",
true,
true)
Expect(err).ToNot(HaveOccurred(), fmt.Sprintf("failed to compare versions due to %v", err))

if isGreaterOrEqual {
currentOCPVersion, err := platform.GetOCPVersion(APIClient)
Expect(err).ToNot(HaveOccurred(), fmt.Sprintf("failed to get OCP version due to %v", err))

Skip(fmt.Sprintf("current OCP version %s is not greater or equal to the 4.15",
currentOCPVersion))
}

By("Insure cgroupv2 configured for the cluster")

err = cgroup.SetLinuxCGroupVersion(APIClient, configv1.CgroupModeV2)
Expect(err).ToNot(HaveOccurred(),
fmt.Sprintf("failed to change cluster cgroup mode to the %v due to %v",
configv1.CgroupModeV2, err))
})

It("Verifies cgroupv2 is a default for the cluster deployment",
Label("cgroupv2"), reportxml.ID("73370"), VerifyCGroupV2IsADefault)

It("Verifies that the cluster can be moved to the cgroupv1 and back",
Label("cgroupv2"), reportxml.ID("73371"), VerifySwitchBetweenCGroupVersions)

AfterAll(func() {
By("Restore cgroupv2 cluster configuration")

err := cgroup.SetLinuxCGroupVersion(APIClient, configv1.CgroupModeV2)
Expect(err).ToNot(HaveOccurred(),
fmt.Sprintf("failed to change cluster cgroup mode to the %v due to %v",
configv1.CgroupModeV2, err))
})
})
}
Loading

0 comments on commit d0ade6d

Please sign in to comment.