Skip to content

Commit

Permalink
golang: 1.20.7 -> 1.21 (#6189)
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
srenatus authored Aug 29, 2023
1 parent 9f89571 commit f8e1e4b
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 7 deletions.
2 changes: 1 addition & 1 deletion .go-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.20.7
1.21
24 changes: 24 additions & 0 deletions internal/prometheus/prometheus_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand Down
14 changes: 11 additions & 3 deletions plugins/rest/rest_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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..
Expand Down
8 changes: 5 additions & 3 deletions topdown/tokens_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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++ {
Expand Down

0 comments on commit f8e1e4b

Please sign in to comment.