Skip to content

Commit b0a948f

Browse files
committed
work around inconsistency in kcp 0.27 API binding
On-behalf-of: @SAP christoph.mewes@sap.com
1 parent db1573c commit b0a948f

File tree

2 files changed

+33
-0
lines changed

2 files changed

+33
-0
lines changed

test/e2e/sync/apiexportendpointslice_test.go

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,14 @@ func TestAPIExportEndpointSliceSameCluster(t *testing.T) {
122122
Resource: "crontabs",
123123
})
124124

125+
// In kcp 0.27, the binding' status is not perfectly in-sync with the actual APIs available in
126+
// the workspace; since this is fixed in 0.28+ and we really care about the APIBinding, not necessarily
127+
// the Kubernetes magic behind it, we keep the loop above but on 0.27 add a small synthetic delay.
128+
// TODO: Remove this once we do not support kcp 0.27 anymore.
129+
if utils.KCPMinor() < 28 {
130+
time.Sleep(2 * time.Second)
131+
}
132+
125133
// create a Crontab object in a team workspace
126134
t.Log("Creating CronTab in kcp…")
127135
crontab := utils.YAMLToUnstructured(t, `
@@ -258,6 +266,11 @@ func TestAPIExportEndpointSliceDifferentCluster(t *testing.T) {
258266
Resource: "crontabs",
259267
})
260268

269+
// TODO: Remove this once we do not support kcp 0.27 anymore.
270+
if utils.KCPMinor() < 28 {
271+
time.Sleep(2 * time.Second)
272+
}
273+
261274
// create a Crontab object in a team workspace
262275
t.Log("Creating CronTab in kcp…")
263276
crontab := utils.YAMLToUnstructured(t, `

test/utils/utils.go

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import (
2121
"net/url"
2222
"os"
2323
"regexp"
24+
"strconv"
2425
"strings"
2526
"testing"
2627

@@ -205,3 +206,22 @@ func YAMLToUnstructured(t *testing.T, data string) *unstructured.Unstructured {
205206

206207
return ToUnstructured(t, obj)
207208
}
209+
210+
func KCPMinor() int {
211+
version := os.Getenv("KCP_VERSION")
212+
if version == "" {
213+
panic("No $KCP_VERSION environment variable defined.")
214+
}
215+
216+
parts := strings.SplitN(version, ".", 3)
217+
if len(parts) != 3 {
218+
panic("Invalid $KCP_VERSION, must be X.Y.Z.")
219+
}
220+
221+
minor, err := strconv.ParseInt(parts[1], 10, 32)
222+
if err != nil {
223+
panic(fmt.Sprintf("Invalid $KCP_VERSION: not parseable: %v", err))
224+
}
225+
226+
return int(minor)
227+
}

0 commit comments

Comments
 (0)