-
Notifications
You must be signed in to change notification settings - Fork 20
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
Add pv support #109
Add pv support #109
Changes from 1 commit
c03bdbd
cf28198
0d837fe
3c7ae90
9db5543
5001aea
c46d429
2a9dc4e
dae80d0
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,6 +10,8 @@ import ( | |
|
||
gatlingv1alpha1 "github.com/st-tech/gatling-operator/api/v1alpha1" | ||
batchv1 "k8s.io/api/batch/v1" | ||
corev1 "k8s.io/api/core/v1" | ||
"k8s.io/apimachinery/pkg/api/resource" | ||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" | ||
"k8s.io/utils/pointer" | ||
//+kubebuilder:scaffold:imports | ||
|
@@ -84,5 +86,99 @@ var _ = Context("Inside of a new namespace", func() { | |
Expect(job.Spec.Completions).Should(Equal(pointer.Int32Ptr(2))) | ||
}) | ||
|
||
It("shoud create a New Gatling resource with PersistentVolume resources", func() { | ||
pvFS := corev1.PersistentVolumeFilesystem | ||
gatling := &gatlingv1alpha1.Gatling{ | ||
ObjectMeta: metav1.ObjectMeta{ | ||
Name: gatlingName, | ||
Namespace: ns.Name, | ||
}, | ||
Spec: gatlingv1alpha1.GatlingSpec{ | ||
GenerateReport: false, | ||
NotifyReport: false, | ||
CleanupAfterJobDone: false, | ||
PodSpec: gatlingv1alpha1.PodSpec{ | ||
Volumes: []corev1.Volume{ | ||
{ | ||
Name: "resource-vol", | ||
VolumeSource: corev1.VolumeSource{ | ||
PersistentVolumeClaim: &corev1.PersistentVolumeClaimVolumeSource{ | ||
ClaimName: "resource-pvc", | ||
}, | ||
}, | ||
}, | ||
}, | ||
}, | ||
PersistentVolumeSpec: gatlingv1alpha1.PersistentVolumeSpec{ | ||
Name: "resource-pv", | ||
Spec: corev1.PersistentVolumeSpec{ | ||
VolumeMode: &pvFS, | ||
AccessModes: []corev1.PersistentVolumeAccessMode{ | ||
corev1.ReadWriteOnce, | ||
}, | ||
StorageClassName: "", | ||
Capacity: corev1.ResourceList{ | ||
corev1.ResourceStorage: resource.MustParse("1Gi"), | ||
}, | ||
PersistentVolumeSource: corev1.PersistentVolumeSource{ | ||
Local: &corev1.LocalVolumeSource{Path: "/tmp"}, | ||
}, | ||
NodeAffinity: &corev1.VolumeNodeAffinity{ | ||
Required: &corev1.NodeSelector{ | ||
NodeSelectorTerms: []corev1.NodeSelectorTerm{ | ||
{ | ||
MatchExpressions: []corev1.NodeSelectorRequirement{{Key: "kubernetes.io/os", Operator: corev1.NodeSelectorOpIn, Values: []string{"linux"}}}, | ||
}, | ||
}, | ||
}, | ||
}, | ||
}, | ||
}, | ||
PersistentVolumeClaimSpec: gatlingv1alpha1.PersistentVolumeClaimSpec{ | ||
Name: "resource-pvc", | ||
Spec: corev1.PersistentVolumeClaimSpec{ | ||
AccessModes: []corev1.PersistentVolumeAccessMode{ | ||
corev1.ReadWriteOnce, | ||
}, | ||
VolumeName: "resource-pv", | ||
Resources: corev1.ResourceRequirements{ | ||
Requests: corev1.ResourceList{corev1.ResourceStorage: resource.MustParse("1Gi")}, | ||
}, | ||
}, | ||
}, | ||
TestScenarioSpec: gatlingv1alpha1.TestScenarioSpec{ | ||
SimulationClass: "PersistentVolumeSampleSimulation", | ||
Parallelism: 1, | ||
VolumeMounts: []corev1.VolumeMount{ | ||
{ | ||
Name: "resource-vol", | ||
MountPath: "/opt/gatling/user-files/resources/pv", | ||
}, | ||
}, | ||
}, | ||
}, | ||
} | ||
err := k8sClient.Create(ctx, gatling) | ||
Expect(err).NotTo(HaveOccurred(), "failed to create test Gatling resource") | ||
|
||
job := &batchv1.Job{} | ||
Eventually(func() error { | ||
return k8sClient.Get( | ||
ctx, client.ObjectKey{Namespace: ns.Name, Name: gatlingName + "-runner"}, job) | ||
}).Should(Succeed()) | ||
|
||
pv := &corev1.PersistentVolume{} | ||
Eventually(func() error { | ||
return k8sClient.Get( | ||
ctx, client.ObjectKey{Namespace: ns.Name, Name: "resource-pv"}, pv) | ||
}).Should(Succeed()) | ||
|
||
pvc := &corev1.PersistentVolumeClaim{} | ||
Eventually(func() error { | ||
return k8sClient.Get( | ||
ctx, client.ObjectKey{Namespace: ns.Name, Name: "resource-pvc"}, pvc) | ||
}).Should(Succeed()) | ||
}) | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Just a question. Are the below codes needed here?
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Since the code confirms that the results of getGatlingRunnerJobParallelism are correct, we consider it unnecessary in the added test code. Of course, it can be added. |
||
}) | ||
}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
shoud -> should