Skip to content

Commit

Permalink
Add bootstrap pod resource test
Browse files Browse the repository at this point in the history
  • Loading branch information
salyh authored and dr-lilienthal committed Jan 7, 2025
1 parent 8753142 commit ae195ef
Showing 1 changed file with 32 additions and 1 deletion.
33 changes: 32 additions & 1 deletion opensearch-operator/pkg/builders/cluster_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,16 @@ func ClusterDescWithBootstrapPriorityClassNameAndLabel(prioClassName string, lab
}
}

func ClusterDescWithBootstrapResources(resources corev1.ResourceRequirements) opsterv1.OpenSearchCluster {
return opsterv1.OpenSearchCluster{
Spec: opsterv1.ClusterSpec{
Bootstrap: opsterv1.BootstrapConfig{
Resources: resources,
},
},
}
}

var _ = Describe("Builders", func() {
When("Constructing a STS for a NodePool", func() {
It("should include the init containers as SKIP_INIT_CONTAINER is not set", func() {
Expand Down Expand Up @@ -947,7 +957,7 @@ var _ = Describe("Builders", func() {
})

When("Constructing a bootstrap pod with priorityClass and label Values", func() {
It("should create a proper spec", func() {
It("should create a proper bootstrap spec with priorityClass and labels", func() {
prioClassName := "testprioclass"

labels := map[string]string{
Expand All @@ -967,4 +977,25 @@ var _ = Describe("Builders", func() {
}))
})
})

When("Constructing a bootstrap pod with resources", func() {
It("should create a proper spec with resources", func() {

resources := corev1.ResourceRequirements{
Limits: corev1.ResourceList{
corev1.ResourceCPU: resource.MustParse("1000m"),
corev1.ResourceMemory: resource.MustParse("1Gi"),
},
Requests: corev1.ResourceList{
corev1.ResourceCPU: resource.MustParse("500m"),
corev1.ResourceMemory: resource.MustParse("2Gi"),
},
}

clusterObject := ClusterDescWithBootstrapResources(resources)

result := NewBootstrapPod(&clusterObject, nil, nil)
Expect(result.Spec.Containers[0].Resources).To(Equal(resources))
})
})
})

0 comments on commit ae195ef

Please sign in to comment.