Skip to content

Commit

Permalink
[kjobctl] Install CRDs on integration tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
mbobrovskyi committed Jun 28, 2024
1 parent 9fad277 commit 63f98d3
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 10 deletions.
4 changes: 2 additions & 2 deletions cmd/experimental/kjobctl/apis/v1alpha1/volumebundle_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ import (
)

// VolumeBundleSpec defines the desired state of VolumeBundle
// +kubebuilder:validation:XValidation:rule="self.mountPoints.map(x, x.name in self.volumes.map(y, y.name))", message="mountPoint name must match a volume name"
type VolumeBundleSpec struct {
// volumes is a set of volumes that will be added to all pods of the job.
// +listType=map
Expand All @@ -39,7 +38,8 @@ type VolumeBundleSpec struct {
// envVars are environment variables that refer to absolute paths in the container filesystem.
// These key/value pairs will be available in containers as environment variables.
// +optional
// +kubebuilder:validation:XValidation:rule="self.all(x, x.name.matches('^[A-Za-z_][A-Za-z0-9_]*$') )", message="invalid environment variable name"
// +listType=map
// +listMapKey=name
EnvVars []corev1.EnvVar `json:"envVars,omitempty"`
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -236,9 +236,9 @@ spec:
- name
type: object
type: array
x-kubernetes-validations:
- message: invalid environment variable name
rule: self.all(x, x.name.matches('^[A-Za-z_][A-Za-z0-9_]*$') )
x-kubernetes-list-map-keys:
- name
x-kubernetes-list-type: map
volumes:
description: volumes is a set of volumes that will be added to all
pods of the job.
Expand Down Expand Up @@ -2004,9 +2004,6 @@ spec:
- containerVolumeMounts
- volumes
type: object
x-kubernetes-validations:
- message: mountPoint name must match a volume name
rule: self.mountPoints.map(x, x.name in self.volumes.map(y, y.name))
type: object
served: true
storage: true
6 changes: 5 additions & 1 deletion cmd/experimental/kjobctl/test/framework/framework.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,18 @@ import (
)

type Framework struct {
CRDPath string
testEnv *envtest.Environment
cancel context.CancelFunc
}

func (f *Framework) Init() *rest.Config {
ginkgo.By("bootstrapping test environment")

f.testEnv = &envtest.Environment{}
f.testEnv = &envtest.Environment{
CRDDirectoryPaths: []string{f.CRDPath},
ErrorIfCRDPathMissing: true,
}
cfg, err := f.testEnv.Start()

gomega.ExpectWithOffset(1, err).NotTo(gomega.HaveOccurred())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ package kjobctl

import (
"context"
"path/filepath"
"testing"

"github.com/onsi/ginkgo/v2"
Expand All @@ -33,6 +34,7 @@ var (
k8sClient client.Client
ctx context.Context
fwk *framework.Framework
crdPath = filepath.Join("..", "..", "..", "config", "crd", "bases")
)

func TestKjobctl(t *testing.T) {
Expand All @@ -41,7 +43,7 @@ func TestKjobctl(t *testing.T) {
}

var _ = ginkgo.BeforeSuite(func() {
fwk = &framework.Framework{}
fwk = &framework.Framework{CRDPath: crdPath}
cfg = fwk.Init()
ctx, k8sClient = fwk.SetupClient(cfg)
})
Expand Down

0 comments on commit 63f98d3

Please sign in to comment.