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 25, 2023
1 parent b9de35e commit 0bed7b6
Show file tree
Hide file tree
Showing 4 changed files with 457 additions and 0 deletions.
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")
golderFile := os.Getenv("NOTES_TEST_GOLDEN_FILE")
prevTag := os.Getenv("NOTES_TEST_PREVIOUS_RELEASE_TAG")

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

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

expectedOutput, err := os.ReadFile(golderFile)
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 0bed7b6

Please sign in to comment.