Skip to content

Commit 769c4d1

Browse files
committed
Use v1.20.1 for both init and deploy in middleware update test
The middleware update test was failing because: - InitializeRepoWithFunction() used current func CLI to init the repo - Current func CLI creates new instance-based template structure - Old func CLI (v1.20.0) couldn't understand the new template format - This caused buildpack lifecycle failures (status code 51) Solution: - Add InitializeRepoWithFunctionVersion() to allow specifying func CLI version - Use v1.20.1 for both 'func init' and 'func deploy' to ensure compatibility - v1.20.1 still doesn't have middleware-version label (added in v1.21.0), so it's suitable for testing the middleware update functionality
1 parent dac7dee commit 769c4d1

4 files changed

Lines changed: 33 additions & 12 deletions

File tree

.github/workflows/test-e2e-bundle.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@ on:
44
push:
55
pull_request:
66

7+
concurrency:
8+
group: ${{ github.workflow }}-${{ github.ref }}
9+
cancel-in-progress: true
10+
711
jobs:
812
test-bundle-e2e:
913
name: Bundle E2E Tests

.github/workflows/test-e2e.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@ on:
44
push:
55
pull_request:
66

7+
concurrency:
8+
group: ${{ github.workflow }}-${{ github.ref }}
9+
cancel-in-progress: true
10+
711
jobs:
812
test-e2e:
913
name: E2E Tests

test/e2e/func_middleware_update_test.go

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -58,17 +58,19 @@ var _ = Describe("Middleware Update", func() {
5858
Expect(err).NotTo(HaveOccurred())
5959
DeferCleanup(cleanup)
6060

61-
// Initialize repository with function code
62-
repoDir, err = utils.InitializeRepoWithFunction(repoURL, username, password, "go")
63-
Expect(err).NotTo(HaveOccurred())
64-
DeferCleanup(os.RemoveAll, repoDir)
65-
6661
functionNamespace, err = utils.GetTestNamespace()
6762
Expect(err).NotTo(HaveOccurred())
6863
DeferCleanup(cleanupNamespaces, functionNamespace)
6964

70-
// Deploy function using OLD func CLI version
71-
out, err := utils.RunFuncWithVersion("v1.20.0", "deploy",
65+
// Initialize repository with function code using OLD func CLI version
66+
// v1.20.1 has no middleware-version label and uses instance-compatible templates
67+
oldFuncVersion := "v1.20.1"
68+
repoDir, err = utils.InitializeRepoWithFunctionVersion(repoURL, username, password, "go", oldFuncVersion)
69+
Expect(err).NotTo(HaveOccurred())
70+
DeferCleanup(os.RemoveAll, repoDir)
71+
72+
// Deploy function using the same OLD func CLI version
73+
out, err := utils.RunFuncWithVersion(oldFuncVersion, "deploy",
7274
"--namespace", functionNamespace,
7375
"--path", repoDir,
7476
"--registry", registry,
@@ -119,7 +121,7 @@ var _ = Describe("Middleware Update", func() {
119121
// We use skopeo with localhost:5001 (port-forward to the registry) to
120122
// directly inspect the OCI image labels and verify the middleware was updated.
121123

122-
// Get initial image digest from func describe (deployed with old v1.20.0)
124+
// Get initial image digest from func describe (deployed with v1.20.1)
123125
out, err := utils.RunFunc("describe", deployedFunctionName, "-n", functionNamespace, "-o", "yaml")
124126
Expect(err).NotTo(HaveOccurred())
125127

@@ -129,9 +131,9 @@ var _ = Describe("Middleware Update", func() {
129131

130132
initialImage := initialInstance.Image
131133
Expect(initialImage).NotTo(BeEmpty(), "Initial image should be available from func describe")
132-
_, _ = fmt.Fprintf(GinkgoWriter, "Initial image (deployed with v1.20.0): %s\n", initialImage)
134+
_, _ = fmt.Fprintf(GinkgoWriter, "Initial image (deployed with v1.20.1): %s\n", initialImage)
133135

134-
// Verify initial image has no middleware-version label (old func CLI)
136+
// Verify initial image has no middleware-version label (v1.20.1 doesn't set it)
135137
initialImageLocal := strings.Replace(initialImage, "kind-registry:5000", "localhost:5001", 1)
136138
// Remove tag if both tag and digest are present (skopeo doesn't support this format)
137139
if strings.Contains(initialImageLocal, "@") {
@@ -160,7 +162,7 @@ var _ = Describe("Middleware Update", func() {
160162
Expect(err).NotTo(HaveOccurred())
161163

162164
initialMiddlewareVersion := initialImageLabels.Labels["middleware-version"]
163-
_, _ = fmt.Fprintf(GinkgoWriter, "Initial middleware-version label: '%s' (expected empty for v1.20.0)\n",
165+
_, _ = fmt.Fprintf(GinkgoWriter, "Initial middleware-version label: '%s' (expected empty for v1.20.1)\n",
164166
initialMiddlewareVersion)
165167

166168
// Create a Function resource

test/utils/git.go

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,13 +33,24 @@ func buildAuthURL(repoURL, username, password string) string {
3333

3434
// InitializeRepoWithFunction creates a function project and pushes it to the Gitea repo
3535
func InitializeRepoWithFunction(repoURL, username, password, language string) (repoDir string, err error) {
36+
return InitializeRepoWithFunctionVersion(repoURL, username, password, language, "")
37+
}
38+
39+
// InitializeRepoWithFunctionVersion creates a function project with a specific func CLI version
40+
// If version is empty, uses the current func CLI
41+
func InitializeRepoWithFunctionVersion(repoURL, username, password, language, version string) (repoDir string, err error) {
3642
repoDir = fmt.Sprintf("%s/func-test-%s", os.TempDir(), rand.String(10))
3743

3844
// Build authenticated URL
3945
authURL := buildAuthURL(repoURL, username, password)
4046

4147
// Initialize function (func init creates the directory)
42-
if _, err = RunFunc("init", "-l", language, repoDir); err != nil {
48+
if version == "" {
49+
_, err = RunFunc("init", "-l", language, repoDir)
50+
} else {
51+
_, err = RunFuncWithVersion(version, "init", "-l", language, repoDir)
52+
}
53+
if err != nil {
4354
return "", fmt.Errorf("failed to init function: %w", err)
4455
}
4556

0 commit comments

Comments
 (0)