Add unit test for resource limits
package converter_test
import (
+ "encoding/json"
"fmt"
"path"
@@ -382,7 +383,7 @@ var _ = Describe("ContainerFactory", func() {
Expect(err.Error()).To(ContainSubstring("fake-release-image-error"))
})
- It("adds k8s resource requests from bpm config", func() {
+ It("adds k8s resource requests and limits from bpm config", func() {
jobs = []bdm.Job{
{Name: "fake-job"},
}
@@ -406,6 +407,30 @@ var _ = Describe("ContainerFactory", func() {
Expect(containers[0].Resources.Limits.Memory().String()).To(Equal("5G"))
})
+ It("doesn't add invalid k8s resource limits from bpm config", func() {
+ jobs = []bdm.Job{
+ {Name: "fake-job"},
+ }
+
+ bpmConfigs["fake-job"] = bpm.Config{
+ Processes: []bpm.Process{
+ {
+ Name: "fake-job",
+ Limits: bpm.Limits{Memory: "invalid"},
+ },
+ },
+ }
+ containers, err := act()
+ Expect(err).ToNot(HaveOccurred())
+ Expect(len(containers)).To(BeNumerically(">", 0))
+ Expect(containers[0].Name).To(ContainSubstring("fake-job"))
+ Expect(containers[0].Resources.Limits.Memory().String()).To(Equal("0"))
+
+ bytes, err := json.Marshal(containers[0].Resources.Limits)
+ Expect(err).ToNot(HaveOccurred())
+ Expect(string(bytes)).To(Equal("{}"))
+ })
+
Context("with lifecycle events", func() {
It("creates a preStop handler per job", func() {
containers, err := act()
