Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

vCore: keda test suite #63

Merged
merged 5 commits into from
Jun 22, 2024
Merged
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
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
Loading