Skip to content

Commit

Permalink
Add integration test for release notes tool
Browse files Browse the repository at this point in the history
  • Loading branch information
g-gaston committed Oct 31, 2023
1 parent b9de35e commit 3222ba5
Show file tree
Hide file tree
Showing 5 changed files with 459 additions and 1 deletion.
2 changes: 1 addition & 1 deletion hack/tools/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ replace sigs.k8s.io/cluster-api/test => ../../test
require (
cloud.google.com/go/storage v1.33.0
github.com/blang/semver/v4 v4.0.0
github.com/onsi/gomega v1.28.1
github.com/pkg/errors v0.9.1
github.com/spf13/pflag v1.0.5
github.com/valyala/fastjson v1.6.4
Expand Down Expand Up @@ -90,7 +91,6 @@ require (
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
github.com/modern-go/reflect2 v1.0.2 // indirect
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect
github.com/onsi/gomega v1.28.1 // indirect
github.com/opencontainers/go-digest v1.0.0 // indirect
github.com/opencontainers/image-spec v1.1.0-rc2 // indirect
github.com/pelletier/go-toml/v2 v2.1.0 // indirect
Expand Down
73 changes: 73 additions & 0 deletions hack/tools/release/release_notes_integration_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
//go:build tools && integration

/*
Copyright 2023 The Kubernetes Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

package main

import (
"flag"
"fmt"
"io"
"os"
"testing"

. "github.com/onsi/gomega"
)

func TestReleaseNotes(t *testing.T) {
g := NewWithT(t)
folder := os.Getenv("NOTES_TEST_FOLDER")
goldenFile := os.Getenv("NOTES_TEST_GOLDEN_FILE")
prevTag := os.Getenv("NOTES_TEST_PREVIOUS_RELEASE_TAG")

g.Expect(folder).ToNot(BeEmpty())
g.Expect(goldenFile).ToNot(BeEmpty())
g.Expect(prevTag).ToNot(BeEmpty())

t.Logf("Running release notes for prev tag %s", prevTag)

expectedOutput, err := os.ReadFile(goldenFile)
g.Expect(err).ToNot(HaveOccurred())

// two workers is slow but is guarantees no rate limiting
os.Args = []string{os.Args[0], "--from", prevTag, "--workers", "2"}
g.Expect(os.Chdir(folder)).To(Succeed())

old := os.Stdout // keep backup of the real stdout to restore later
r, w, err := os.Pipe()
g.Expect(err).To(Succeed())
os.Stdout = w

g.Expect(runReleaseNotesCmd()).To(Succeed())

w.Close()
output, err := io.ReadAll(r)
g.Expect(err).NotTo(HaveOccurred())
os.Stdout = old

g.Expect(string(output)).To(BeComparableTo(string(expectedOutput)))
}

func runReleaseNotesCmd() error {
// we replicate the main function here so we don't get os.Exit
flag.Parse()
if code := run(); code != 0 {
return fmt.Errorf("release notes command exited with code %d", code)
}

return nil
}
34 changes: 34 additions & 0 deletions hack/tools/release/test/golden/v1.3.10.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
## 👌 Kubernetes version support

- Management Cluster: v1.**X**.x -> v1.**X**.x
- Workload Cluster: v1.**X**.x -> v1.**X**.x

[More information about version support can be found here](https://cluster-api.sigs.k8s.io/reference/versions.html)

## Highlights

* REPLACE ME

## Deprecation Warning

REPLACE ME: A couple sentences describing the deprecation, including links to docs.

* [GitHub issue #REPLACE ME](REPLACE ME)

## Changes since v1.3.9
## :chart_with_upwards_trend: Overview
- 6 new commits merged
- 2 bugs fixed 🐛

## :bug: Bug Fixes
- Dependency: Bump to docker v24.0.5-0.20230714235725-36e9e796c6fc (#9046)
- KCP: Requeue KCP object if ControlPlaneComponentsHealthyCondition is not yet true (#9034)

## :seedling: Others
- ClusterCacheTracker: Ensure Get/List calls are not getting stuck when apiserver is unreachable (#9033)
- Dependency: Bump docker to v24.0.5 (#9067)
- Dependency: Bump google.golang.org/grpc to v1.55.0 (#8971)
- Dependency: Change tilt debug base image to golang (#9075)


_Thanks to all our contributors!_ 😊
Loading

0 comments on commit 3222ba5

Please sign in to comment.