Skip to content

Commit 973d97a

Browse files
committed
Add integration test for release notes tool
1 parent dc3b60b commit 973d97a

File tree

5 files changed

+459
-0
lines changed

5 files changed

+459
-0
lines changed

hack/tools/go.mod

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ replace sigs.k8s.io/cluster-api/test => ../../test
99
require (
1010
cloud.google.com/go/storage v1.35.1
1111
github.com/blang/semver/v4 v4.0.0
12+
github.com/onsi/gomega v1.29.0
1213
github.com/pkg/errors v0.9.1
1314
github.com/spf13/pflag v1.0.5
1415
github.com/valyala/fastjson v1.6.4
Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
//go:build tools && integration
2+
3+
/*
4+
Copyright 2023 The Kubernetes Authors.
5+
6+
Licensed under the Apache License, Version 2.0 (the "License");
7+
you may not use this file except in compliance with the License.
8+
You may obtain a copy of the License at
9+
10+
http://www.apache.org/licenses/LICENSE-2.0
11+
12+
Unless required by applicable law or agreed to in writing, software
13+
distributed under the License is distributed on an "AS IS" BASIS,
14+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
See the License for the specific language governing permissions and
16+
limitations under the License.
17+
*/
18+
19+
package main
20+
21+
import (
22+
"flag"
23+
"fmt"
24+
"io"
25+
"os"
26+
"testing"
27+
28+
. "github.com/onsi/gomega"
29+
)
30+
31+
func TestReleaseNotes(t *testing.T) {
32+
g := NewWithT(t)
33+
folder := os.Getenv("NOTES_TEST_FOLDER")
34+
goldenFile := os.Getenv("NOTES_TEST_GOLDEN_FILE")
35+
prevTag := os.Getenv("NOTES_TEST_PREVIOUS_RELEASE_TAG")
36+
37+
g.Expect(folder).ToNot(BeEmpty())
38+
g.Expect(goldenFile).ToNot(BeEmpty())
39+
g.Expect(prevTag).ToNot(BeEmpty())
40+
41+
t.Logf("Running release notes for prev tag %s", prevTag)
42+
43+
expectedOutput, err := os.ReadFile(goldenFile)
44+
g.Expect(err).ToNot(HaveOccurred())
45+
46+
// two workers is slow but is guarantees no rate limiting
47+
os.Args = []string{os.Args[0], "--from", prevTag, "--workers", "2"}
48+
g.Expect(os.Chdir(folder)).To(Succeed())
49+
50+
old := os.Stdout // keep backup of the real stdout to restore later
51+
r, w, err := os.Pipe()
52+
g.Expect(err).To(Succeed())
53+
os.Stdout = w
54+
55+
g.Expect(runReleaseNotesCmd()).To(Succeed())
56+
57+
w.Close()
58+
output, err := io.ReadAll(r)
59+
g.Expect(err).NotTo(HaveOccurred())
60+
os.Stdout = old
61+
62+
g.Expect(string(output)).To(BeComparableTo(string(expectedOutput)))
63+
}
64+
65+
func runReleaseNotesCmd() error {
66+
// we replicate the main function here so we don't get os.Exit
67+
flag.Parse()
68+
if code := run(); code != 0 {
69+
return fmt.Errorf("release notes command exited with code %d", code)
70+
}
71+
72+
return nil
73+
}
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
## 👌 Kubernetes version support
2+
3+
- Management Cluster: v1.**X**.x -> v1.**X**.x
4+
- Workload Cluster: v1.**X**.x -> v1.**X**.x
5+
6+
[More information about version support can be found here](https://cluster-api.sigs.k8s.io/reference/versions.html)
7+
8+
## Highlights
9+
10+
* REPLACE ME
11+
12+
## Deprecation Warning
13+
14+
REPLACE ME: A couple sentences describing the deprecation, including links to docs.
15+
16+
* [GitHub issue #REPLACE ME](REPLACE ME)
17+
18+
## Changes since v1.3.9
19+
## :chart_with_upwards_trend: Overview
20+
- 6 new commits merged
21+
- 2 bugs fixed 🐛
22+
23+
## :bug: Bug Fixes
24+
- Dependency: Bump to docker v24.0.5-0.20230714235725-36e9e796c6fc (#9046)
25+
- KCP: Requeue KCP object if ControlPlaneComponentsHealthyCondition is not yet true (#9034)
26+
27+
## :seedling: Others
28+
- ClusterCacheTracker: Ensure Get/List calls are not getting stuck when apiserver is unreachable (#9033)
29+
- Dependency: Bump docker to v24.0.5 (#9067)
30+
- Dependency: Bump google.golang.org/grpc to v1.55.0 (#8971)
31+
- Dependency: Change tilt debug base image to golang (#9075)
32+
33+
34+
_Thanks to all our contributors!_ 😊

0 commit comments

Comments
 (0)