golang: 1.20.7 -> 1.21 (#6189)

https://tip.golang.org/doc/go1.21

This required some test updates:

* topdown/tokens_test: adjust for go1.21

   What was correct for 1.20 is correct for 1.21, so I've flipped the exception logic.

* plugins/rest/TestClientCert: adapt cert-related error string

* internal/prometheus/TestJSONSerialization: add new metrics

   There are new metrics!

Signed-off-by: Stephan Renatus <stephan@styra.com>
This commit is contained in:
Stephan Renatus
2023-08-29 15:26:09 +02:00
committed by GitHub
parent 9f895711b1
commit f8e1e4bf2d
4 changed files with 41 additions and 7 deletions
+1 -1
View File
@@ -1 +1 @@
1.20.7
1.21
+24
View File
@@ -85,6 +85,13 @@ func TestJSONSerialization(t *testing.T) {
"go_sched_goroutines_goroutines",
"go_sched_gomaxprocs_threads",
"go_threads",
"go_gc_gomemlimit_bytes", // BEGIN added in 1.21
"go_gc_heap_live_bytes",
"go_gc_gogc_percent",
"go_gc_scan_globals_bytes",
"go_gc_scan_heap_bytes",
"go_gc_scan_stack_bytes",
"go_gc_scan_total_bytes",
},
"COUNTER": {
"go_gc_cycles_automatic_gc_cycles_total",
@@ -112,6 +119,23 @@ func TestJSONSerialization(t *testing.T) {
"go_cpu_classes_gc_total_cpu_seconds_total",
"go_sync_mutex_wait_total_seconds_total",
"go_cpu_classes_gc_pause_cpu_seconds_total",
"go_godebug_non_default_behavior_execerrdot_events_total", // BEGIN added in 1.21
"go_godebug_non_default_behavior_gocachehash_events_total",
"go_godebug_non_default_behavior_gocachetest_events_total",
"go_godebug_non_default_behavior_gocacheverify_events_total",
"go_godebug_non_default_behavior_http2client_events_total",
"go_godebug_non_default_behavior_http2server_events_total",
"go_godebug_non_default_behavior_installgoroot_events_total",
"go_godebug_non_default_behavior_jstmpllitinterp_events_total",
"go_godebug_non_default_behavior_panicnil_events_total",
"go_godebug_non_default_behavior_randautoseed_events_total",
"go_godebug_non_default_behavior_tarinsecurepath_events_total",
"go_godebug_non_default_behavior_multipartmaxheaders_events_total",
"go_godebug_non_default_behavior_multipartmaxparts_events_total",
"go_godebug_non_default_behavior_multipathtcp_events_total",
"go_godebug_non_default_behavior_x509sha1_events_total",
"go_godebug_non_default_behavior_x509usefallbackroots_events_total",
"go_godebug_non_default_behavior_zipinsecurepath_events_total",
},
"SUMMARY": {
"go_gc_duration_seconds",
+11 -3
View File
@@ -1274,9 +1274,17 @@ func TestClientCert(t *testing.T) {
// Ensure the keys don't work anymore, make a new client as the url will have changed
client = newTestClient(t, &ts, certPath, keyPath)
_, err := client.Do(ctx, "GET", "test")
expectedErrMsg := "tls: bad certificate"
if err == nil || !strings.Contains(err.Error(), expectedErrMsg) {
t.Fatalf("Expected '%s' error but request succeeded", expectedErrMsg)
expectedErrMsg := func(s string) bool {
switch {
case strings.Contains(s, "tls: unknown certificate authority"):
case strings.Contains(s, "tls: bad certificate"):
default:
return false
}
return true
}
if err == nil || !expectedErrMsg(err.Error()) {
t.Fatalf("Unexpected error %v", err)
}
// Update the key files and try again..
+5 -3
View File
@@ -471,9 +471,11 @@ func TestTopdownJWTEncodeSignECWithSeedReturnsSameSignature(t *testing.T) {
"y":"x_FEzRu9m36HLN_tue659LNpXW6pCyStikYjKIWI5a0",
"d":"jpsQnnGQmL-YBIffH1136cspYG6-0iY7X1fCE9-E9LI"
}, x)`
encodedSigned := "eyJhbGciOiAiRVMyNTYifQ.eyJwYXkiOiAibG9hZCJ9.05wmHY3NomU1jr7yvusBvKwhthRklPuJhUPOkoeIn5e5n_GXvE25EfRs9AJK2wOy6NoY2ljhj07M9BMtV0dfyA"
if strings.HasPrefix(runtime.Version(), "go1.20") {
encodedSigned = "eyJhbGciOiAiRVMyNTYifQ.eyJwYXkiOiAibG9hZCJ9.GRp6wIqDZuYnvQH50hnIy559LdrjUux76v1ynxX6lH0XtlgwreyR16x2JMnuElo79X3zUbqlWrZITICv86arew"
// go1.20 and beyond
encodedSigned := "eyJhbGciOiAiRVMyNTYifQ.eyJwYXkiOiAibG9hZCJ9.GRp6wIqDZuYnvQH50hnIy559LdrjUux76v1ynxX6lH0XtlgwreyR16x2JMnuElo79X3zUbqlWrZITICv86arew"
if strings.HasPrefix(runtime.Version(), "go1.19") { // we don't use go1.18 anymore
encodedSigned = "eyJhbGciOiAiRVMyNTYifQ.eyJwYXkiOiAibG9hZCJ9.05wmHY3NomU1jr7yvusBvKwhthRklPuJhUPOkoeIn5e5n_GXvE25EfRs9AJK2wOy6NoY2ljhj07M9BMtV0dfyA"
}
for i := 0; i < 10; i++ {