Skip to content

Commit

Permalink
modify tests
Browse files Browse the repository at this point in the history
  • Loading branch information
sanposhiho committed Oct 10, 2023
1 parent 18a0fe9 commit 585bbc9
Show file tree
Hide file tree
Showing 32 changed files with 278 additions and 82 deletions.
12 changes: 6 additions & 6 deletions api/autoscaling/v2/horizontalpodautoscaler_webhook_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,15 +50,18 @@ func mutateTest(before, after, torotise string) {
err = yaml.NewYAMLOrJSONDecoder(bytes.NewReader(y), 4096).Decode(tor)
status := tor.Status
Expect(err).NotTo(HaveOccurred())
err = k8sClient.Create(ctx, tor)
err = k8sClient.Create(ctx, tor.DeepCopy())
Expect(err).NotTo(HaveOccurred())
defer func() {
err = k8sClient.Delete(ctx, tor)
Expect(err).NotTo(HaveOccurred())
}()

err = k8sClient.Get(ctx, types.NamespacedName{Name: tor.GetName(), Namespace: tor.GetNamespace()}, tor)
Expect(err).NotTo(HaveOccurred())
tor.Status = status
//nolint:errcheck
k8sClient.Status().Update(ctx, tor)
err = k8sClient.Status().Update(ctx, tor)
Expect(err).NotTo(HaveOccurred())

y, err = os.ReadFile(before)
Expect(err).NotTo(HaveOccurred())
Expand Down Expand Up @@ -87,9 +90,6 @@ func mutateTest(before, after, torotise string) {

var _ = Describe("v2.HPA Webhook", func() {
Context("mutating", func() {
It("nothing to do", func() {
mutateTest(filepath.Join("testdata", "mutating", "nothing-to-do", "before.yaml"), filepath.Join("testdata", "mutating", "nothing-to-do", "after.yaml"), filepath.Join("testdata", "mutating", "nothing-to-do", "tortoise.yaml"))
})
It("HPA is mutated based on the recommendation", func() {
mutateTest(filepath.Join("testdata", "mutating", "mutate-by-recommendations", "before.yaml"), filepath.Join("testdata", "mutating", "mutate-by-recommendations", "after.yaml"), filepath.Join("testdata", "mutating", "mutate-by-recommendations", "tortoise.yaml"))
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,15 @@ spec:
memory: Vertical
status:
tortoisePhase: Working
containerResourcePhases:
- containerName: "nginx"
resourcePhases:
cpu: Working
memory: Working
- containerName: "istio-proxy"
resourcePhases:
cpu: Working
memory: Working
targets:
deployment: sample
horizontalPodAutoscaler: sample
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,15 @@ spec:
memory: Vertical
status:
tortoisePhase: Working
containerResourcePhases:
- containerName: "nginx"
resourcePhases:
cpu: Working
memory: Working
- containerName: "istio-proxy"
resourcePhases:
cpu: Working
memory: Working
targets:
deployment: sample
horizontalPodAutoscaler: sample2
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,15 @@ spec:
memory: Vertical
status:
tortoisePhase: Working
containerResourcePhases:
- containerName: "nginx"
resourcePhases:
cpu: Working
memory: Working
- containerName: "istio-proxy"
resourcePhases:
cpu: Working
memory: Working
targets:
deployment: sample
horizontalPodAutoscaler: sample
Expand Down
27 changes: 0 additions & 27 deletions api/autoscaling/v2/testdata/mutating/nothing-to-do/after.yaml

This file was deleted.

27 changes: 0 additions & 27 deletions api/autoscaling/v2/testdata/mutating/nothing-to-do/before.yaml

This file was deleted.

22 changes: 0 additions & 22 deletions api/autoscaling/v2/testdata/mutating/nothing-to-do/tortoise.yaml

This file was deleted.

29 changes: 29 additions & 0 deletions api/v1beta1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 9 additions & 0 deletions controllers/testdata/deletion-no-delete/before/tortoise.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -83,3 +83,12 @@ status:
- name: tortoise-monitor-mercari
role: Monitor
tortoisePhase: Working
containerResourcePhases:
- containerName: "nginx"
resourcePhases:
cpu: Working
memory: Working
- containerName: "istio-proxy"
resourcePhases:
cpu: Working
memory: Working
9 changes: 9 additions & 0 deletions controllers/testdata/deletion-policy-all/before/tortoise.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -83,3 +83,12 @@ status:
- name: tortoise-monitor-mercari
role: Monitor
tortoisePhase: Working
containerResourcePhases:
- containerName: "nginx"
resourcePhases:
cpu: Working
memory: Working
- containerName: "istio-proxy"
resourcePhases:
cpu: Working
memory: Working
Original file line number Diff line number Diff line change
Expand Up @@ -91,3 +91,12 @@ status:
- name: tortoise-monitor-mercari
role: Monitor
tortoisePhase: Working
containerResourcePhases:
- containerName: "nginx"
resourcePhases:
cpu: Working
memory: Working
- containerName: "istio-proxy"
resourcePhases:
cpu: Working
memory: Working
Original file line number Diff line number Diff line change
Expand Up @@ -82,3 +82,12 @@ status:
- name: tortoise-monitor-mercari
role: Monitor
tortoisePhase: Working
containerResourcePhases:
- containerName: "nginx"
resourcePhases:
cpu: Working
memory: Working
- containerName: "istio-proxy"
resourcePhases:
cpu: Working
memory: Working
Original file line number Diff line number Diff line change
Expand Up @@ -89,3 +89,12 @@ status:
- name: tortoise-monitor-mercari
role: Monitor
tortoisePhase: Working
containerResourcePhases:
- containerName: "nginx"
resourcePhases:
cpu: Working
memory: Working
- containerName: "istio-proxy"
resourcePhases:
cpu: Working
memory: Working
Original file line number Diff line number Diff line change
Expand Up @@ -87,3 +87,12 @@ status:
- name: tortoise-monitor-mercari
role: Monitor
tortoisePhase: Working
containerResourcePhases:
- containerName: "nginx"
resourcePhases:
cpu: Working
memory: Working
- containerName: "istio-proxy"
resourcePhases:
cpu: Working
memory: Working
Original file line number Diff line number Diff line change
Expand Up @@ -88,3 +88,12 @@ status:
- name: tortoise-monitor-mercari
role: Monitor
tortoisePhase: Working
containerResourcePhases:
- containerName: "nginx"
resourcePhases:
cpu: Working
memory: Working
- containerName: "istio-proxy"
resourcePhases:
cpu: Working
memory: Working
Original file line number Diff line number Diff line change
Expand Up @@ -82,3 +82,12 @@ status:
- name: tortoise-monitor-mercari
role: Monitor
tortoisePhase: Working
containerResourcePhases:
- containerName: "nginx"
resourcePhases:
cpu: Working
memory: Working
- containerName: "istio-proxy"
resourcePhases:
cpu: Working
memory: Working
Original file line number Diff line number Diff line change
Expand Up @@ -86,3 +86,12 @@ status:
- name: tortoise-monitor-mercari
role: Monitor
tortoisePhase: Working
containerResourcePhases:
- containerName: "nginx"
resourcePhases:
cpu: Working
memory: Working
- containerName: "istio-proxy"
resourcePhases:
cpu: Working
memory: Working
Original file line number Diff line number Diff line change
Expand Up @@ -78,3 +78,12 @@ status:
- name: tortoise-monitor-mercari
role: Monitor
tortoisePhase: Working
containerResourcePhases:
- containerName: "nginx"
resourcePhases:
cpu: Working
memory: Working
- containerName: "istio-proxy"
resourcePhases:
cpu: Working
memory: Working
Original file line number Diff line number Diff line change
Expand Up @@ -87,3 +87,12 @@ status:
- name: tortoise-monitor-mercari
role: Monitor
tortoisePhase: Working
containerResourcePhases:
- containerName: "nginx"
resourcePhases:
cpu: Working
memory: Working
- containerName: "istio-proxy"
resourcePhases:
cpu: Working
memory: Working
Original file line number Diff line number Diff line change
Expand Up @@ -79,3 +79,12 @@ status:
- name: tortoise-monitor-mercari
role: Monitor
tortoisePhase: Working
containerResourcePhases:
- containerName: "nginx"
resourcePhases:
cpu: Working
memory: Working
- containerName: "istio-proxy"
resourcePhases:
cpu: Working
memory: Working
Original file line number Diff line number Diff line change
Expand Up @@ -91,3 +91,12 @@ status:
- name: tortoise-monitor-mercari
role: Monitor
tortoisePhase: Emergency
containerResourcePhases:
- containerName: "nginx"
resourcePhases:
cpu: Working
memory: Working
- containerName: "istio-proxy"
resourcePhases:
cpu: Working
memory: Working
Original file line number Diff line number Diff line change
Expand Up @@ -83,3 +83,12 @@ status:
- name: tortoise-monitor-mercari
role: Monitor
tortoisePhase: Working
containerResourcePhases:
- containerName: "nginx"
resourcePhases:
cpu: Working
memory: Working
- containerName: "istio-proxy"
resourcePhases:
cpu: Working
memory: Working
Original file line number Diff line number Diff line change
Expand Up @@ -89,3 +89,12 @@ status:
- name: tortoise-monitor-mercari
role: Monitor
tortoisePhase: Working
containerResourcePhases:
- containerName: "nginx"
resourcePhases:
cpu: Working
memory: Working
- containerName: "istio-proxy"
resourcePhases:
cpu: Working
memory: Working
Loading

0 comments on commit 585bbc9

Please sign in to comment.