From a2edb5b64ecec9937cadde35929d1bc2cdbe0bc4 Mon Sep 17 00:00:00 2001 From: Djordje Lukic Date: Thu, 16 Jul 2020 10:01:49 +0200 Subject: [PATCH 1/2] Fix adding a tag to a container group --- azure/backend.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/azure/backend.go b/azure/backend.go index a605cb971..a1e541b32 100644 --- a/azure/backend.go +++ b/azure/backend.go @@ -196,16 +196,16 @@ func (cs *aciContainerService) Run(ctx context.Context, r containers.ContainerCo if err != nil { return err } - addTag(groupDefinition, singleContainerTag) + addTag(&groupDefinition, singleContainerTag) return createACIContainers(ctx, cs.ctx, groupDefinition) } -func addTag(groupDefinition containerinstance.ContainerGroup, tagName string) { +func addTag(groupDefinition *containerinstance.ContainerGroup, tagName string) { if groupDefinition.Tags == nil { groupDefinition.Tags = make(map[string]*string, 1) } - groupDefinition.Tags[tagName] = to.StringPtr("") + groupDefinition.Tags[tagName] = to.StringPtr(tagName) } func (cs *aciContainerService) Stop(ctx context.Context, containerName string, timeout *uint32) error { @@ -332,7 +332,7 @@ func (cs *aciComposeService) Up(ctx context.Context, opts cli.ProjectOptions) er } logrus.Debugf("Up on project with name %q\n", project.Name) groupDefinition, err := convert.ToContainerGroup(cs.ctx, *project) - addTag(groupDefinition, composeContainerTag) + addTag(&groupDefinition, composeContainerTag) if err != nil { return err From 4480d27595fd44c15f0729760046d9025d83d449 Mon Sep 17 00:00:00 2001 From: Djordje Lukic Date: Thu, 16 Jul 2020 10:39:41 +0200 Subject: [PATCH 2/2] Don't set the container name in the test This will help us catch errors such as https://github.com/docker/desktop-microsoft/issues/42 --- tests/aci-e2e/e2e-aci_test.go | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/tests/aci-e2e/e2e-aci_test.go b/tests/aci-e2e/e2e-aci_test.go index 7adcf6335..d1d2faffa 100644 --- a/tests/aci-e2e/e2e-aci_test.go +++ b/tests/aci-e2e/e2e-aci_test.go @@ -81,6 +81,7 @@ func (s *E2eACISuite) TestLoginLogoutCreateContextError() { } func (s *E2eACISuite) TestACIRunSingleContainer() { + var containerName string resourceGroupName := s.setupTestResourceGroup() defer deleteResourceGroup(resourceGroupName) @@ -105,8 +106,10 @@ func (s *E2eACISuite) TestACIRunSingleContainer() { "-v", fmt.Sprintf("%s:%s@%s:%s", testStorageAccountName, firstKey, testShareName, mountTarget), "-p", "80:80", - "--name", testContainerName).ExecOrDie() - Expect(output).To(ContainSubstring(testContainerName)) + ).ExecOrDie() + runOutput := Lines(output) + containerName = runOutput[len(runOutput)-1] + output = s.NewDockerCommand("ps").ExecOrDie() lines := Lines(output) Expect(len(lines)).To(Equal(2)) @@ -127,10 +130,10 @@ func (s *E2eACISuite) TestACIRunSingleContainer() { }) s.Step("exec command", func() { - output := s.NewDockerCommand("exec", testContainerName, "pwd").ExecOrDie() + output := s.NewDockerCommand("exec", containerName, "pwd").ExecOrDie() Expect(output).To(ContainSubstring("/")) - _, err := s.NewDockerCommand("exec", testContainerName, "echo", "fail_with_argument").Exec() + _, err := s.NewDockerCommand("exec", containerName, "echo", "fail_with_argument").Exec() Expect(err.Error()).To(ContainSubstring("ACI exec command does not accept arguments to the command. " + "Only the binary should be specified")) }) @@ -138,7 +141,7 @@ func (s *E2eACISuite) TestACIRunSingleContainer() { s.Step("follow logs from nginx", func() { timeChan := make(chan time.Time) - ctx := s.NewDockerCommand("logs", "--follow", testContainerName).WithTimeout(timeChan) + ctx := s.NewDockerCommand("logs", "--follow", containerName).WithTimeout(timeChan) outChan := make(chan string) go func() { @@ -163,8 +166,8 @@ func (s *E2eACISuite) TestACIRunSingleContainer() { }) s.Step("removes container nginx", func() { - output := s.NewDockerCommand("rm", testContainerName).ExecOrDie() - Expect(Lines(output)[0]).To(Equal(testContainerName)) + output := s.NewDockerCommand("rm", containerName).ExecOrDie() + Expect(Lines(output)[0]).To(Equal(containerName)) }) s.Step("re-run nginx with modified cpu/mem, and without --detach and follow logs", func() {