- Sponsor
-
Notifications
You must be signed in to change notification settings - Fork 233
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Loading status checks…
Add integration tests for redis standalone
Signed-off-by: Mathieu Cesbron <mathieu.cesbron@protonmail.com>
1 parent
7665d4a
commit 79c4fb7
Showing
7 changed files
with
186 additions
and
66 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
package controllers | ||
|
||
import ( | ||
"context" | ||
"time" | ||
|
||
redisv1beta2 "github.com/OT-CONTAINER-KIT/redis-operator/api/v1beta2" | ||
. "github.com/onsi/ginkgo/v2" | ||
. "github.com/onsi/gomega" | ||
corev1 "k8s.io/api/core/v1" | ||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" | ||
"k8s.io/apimachinery/pkg/types" | ||
) | ||
|
||
const ( | ||
ns = "default" | ||
redisStandaloneName = "redis-standalone" | ||
|
||
timeout = time.Second * 5 | ||
interval = time.Millisecond * 250 | ||
) | ||
|
||
var _ = Describe("Redis standalone test", func() { | ||
Context("When creating a redis standalone CR", func() { | ||
It("should create a statefulset", func() { | ||
ctx := context.Background() | ||
|
||
var runAsUser int64 = 1000 | ||
var fsGroup int64 = 1000 | ||
redisStandaloneCR := redisv1beta2.Redis{ | ||
TypeMeta: metav1.TypeMeta{ | ||
APIVersion: "redisv1beta2/apiVersion", | ||
Kind: "Redis", | ||
}, | ||
ObjectMeta: metav1.ObjectMeta{ | ||
Name: redisStandaloneName, | ||
Namespace: ns, | ||
}, | ||
Spec: redisv1beta2.RedisSpec{ | ||
PodSecurityContext: &corev1.PodSecurityContext{ | ||
RunAsUser: &runAsUser, | ||
FSGroup: &fsGroup, | ||
}, | ||
// KubernetesConfig: redisv1beta2.KubernetesConfig{}, | ||
}, | ||
} | ||
Expect(k8sClient.Create(ctx, &redisStandaloneCR)).Should(Succeed()) | ||
|
||
Eventually(func() error { | ||
service := &corev1.Service{} | ||
err := k8sClient.Get(ctx, types.NamespacedName{ | ||
Name: redisStandaloneName, | ||
Namespace: ns, | ||
}, service) | ||
return err | ||
}, timeout, interval).Should(BeNil()) | ||
}) | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
#!/usr/bin/env bash | ||
set -euo pipefail | ||
|
||
K8S_VERSION="${K8S_VERSION:="1.28.x"}" | ||
KUBEBUILDER_ASSETS="/usr/local/kubebuilder/bin" | ||
|
||
main() { | ||
tools | ||
kubebuilder | ||
} | ||
|
||
tools() { | ||
go install github.com/google/go-licenses@latest | ||
go install github.com/golangci/golangci-lint/cmd/golangci-lint@latest | ||
go install github.com/google/ko@latest | ||
go install github.com/mikefarah/yq/v4@latest | ||
go install github.com/norwoodj/helm-docs/cmd/helm-docs@latest | ||
go install sigs.k8s.io/controller-runtime/tools/setup-envtest@latest | ||
go install sigs.k8s.io/controller-tools/cmd/controller-gen@latest | ||
go install github.com/sigstore/cosign/v2/cmd/cosign@latest | ||
go install -tags extended github.com/gohugoio/hugo@v0.110.0 | ||
go install golang.org/x/vuln/cmd/govulncheck@latest | ||
go install github.com/onsi/ginkgo/v2/ginkgo@latest | ||
go install github.com/rhysd/actionlint/cmd/actionlint@latest | ||
go install github.com/mattn/goveralls@latest | ||
|
||
if ! echo "$PATH" | grep -q "${GOPATH:-undefined}/bin\|$HOME/go/bin"; then | ||
echo "Go workspace's \"bin\" directory is not in PATH. Run 'export PATH=\"\$PATH:\${GOPATH:-\$HOME/go}/bin\"'." | ||
fi | ||
} | ||
|
||
kubebuilder() { | ||
sudo mkdir -p ${KUBEBUILDER_ASSETS} | ||
sudo chown "${USER}" ${KUBEBUILDER_ASSETS} | ||
arch=$(go env GOARCH) | ||
ln -sf $(setup-envtest use -p path "${K8S_VERSION}" --arch="${arch}" --bin-dir="${KUBEBUILDER_ASSETS}")/* ${KUBEBUILDER_ASSETS} | ||
find $KUBEBUILDER_ASSETS | ||
} | ||
|
||
main "$@" |