Browse code

Windows: Test for container servicing

Signed-off-by: John Howard <jhoward@microsoft.com>

John Howard authored on 2016/10/08 02:42:54
Showing 1 changed files
... ...
@@ -4538,3 +4538,22 @@ func (s *DockerSuite) TestRunCredentialSpecFailures(c *check.C) {
4538 4538
 		c.Assert(err.Error(), checker.Contains, attempt.expectedError, check.Commentf("%s expected %s got %s", attempt.value, attempt.expectedError, err))
4539 4539
 	}
4540 4540
 }
4541
+
4542
+// Windows specific test to ensure that a servicing app container is started
4543
+// if necessary once a container exits. It does this by forcing a no-op
4544
+// servicing event and verifying the event from Hyper-V-Compute
4545
+func (s *DockerSuite) TestRunServicingContainer(c *check.C) {
4546
+	testRequires(c, DaemonIsWindows, SameHostDaemon)
4547
+
4548
+	out, _ := dockerCmd(c, "run", "-d", WindowsBaseImage, "cmd", "/c", "mkdir c:\\programdata\\Microsoft\\Windows\\ContainerUpdates\\000_000_d99f45d0-ffc8-4af7-bd9c-ea6a62e035c9_200 && sc control cexecsvc 255")
4549
+	containerID := strings.TrimSpace(out)
4550
+	err := waitExited(containerID, 60*time.Second)
4551
+	c.Assert(err, checker.IsNil)
4552
+
4553
+	cmd := exec.Command("powershell", "echo", `(Get-WinEvent -ProviderName "Microsoft-Windows-Hyper-V-Compute" -FilterXPath 'Event[System[EventID=2010]]' -MaxEvents 1).Message`)
4554
+	out2, _, err := runCommandWithOutput(cmd)
4555
+	c.Assert(err, checker.IsNil)
4556
+	c.Assert(out2, checker.Contains, `"Servicing":true`, check.Commentf("Servicing container does not appear to have been started: %s", out2))
4557
+	c.Assert(out2, checker.Contains, `Windows Container (Servicing)`, check.Commentf("Didn't find 'Windows Container (Servicing): %s", out2))
4558
+	c.Assert(out2, checker.Contains, containerID+"_servicing", check.Commentf("Didn't find '%s_servicing': %s", containerID+"_servicing", out2))
4559
+}