From 7406088853b6cbcb8996c367062cee2e1ee6eaaa Mon Sep 17 00:00:00 2001 From: Christopher Crone Date: Mon, 25 Sep 2017 13:58:51 +0200 Subject: [PATCH 1/4] Match not implemented error check to others Signed-off-by: Christopher Crone --- client/errors.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/client/errors.go b/client/errors.go index 3f52dfe5f6..ba29bce679 100644 --- a/client/errors.go +++ b/client/errors.go @@ -171,10 +171,10 @@ func (e notImplementedError) NotImplemented() bool { return true } -// IsNotImplementedError returns true if the error is a NotImplemented error. +// IsErrNotImplemented returns true if the error is a NotImplemented error. // This is returned by the API when a requested feature has not been // implemented. -func IsNotImplementedError(err error) bool { +func IsErrNotImplemented(err error) bool { te, ok := err.(notImplementedError) return ok && te.NotImplemented() } From d43dac2202667a407f4c5ab061c04b0ea334aa20 Mon Sep 17 00:00:00 2001 From: Christopher Crone Date: Mon, 25 Sep 2017 14:05:18 +0200 Subject: [PATCH 2/4] Protect environment for system integration tests Signed-off-by: Christopher Crone --- integration/system/main_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/integration/system/main_test.go b/integration/system/main_test.go index ad0d203753..575bbc166d 100644 --- a/integration/system/main_test.go +++ b/integration/system/main_test.go @@ -23,6 +23,6 @@ func TestMain(m *testing.M) { } func setupTest(t *testing.T) func() { - environment.ProtectImages(t, testEnv) + environment.ProtectAll(t, testEnv) return func() { testEnv.Clean(t) } } From 82440a039f58b6a1487f8042486fe8dba675df54 Mon Sep 17 00:00:00 2001 From: Christopher Crone Date: Mon, 25 Sep 2017 14:08:03 +0200 Subject: [PATCH 3/4] Do not use deprecated call for APIClient Signed-off-by: Christopher Crone --- integration/system/version_test.go | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/integration/system/version_test.go b/integration/system/version_test.go index 110bd9f56f..c1231fd383 100644 --- a/integration/system/version_test.go +++ b/integration/system/version_test.go @@ -3,15 +3,14 @@ package system import ( "testing" - "github.com/docker/docker/integration-cli/request" + "github.com/docker/docker/integration/util/request" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" "golang.org/x/net/context" ) func TestVersion(t *testing.T) { - client, err := request.NewClient() - require.NoError(t, err) + client := request.NewAPIClient(t) version, err := client.ServerVersion(context.Background()) require.NoError(t, err) From 8c5f98c93e06de81b7fb6416372a3f42aa7aeb5d Mon Sep 17 00:00:00 2001 From: Christopher Crone Date: Mon, 25 Sep 2017 14:09:17 +0200 Subject: [PATCH 4/4] Docker EE integration test fixes Signed-off-by: Christopher Crone --- internal/test/environment/clean.go | 16 +++++++++++++++- internal/test/environment/protect.go | 5 +++++ 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/internal/test/environment/clean.go b/internal/test/environment/clean.go index 1bdd21080a..e9548d1cde 100644 --- a/internal/test/environment/clean.go +++ b/internal/test/environment/clean.go @@ -81,7 +81,7 @@ func deleteAllContainers(t assert.TestingT, apiclient client.ContainerAPIClient, Force: true, RemoveVolumes: true, }) - if err == nil || client.IsErrNotFound(err) || alreadyExists.MatchString(err.Error()) { + if err == nil || client.IsErrNotFound(err) || alreadyExists.MatchString(err.Error()) || isErrNotFoundSwarmClassic(err) { continue } assert.NoError(t, err, "failed to remove %s", container.ID) @@ -138,6 +138,10 @@ func deleteAllVolumes(t assert.TestingT, c client.VolumeAPIClient, protectedVolu continue } err := c.VolumeRemove(context.Background(), v.Name, true) + // Docker EE may list volumes that no longer exist. + if isErrNotFoundSwarmClassic(err) { + continue + } assert.NoError(t, err, "failed to remove volume %s", v.Name) } } @@ -164,6 +168,10 @@ func deleteAllNetworks(t assert.TestingT, c client.NetworkAPIClient, daemonPlatf func deleteAllPlugins(t assert.TestingT, c client.PluginAPIClient, protectedPlugins map[string]struct{}) { plugins, err := c.PluginList(context.Background(), filters.Args{}) + // Docker EE does not allow cluster-wide plugin management. + if client.IsErrNotImplemented(err) { + return + } assert.NoError(t, err, "failed to list plugins") for _, p := range plugins { @@ -174,3 +182,9 @@ func deleteAllPlugins(t assert.TestingT, c client.PluginAPIClient, protectedPlug assert.NoError(t, err, "failed to remove plugin %s", p.ID) } } + +// Swarm classic aggregates node errors and returns a 500 so we need to check +// the error string instead of just IsErrNotFound(). +func isErrNotFoundSwarmClassic(err error) bool { + return err != nil && strings.Contains(strings.ToLower(err.Error()), "no such") +} diff --git a/internal/test/environment/protect.go b/internal/test/environment/protect.go index 3c74fcf1bb..296ae73789 100644 --- a/internal/test/environment/protect.go +++ b/internal/test/environment/protect.go @@ -5,6 +5,7 @@ import ( "github.com/docker/docker/api/types" "github.com/docker/docker/api/types/filters" + dclient "github.com/docker/docker/client" "github.com/docker/docker/integration-cli/fixtures/load" "github.com/stretchr/testify/require" ) @@ -172,6 +173,10 @@ func ProtectPlugins(t testingT, testEnv *Execution) { func getExistingPlugins(t require.TestingT, testEnv *Execution) []string { client := testEnv.APIClient() pluginList, err := client.PluginList(context.Background(), filters.Args{}) + // Docker EE does not allow cluster-wide plugin management. + if dclient.IsErrNotImplemented(err) { + return []string{} + } require.NoError(t, err, "failed to list plugins") plugins := []string{}