This is an automated email from the ASF dual-hosted git repository. astefanutti pushed a commit to branch main in repository https://gitbox.apache.org/repos/asf/camel-k.git
commit 11f43db48794415b433005ea2b66044fd8c4b68a Author: Antonin Stefanutti <anto...@stefanutti.fr> AuthorDate: Mon Oct 11 14:38:05 2021 +0200 fix(e2e): Use JSON merge patch to scale integrations --- e2e/support/test_support.go | 27 ++++++++++++++++++++++----- 1 file changed, 22 insertions(+), 5 deletions(-) diff --git a/e2e/support/test_support.go b/e2e/support/test_support.go index e2d1e68..604adcf 100644 --- a/e2e/support/test_support.go +++ b/e2e/support/test_support.go @@ -31,7 +31,7 @@ import ( "io" "io/ioutil" "os" - exec "os/exec" + "os/exec" "reflect" "strings" "testing" @@ -622,17 +622,34 @@ func KitPhase(ns, name string) func() v1.IntegrationKitPhase { } } -func UpdateIntegration(ns string, name string, upd func(it *v1.Integration)) error { +func UpdateIntegration(ns string, name string, mutate func(it *v1.Integration)) error { it := Integration(ns, name)() if it == nil { return fmt.Errorf("no integration named %s found", name) } - upd(it) - return TestClient().Update(TestContext, it) + target := it.DeepCopy() + mutate(target) + return TestClient().Update(TestContext, target) +} + +func PatchIntegration(ns string, name string, mutate func(it *v1.Integration)) error { + it := Integration(ns, name)() + if it == nil { + return fmt.Errorf("no integration named %s found", name) + } + target := it.DeepCopy() + mutate(target) + p, err := patch.PositiveMergePatch(it, target) + if err != nil { + return err + } else if len(p) == 0 { + return nil + } + return TestClient().Patch(TestContext, target, ctrl.RawPatch(types.MergePatchType, p)) } func ScaleIntegration(ns string, name string, replicas int32) error { - return UpdateIntegration(ns, name, func(it *v1.Integration) { + return PatchIntegration(ns, name, func(it *v1.Integration) { it.Spec.Replicas = &replicas }) }