mirror of
https://github.com/moby/moby.git
synced 2026-01-11 18:51:37 +00:00
Merge pull request #51253 from thaJeztah/rm_config_utils
internal/testutil/daemon: remove "Config" utilities
This commit is contained in:
@@ -12,6 +12,7 @@ import (
|
||||
"github.com/moby/moby/api/types/container"
|
||||
"github.com/moby/moby/api/types/mount"
|
||||
"github.com/moby/moby/api/types/swarm"
|
||||
"github.com/moby/moby/client"
|
||||
"github.com/moby/moby/v2/integration-cli/checker"
|
||||
"github.com/moby/moby/v2/internal/testutil"
|
||||
"gotest.tools/v3/assert"
|
||||
@@ -222,16 +223,20 @@ func (s *DockerSwarmSuite) TestServiceCreateWithSecretReferencedTwice(c *testing
|
||||
func (s *DockerSwarmSuite) TestServiceCreateWithConfigSimple(c *testing.T) {
|
||||
ctx := testutil.GetContext(c)
|
||||
d := s.AddDaemon(ctx, c, true, true)
|
||||
apiClient := d.NewClientT(c)
|
||||
|
||||
serviceName := "test-service-config"
|
||||
testName := "test_config"
|
||||
id := d.CreateConfig(c, swarm.ConfigSpec{
|
||||
Annotations: swarm.Annotations{
|
||||
Name: testName,
|
||||
result, err := apiClient.ConfigCreate(ctx, client.ConfigCreateOptions{
|
||||
Spec: swarm.ConfigSpec{
|
||||
Annotations: swarm.Annotations{
|
||||
Name: testName,
|
||||
},
|
||||
Data: []byte("TESTINGDATA"),
|
||||
},
|
||||
Data: []byte("TESTINGDATA"),
|
||||
})
|
||||
assert.Assert(c, id != "", "configs: %s", id)
|
||||
assert.NilError(c, err)
|
||||
assert.Assert(c, result.ID != "", "configs: %s", result.ID)
|
||||
|
||||
out, err := d.Cmd("service", "create", "--detach", "--no-resolve-image", "--name", serviceName, "--config", testName, "busybox", "top")
|
||||
assert.NilError(c, err, out)
|
||||
@@ -251,7 +256,8 @@ func (s *DockerSwarmSuite) TestServiceCreateWithConfigSimple(c *testing.T) {
|
||||
|
||||
out, err = d.Cmd("service", "rm", serviceName)
|
||||
assert.NilError(c, err, out)
|
||||
d.DeleteConfig(c, testName)
|
||||
_, err = apiClient.ConfigRemove(ctx, testName, client.ConfigRemoveOptions{})
|
||||
assert.NilError(c, err)
|
||||
}
|
||||
|
||||
func (s *DockerSwarmSuite) TestServiceCreateWithConfigSourceTargetPaths(c *testing.T) {
|
||||
@@ -266,15 +272,18 @@ func (s *DockerSwarmSuite) TestServiceCreateWithConfigSourceTargetPaths(c *testi
|
||||
|
||||
var configFlags []string
|
||||
|
||||
apiClient := d.NewClientT(c)
|
||||
for testName, testTarget := range testPaths {
|
||||
id := d.CreateConfig(c, swarm.ConfigSpec{
|
||||
Annotations: swarm.Annotations{
|
||||
Name: testName,
|
||||
result, err := apiClient.ConfigCreate(ctx, client.ConfigCreateOptions{
|
||||
Spec: swarm.ConfigSpec{
|
||||
Annotations: swarm.Annotations{
|
||||
Name: testName,
|
||||
},
|
||||
Data: []byte("TESTINGDATA " + testName + " " + testTarget),
|
||||
},
|
||||
Data: []byte("TESTINGDATA " + testName + " " + testTarget),
|
||||
})
|
||||
assert.Assert(c, id != "", "configs: %s", id)
|
||||
|
||||
assert.NilError(c, err)
|
||||
assert.Assert(c, result.ID != "", "configs: %s", result.ID)
|
||||
configFlags = append(configFlags, "--config", fmt.Sprintf("source=%s,target=%s", testName, testTarget))
|
||||
}
|
||||
|
||||
@@ -323,14 +332,17 @@ func (s *DockerSwarmSuite) TestServiceCreateWithConfigSourceTargetPaths(c *testi
|
||||
func (s *DockerSwarmSuite) TestServiceCreateWithConfigReferencedTwice(c *testing.T) {
|
||||
ctx := testutil.GetContext(c)
|
||||
d := s.AddDaemon(ctx, c, true, true)
|
||||
|
||||
id := d.CreateConfig(c, swarm.ConfigSpec{
|
||||
Annotations: swarm.Annotations{
|
||||
Name: "myconfig",
|
||||
apiClient := d.NewClientT(c)
|
||||
result, err := apiClient.ConfigCreate(ctx, client.ConfigCreateOptions{
|
||||
Spec: swarm.ConfigSpec{
|
||||
Annotations: swarm.Annotations{
|
||||
Name: "myconfig",
|
||||
},
|
||||
Data: []byte("TESTINGDATA"),
|
||||
},
|
||||
Data: []byte("TESTINGDATA"),
|
||||
})
|
||||
assert.Assert(c, id != "", "configs: %s", id)
|
||||
assert.NilError(c, err)
|
||||
assert.Assert(c, result.ID != "", "configs: %s", result.ID)
|
||||
|
||||
serviceName := "svc"
|
||||
out, err := d.Cmd("service", "create", "--detach", "--no-resolve-image", "--name", serviceName, "--config", "source=myconfig,target=target1", "--config", "source=myconfig,target=target2", "busybox", "top")
|
||||
|
||||
@@ -21,6 +21,7 @@ import (
|
||||
"github.com/cloudflare/cfssl/helpers"
|
||||
"github.com/moby/moby/api/types/swarm"
|
||||
"github.com/moby/moby/api/types/versions"
|
||||
"github.com/moby/moby/client"
|
||||
"github.com/moby/moby/v2/daemon/libnetwork/driverapi"
|
||||
"github.com/moby/moby/v2/daemon/libnetwork/ipamapi"
|
||||
remoteipam "github.com/moby/moby/v2/daemon/libnetwork/ipams/remote/api"
|
||||
@@ -2008,18 +2009,24 @@ func (s *DockerSwarmSuite) TestSwarmClusterEventsConfig(c *testing.T) {
|
||||
d := s.AddDaemon(ctx, c, true, true)
|
||||
|
||||
testName := "test_config"
|
||||
id := d.CreateConfig(c, swarm.ConfigSpec{
|
||||
Annotations: swarm.Annotations{
|
||||
Name: testName,
|
||||
apiClient := d.NewClientT(c)
|
||||
result, err := apiClient.ConfigCreate(ctx, client.ConfigCreateOptions{
|
||||
Spec: swarm.ConfigSpec{
|
||||
Annotations: swarm.Annotations{
|
||||
Name: testName,
|
||||
},
|
||||
Data: []byte("TESTINGDATA"),
|
||||
},
|
||||
Data: []byte("TESTINGDATA"),
|
||||
})
|
||||
assert.Assert(c, id != "", "configs: %s", id)
|
||||
assert.NilError(c, err)
|
||||
assert.Assert(c, result.ID != "", "configs: %s", result.ID)
|
||||
id := result.ID
|
||||
|
||||
waitForEvent(c, d, "0", "-f scope=swarm", "config create "+id, defaultRetryCount)
|
||||
|
||||
t1 := daemonUnixTime(c)
|
||||
d.DeleteConfig(c, id)
|
||||
_, err = apiClient.ConfigRemove(ctx, id, client.ConfigRemoveOptions{})
|
||||
assert.NilError(c, err)
|
||||
// filtered by config
|
||||
waitForEvent(c, d, t1, "-f type=config", "config remove "+id, defaultRetryCount)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user