Commit 62fc646c authored by Felix Geyer's avatar Felix Geyer

Cherry-pick upstream commits to fix test failures with golang >= 1.11.6-1+deb10u1

parent 0d965646
......@@ -43,3 +43,6 @@ test--skip-TestGetRootUIDGID.patch
test--skip-TestStateRunStop.patch
test--skip-network-tests.patch
test--skip-privileged-unit-tests.patch
test--cli-fix-golang11.patch
test--cli-fix-golang12.patch
test--engine-fix-golang11.patch
From de1523d221d7e719fe470c63c3cd908092e772df Mon Sep 17 00:00:00 2001
From: Sebastiaan van Stijn <github@gone.nl>
Date: Wed, 14 Aug 2019 10:04:43 +0200
Subject: [PATCH] Adjust tests for changes in Go 1.12.8 / 1.11.13
For now, just verifying that an error is returned, but not checking the
error message itself, because those are not under our control, and may
change with different Go versions.
```
=== Failed
=== FAIL: opts TestParseDockerDaemonHost (0.00s)
hosts_test.go:87: tcp tcp:a.b.c.d address expected error "Invalid bind address format: tcp:a.b.c.d" return, got "parse tcp://tcp:a.b.c.d: invalid port \":a.b.c.d\" after host" and addr
hosts_test.go:87: tcp tcp:a.b.c.d/path address expected error "Invalid bind address format: tcp:a.b.c.d/path" return, got "parse tcp://tcp:a.b.c.d/path: invalid port \":a.b.c.d\" after host" and addr
=== FAIL: opts TestParseTCP (0.00s)
hosts_test.go:129: tcp tcp:a.b.c.d address expected error Invalid bind address format: tcp:a.b.c.d return, got parse tcp://tcp:a.b.c.d: invalid port ":a.b.c.d" after host and addr
hosts_test.go:129: tcp tcp:a.b.c.d/path address expected error Invalid bind address format: tcp:a.b.c.d/path return, got parse tcp://tcp:a.b.c.d/path: invalid port ":a.b.c.d" after host and addr
```
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
--- docker.io-18.09.1+dfsg1.orig/cli/opts/hosts_test.go
+++ docker.io-18.09.1+dfsg1/cli/opts/hosts_test.go
@@ -53,8 +53,8 @@ func TestParseHost(t *testing.T) {
func TestParseDockerDaemonHost(t *testing.T) {
invalids := map[string]string{
- "tcp:a.b.c.d": "Invalid bind address format: tcp:a.b.c.d",
- "tcp:a.b.c.d/path": "Invalid bind address format: tcp:a.b.c.d/path",
+ "tcp:a.b.c.d": "",
+ "tcp:a.b.c.d/path": "",
"udp://127.0.0.1": "Invalid bind address format: udp://127.0.0.1",
"udp://127.0.0.1:2375": "Invalid bind address format: udp://127.0.0.1:2375",
"tcp://unix:///run/docker.sock": "Invalid proto, expected tcp: unix:///run/docker.sock",
@@ -83,7 +83,7 @@ func TestParseDockerDaemonHost(t *testin
"localhost:5555/path": "tcp://localhost:5555/path",
}
for invalidAddr, expectedError := range invalids {
- if addr, err := parseDockerDaemonHost(invalidAddr); err == nil || err.Error() != expectedError {
+ if addr, err := parseDockerDaemonHost(invalidAddr); err == nil || expectedError != "" && err.Error() != expectedError {
t.Errorf("tcp %v address expected error %q return, got %q and addr %v", invalidAddr, expectedError, err, addr)
}
}
@@ -99,8 +99,8 @@ func TestParseTCP(t *testing.T) {
defaultHTTPHost = "tcp://127.0.0.1:2376"
)
invalids := map[string]string{
- "tcp:a.b.c.d": "Invalid bind address format: tcp:a.b.c.d",
- "tcp:a.b.c.d/path": "Invalid bind address format: tcp:a.b.c.d/path",
+ "tcp:a.b.c.d": "",
+ "tcp:a.b.c.d/path": "",
"udp://127.0.0.1": "Invalid proto, expected tcp: udp://127.0.0.1",
"udp://127.0.0.1:2375": "Invalid proto, expected tcp: udp://127.0.0.1:2375",
}
@@ -125,7 +125,7 @@ func TestParseTCP(t *testing.T) {
"localhost:5555/path": "tcp://localhost:5555/path",
}
for invalidAddr, expectedError := range invalids {
- if addr, err := ParseTCPAddr(invalidAddr, defaultHTTPHost); err == nil || err.Error() != expectedError {
+ if addr, err := ParseTCPAddr(invalidAddr, defaultHTTPHost); err == nil || expectedError != "" && err.Error() != expectedError {
t.Errorf("tcp %v address expected error %v return, got %s and addr %v", invalidAddr, expectedError, err, addr)
}
}
From 7ea48a16e3eac8772f7e10bbf404ee6a2fd909ac Mon Sep 17 00:00:00 2001
From: Sebastiaan van Stijn <github@gone.nl>
Date: Mon, 4 Mar 2019 18:44:07 +0100
Subject: [PATCH] Fix test for Go 1.12.x
After switching to Go 1.12, the format-string causes an error;
```
=== Errors
cli/config/config_test.go:154:3: Fatalf format %q has arg config of wrong type *github.com/docker/cli/cli/config/configfile.ConfigFile
cli/config/config_test.go:217:3: Fatalf format %q has arg config of wrong type *github.com/docker/cli/cli/config/configfile.ConfigFile
cli/config/config_test.go:253:3: Fatalf format %q has arg config of wrong type *github.com/docker/cli/cli/config/configfile.ConfigFile
cli/config/config_test.go:288:3: Fatalf format %q has arg config of wrong type *github.com/docker/cli/cli/config/configfile.ConfigFile
cli/config/config_test.go:435:3: Fatalf format %q has arg config of wrong type *github.com/docker/cli/cli/config/configfile.ConfigFile
cli/config/config_test.go:448:3: Fatalf format %q has arg config of wrong type *github.com/docker/cli/cli/config/configfile.ConfigFile
DONE 1115 tests, 2 skipped, 6 errors in 215.984s
make: *** [Makefile:22: test-coverage] Error 2
Exited with code 2
```
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
(cherry picked from commit d4877fb2259feac2c76762ccd3001999cb7f0d58)
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
--- docker.io-18.09.1+dfsg1.orig/cli/cli/config/config_test.go
+++ docker.io-18.09.1+dfsg1/cli/cli/config/config_test.go
@@ -150,9 +150,8 @@ func TestOldValidAuth(t *testing.T) {
// defaultIndexserver is https://index.docker.io/v1/
ac := config.AuthConfigs["https://index.docker.io/v1/"]
- if ac.Username != "joejoe" || ac.Password != "hello" {
- t.Fatalf("Missing data from parsing:\n%q", config)
- }
+ assert.Equal(t, ac.Username, "joejoe")
+ assert.Equal(t, ac.Password, "hello")
// Now save it and make sure it shows up in new form
configStr := saveConfigAndValidateNewFormat(t, config, tmpHome)
@@ -213,9 +212,8 @@ func TestOldJSON(t *testing.T) {
assert.NilError(t, err)
ac := config.AuthConfigs["https://index.docker.io/v1/"]
- if ac.Username != "joejoe" || ac.Password != "hello" {
- t.Fatalf("Missing data from parsing:\n%q", config)
- }
+ assert.Equal(t, ac.Username, "joejoe")
+ assert.Equal(t, ac.Password, "hello")
// Now save it and make sure it shows up in new form
configStr := saveConfigAndValidateNewFormat(t, config, tmpHome)
@@ -249,9 +247,8 @@ func TestNewJSON(t *testing.T) {
assert.NilError(t, err)
ac := config.AuthConfigs["https://index.docker.io/v1/"]
- if ac.Username != "joejoe" || ac.Password != "hello" {
- t.Fatalf("Missing data from parsing:\n%q", config)
- }
+ assert.Equal(t, ac.Username, "joejoe")
+ assert.Equal(t, ac.Password, "hello")
// Now save it and make sure it shows up in new form
configStr := saveConfigAndValidateNewFormat(t, config, tmpHome)
@@ -284,9 +281,8 @@ func TestNewJSONNoEmail(t *testing.T) {
assert.NilError(t, err)
ac := config.AuthConfigs["https://index.docker.io/v1/"]
- if ac.Username != "joejoe" || ac.Password != "hello" {
- t.Fatalf("Missing data from parsing:\n%q", config)
- }
+ assert.Equal(t, ac.Username, "joejoe")
+ assert.Equal(t, ac.Password, "hello")
// Now save it and make sure it shows up in new form
configStr := saveConfigAndValidateNewFormat(t, config, tmpHome)
@@ -431,10 +427,8 @@ func TestJSONReaderNoFile(t *testing.T)
assert.NilError(t, err)
ac := config.AuthConfigs["https://index.docker.io/v1/"]
- if ac.Username != "joejoe" || ac.Password != "hello" {
- t.Fatalf("Missing data from parsing:\n%q", config)
- }
-
+ assert.Equal(t, ac.Username, "joejoe")
+ assert.Equal(t, ac.Password, "hello")
}
func TestOldJSONReaderNoFile(t *testing.T) {
@@ -444,9 +438,8 @@ func TestOldJSONReaderNoFile(t *testing.
assert.NilError(t, err)
ac := config.AuthConfigs["https://index.docker.io/v1/"]
- if ac.Username != "joejoe" || ac.Password != "hello" {
- t.Fatalf("Missing data from parsing:\n%q", config)
- }
+ assert.Equal(t, ac.Username, "joejoe")
+ assert.Equal(t, ac.Password, "hello")
}
func TestJSONWithPsFormatNoFile(t *testing.T) {
From 64c958a587ff3835d1bacc573e9db3d400dbb0ad Mon Sep 17 00:00:00 2001
From: Sebastiaan van Stijn <github@gone.nl>
Date: Wed, 14 Aug 2019 02:51:08 +0200
Subject: [PATCH] Adjust tests for changes in Go 1.12.8 / 1.11.13
```
00:38:11 === Failed
00:38:11 === FAIL: opts TestParseDockerDaemonHost (0.00s)
00:38:11 hosts_test.go:87: tcp tcp:a.b.c.d address expected error "Invalid bind address format: tcp:a.b.c.d" return, got "parse tcp://tcp:a.b.c.d: invalid port \":a.b.c.d\" after host" and addr
00:38:11 hosts_test.go:87: tcp tcp:a.b.c.d/path address expected error "Invalid bind address format: tcp:a.b.c.d/path" return, got "parse tcp://tcp:a.b.c.d/path: invalid port \":a.b.c.d\" after host" and addr
00:38:11
00:38:11 === FAIL: opts TestParseTCP (0.00s)
00:38:11 hosts_test.go:129: tcp tcp:a.b.c.d address expected error Invalid bind address format: tcp:a.b.c.d return, got parse tcp://tcp:a.b.c.d: invalid port ":a.b.c.d" after host and addr
00:38:11 hosts_test.go:129: tcp tcp:a.b.c.d/path address expected error Invalid bind address format: tcp:a.b.c.d/path return, got parse tcp://tcp:a.b.c.d/path: invalid port ":a.b.c.d" after host and addr
```
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
(cherry picked from commit 683766613a8c1dca8f95b19ddb7e083bb3aef266)
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
--- docker.io-18.09.1+dfsg1.orig/engine/opts/hosts_test.go
+++ docker.io-18.09.1+dfsg1/engine/opts/hosts_test.go
@@ -53,8 +53,8 @@ func TestParseHost(t *testing.T) {
func TestParseDockerDaemonHost(t *testing.T) {
invalids := map[string]string{
- "tcp:a.b.c.d": "Invalid bind address format: tcp:a.b.c.d",
- "tcp:a.b.c.d/path": "Invalid bind address format: tcp:a.b.c.d/path",
+ "tcp:a.b.c.d": "",
+ "tcp:a.b.c.d/path": "",
"udp://127.0.0.1": "Invalid bind address format: udp://127.0.0.1",
"udp://127.0.0.1:2375": "Invalid bind address format: udp://127.0.0.1:2375",
"tcp://unix:///run/docker.sock": "Invalid proto, expected tcp: unix:///run/docker.sock",
@@ -83,7 +83,7 @@ func TestParseDockerDaemonHost(t *testin
"localhost:5555/path": "tcp://localhost:5555/path",
}
for invalidAddr, expectedError := range invalids {
- if addr, err := parseDaemonHost(invalidAddr); err == nil || err.Error() != expectedError {
+ if addr, err := parseDaemonHost(invalidAddr); err == nil || expectedError != "" && err.Error() != expectedError {
t.Errorf("tcp %v address expected error %q return, got %q and addr %v", invalidAddr, expectedError, err, addr)
}
}
@@ -99,8 +99,8 @@ func TestParseTCP(t *testing.T) {
defaultHTTPHost = "tcp://127.0.0.1:2376"
)
invalids := map[string]string{
- "tcp:a.b.c.d": "Invalid bind address format: tcp:a.b.c.d",
- "tcp:a.b.c.d/path": "Invalid bind address format: tcp:a.b.c.d/path",
+ "tcp:a.b.c.d": "",
+ "tcp:a.b.c.d/path": "",
"udp://127.0.0.1": "Invalid proto, expected tcp: udp://127.0.0.1",
"udp://127.0.0.1:2375": "Invalid proto, expected tcp: udp://127.0.0.1:2375",
}
@@ -125,7 +125,7 @@ func TestParseTCP(t *testing.T) {
"localhost:5555/path": "tcp://localhost:5555/path",
}
for invalidAddr, expectedError := range invalids {
- if addr, err := ParseTCPAddr(invalidAddr, defaultHTTPHost); err == nil || err.Error() != expectedError {
+ if addr, err := ParseTCPAddr(invalidAddr, defaultHTTPHost); err == nil || expectedError != "" && err.Error() != expectedError {
t.Errorf("tcp %v address expected error %v return, got %s and addr %v", invalidAddr, expectedError, err, addr)
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment