Browse code

Docker EE integration test fixes

Signed-off-by: Christopher Crone <christopher.crone@docker.com>

Christopher Crone authored on 2017/09/25 21:09:17
Showing 2 changed files
... ...
@@ -81,7 +81,7 @@ func deleteAllContainers(t assert.TestingT, apiclient client.ContainerAPIClient,
81 81
 			Force:         true,
82 82
 			RemoveVolumes: true,
83 83
 		})
84
-		if err == nil || client.IsErrNotFound(err) || alreadyExists.MatchString(err.Error()) {
84
+		if err == nil || client.IsErrNotFound(err) || alreadyExists.MatchString(err.Error()) || isErrNotFoundSwarmClassic(err) {
85 85
 			continue
86 86
 		}
87 87
 		assert.NoError(t, err, "failed to remove %s", container.ID)
... ...
@@ -138,6 +138,10 @@ func deleteAllVolumes(t assert.TestingT, c client.VolumeAPIClient, protectedVolu
138 138
 			continue
139 139
 		}
140 140
 		err := c.VolumeRemove(context.Background(), v.Name, true)
141
+		// Docker EE may list volumes that no longer exist.
142
+		if isErrNotFoundSwarmClassic(err) {
143
+			continue
144
+		}
141 145
 		assert.NoError(t, err, "failed to remove volume %s", v.Name)
142 146
 	}
143 147
 }
... ...
@@ -164,6 +168,10 @@ func deleteAllNetworks(t assert.TestingT, c client.NetworkAPIClient, daemonPlatf
164 164
 
165 165
 func deleteAllPlugins(t assert.TestingT, c client.PluginAPIClient, protectedPlugins map[string]struct{}) {
166 166
 	plugins, err := c.PluginList(context.Background(), filters.Args{})
167
+	// Docker EE does not allow cluster-wide plugin management.
168
+	if client.IsErrNotImplemented(err) {
169
+		return
170
+	}
167 171
 	assert.NoError(t, err, "failed to list plugins")
168 172
 
169 173
 	for _, p := range plugins {
... ...
@@ -174,3 +182,9 @@ func deleteAllPlugins(t assert.TestingT, c client.PluginAPIClient, protectedPlug
174 174
 		assert.NoError(t, err, "failed to remove plugin %s", p.ID)
175 175
 	}
176 176
 }
177
+
178
+// Swarm classic aggregates node errors and returns a 500 so we need to check
179
+// the error string instead of just IsErrNotFound().
180
+func isErrNotFoundSwarmClassic(err error) bool {
181
+	return err != nil && strings.Contains(strings.ToLower(err.Error()), "no such")
182
+}
... ...
@@ -5,6 +5,7 @@ import (
5 5
 
6 6
 	"github.com/docker/docker/api/types"
7 7
 	"github.com/docker/docker/api/types/filters"
8
+	dclient "github.com/docker/docker/client"
8 9
 	"github.com/docker/docker/integration-cli/fixtures/load"
9 10
 	"github.com/stretchr/testify/require"
10 11
 )
... ...
@@ -172,6 +173,10 @@ func ProtectPlugins(t testingT, testEnv *Execution) {
172 172
 func getExistingPlugins(t require.TestingT, testEnv *Execution) []string {
173 173
 	client := testEnv.APIClient()
174 174
 	pluginList, err := client.PluginList(context.Background(), filters.Args{})
175
+	// Docker EE does not allow cluster-wide plugin management.
176
+	if dclient.IsErrNotImplemented(err) {
177
+		return []string{}
178
+	}
175 179
 	require.NoError(t, err, "failed to list plugins")
176 180
 
177 181
 	plugins := []string{}