deps: update Go to v1.24.2 (#3750)

* deps: update Go to v1.24.2
* tests: replace context.Background() with t.Context()

---------

Signed-off-by: Daniel Weiße <dw@edgeless.systems>
This commit is contained in:
Daniel Weiße 2025-04-09 10:54:28 +02:00 committed by GitHub
parent a7f9561a3d
commit 4e5c213b4d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
112 changed files with 287 additions and 316 deletions

View file

@ -12,7 +12,6 @@ package lb
import (
"bufio"
"bytes"
"context"
"fmt"
"io"
"net/http"
@ -70,7 +69,7 @@ func TestLoadBalancer(t *testing.T) {
t.Log("Change port of service to 8044")
svc.Spec.Ports[0].Port = newPort
svc, err = k.CoreV1().Services(namespaceName).Update(context.Background(), svc, metaV1.UpdateOptions{})
svc, err = k.CoreV1().Services(namespaceName).Update(t.Context(), svc, metaV1.UpdateOptions{})
require.NoError(err)
assert.Equal(newPort, svc.Spec.Ports[0].Port)
@ -93,7 +92,7 @@ func gatherDebugInfo(t *testing.T, k *kubernetes.Clientset) {
t.Log("Gathering additional debug information.")
pods, err := k.CoreV1().Pods(namespaceName).List(context.Background(), metaV1.ListOptions{
pods, err := k.CoreV1().Pods(namespaceName).List(t.Context(), metaV1.ListOptions{
LabelSelector: "app=whoami",
})
if err != nil {
@ -106,7 +105,7 @@ func gatherDebugInfo(t *testing.T, k *kubernetes.Clientset) {
req := k.CoreV1().Pods(namespaceName).GetLogs(pod.Name, &coreV1.PodLogOptions{
LimitBytes: func() *int64 { i := int64(1024 * 1024); return &i }(),
})
logs, err := req.Stream(context.Background())
logs, err := req.Stream(t.Context())
if err != nil {
t.Logf("fetching logs: %v", err)
return
@ -155,7 +154,7 @@ func testEventuallyStatusOK(t *testing.T, url string) {
require := require.New(t)
assert.Eventually(func() bool {
req, err := http.NewRequestWithContext(context.Background(), http.MethodGet, url, http.NoBody)
req, err := http.NewRequestWithContext(t.Context(), http.MethodGet, url, http.NoBody)
require.NoError(err)
resp, err := http.DefaultClient.Do(req)
@ -183,7 +182,7 @@ func testEventuallyExternalIPAvailable(t *testing.T, k *kubernetes.Clientset) *c
require.Eventually(t, func() bool {
var err error
svc, err = k.CoreV1().Services(namespaceName).Get(context.Background(), serviceName, metaV1.GetOptions{})
svc, err = k.CoreV1().Services(namespaceName).Get(t.Context(), serviceName, metaV1.GetOptions{})
if err != nil {
t.Log("Getting service failed: ", err.Error())
return false
@ -212,7 +211,7 @@ func testEndpointAvailable(t *testing.T, url string, allHostnames []string, reqI
assert := assert.New(t)
require := require.New(t)
req, err := http.NewRequestWithContext(context.Background(), http.MethodGet, url, http.NoBody)
req, err := http.NewRequestWithContext(t.Context(), http.MethodGet, url, http.NoBody)
require.NoError(err)
resp, err := http.DefaultClient.Do(req)

View file

@ -90,7 +90,7 @@ func testStatusEventuallyWorks(t *testing.T, cli string, timeout time.Duration)
// Show versions set in cluster.
// The string after "Cluster status:" in the output might not be updated yet.
// This is only updated after the operator finishes one reconcile loop.
cmd := exec.CommandContext(context.Background(), cli, "status")
cmd := exec.CommandContext(t.Context(), cli, "status")
stdout, stderr, err := runCommandWithSeparateOutputs(cmd)
if err != nil {
log.Printf("Stdout: %s\nStderr: %s", string(stdout), string(stderr))
@ -121,7 +121,7 @@ func testMicroservicesEventuallyHaveVersion(t *testing.T, wantMicroserviceVersio
func testNodesEventuallyHaveVersion(t *testing.T, k *kubernetes.Clientset, targetVersions VersionContainer, totalNodeCount int, timeout time.Duration) {
require.Eventually(t, func() bool {
nodes, err := k.CoreV1().Nodes().List(context.Background(), metaV1.ListOptions{})
nodes, err := k.CoreV1().Nodes().List(t.Context(), metaV1.ListOptions{})
if err != nil {
log.Println(err)
return false

View file

@ -72,7 +72,7 @@ func TestUpgrade(t *testing.T) {
targetVersions := WriteUpgradeConfig(require, *targetImage, *targetKubernetes, *targetMicroservices, constants.ConfigFilename)
log.Println("Fetching measurements for new image.")
cmd := exec.CommandContext(context.Background(), cli, "config", "fetch-measurements", "--insecure", "--debug")
cmd := exec.CommandContext(t.Context(), cli, "config", "fetch-measurements", "--insecure", "--debug")
stdout, stderr, err := runCommandWithSeparateOutputs(cmd)
require.NoError(err, "Stdout: %s\nStderr: %s", string(stdout), string(stderr))
log.Println(string(stdout))
@ -83,10 +83,10 @@ func TestUpgrade(t *testing.T) {
log.Println("Checking upgrade.")
assert := assert.New(t) // use assert because this part is more brittle and should not fail the entire test
runUpgradeCheck(assert, cli, *targetKubernetes)
runUpgradeCheck(t.Context(), assert, cli, *targetKubernetes)
log.Println("Triggering upgrade.")
runUpgradeApply(require, cli)
runUpgradeApply(t.Context(), require, cli)
AssertUpgradeSuccessful(t, cli, targetVersions, k, *wantControl, *wantWorker, *timeout)
}
@ -96,7 +96,7 @@ func TestUpgrade(t *testing.T) {
// 2) all pods have good status conditions.
func testPodsEventuallyReady(t *testing.T, k *kubernetes.Clientset, namespace string) {
require.Eventually(t, func() bool {
pods, err := k.CoreV1().Pods(namespace).List(context.Background(), metaV1.ListOptions{})
pods, err := k.CoreV1().Pods(namespace).List(t.Context(), metaV1.ListOptions{})
if err != nil {
log.Println(err)
return false
@ -127,7 +127,7 @@ func testPodsEventuallyReady(t *testing.T, k *kubernetes.Clientset, namespace st
// 2) the expected number of nodes have joined the cluster.
func testNodesEventuallyAvailable(t *testing.T, k *kubernetes.Clientset, wantControlNodeCount, wantWorkerNodeCount int) {
require.Eventually(t, func() bool {
nodes, err := k.CoreV1().Nodes().List(context.Background(), metaV1.ListOptions{})
nodes, err := k.CoreV1().Nodes().List(t.Context(), metaV1.ListOptions{})
if err != nil {
log.Println(err)
return false
@ -172,8 +172,8 @@ func testNodesEventuallyAvailable(t *testing.T, k *kubernetes.Clientset, wantCon
// runUpgradeCheck executes 'upgrade check' and does basic checks on the output.
// We can not check images upgrades because we might use unpublished images. CLI uses public CDN to check for available images.
func runUpgradeCheck(assert *assert.Assertions, cli, targetKubernetes string) {
cmd := exec.CommandContext(context.Background(), cli, "upgrade", "check", "--debug")
func runUpgradeCheck(ctx context.Context, assert *assert.Assertions, cli, targetKubernetes string) {
cmd := exec.CommandContext(ctx, cli, "upgrade", "check", "--debug")
stdout, stderr, err := runCommandWithSeparateOutputs(cmd)
assert.NoError(err, "Stdout: %s\nStderr: %s", string(stdout), string(stderr))
@ -204,16 +204,16 @@ func containsAny(text string, substrs []string) bool {
return false
}
func runUpgradeApply(require *require.Assertions, cli string) {
func runUpgradeApply(ctx context.Context, require *require.Assertions, cli string) {
tfLogFlag := ""
cmd := exec.CommandContext(context.Background(), cli, "--help")
cmd := exec.CommandContext(ctx, cli, "--help")
stdout, stderr, err := runCommandWithSeparateOutputs(cmd)
require.NoError(err, "Stdout: %s\nStderr: %s", string(stdout), string(stderr))
if strings.Contains(string(stdout), "--tf-log") {
tfLogFlag = "--tf-log=DEBUG"
}
cmd = exec.CommandContext(context.Background(), cli, "apply", "--debug", "--yes", tfLogFlag)
cmd = exec.CommandContext(ctx, cli, "apply", "--debug", "--yes", tfLogFlag)
stdout, stderr, err = runCommandWithSeparateOutputs(cmd)
require.NoError(err, "Stdout: %s\nStderr: %s", string(stdout), string(stderr))
require.NoError(containsUnexepectedMsg(string(stdout)))