blob: dad02f46d88280011f8250994ce22356b72973aa (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
|
// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.vespa.hosted.node.admin.integration;
import com.yahoo.config.provision.DockerImage;
import com.yahoo.vespa.hosted.node.admin.container.ContainerName;
import com.yahoo.vespa.hosted.node.admin.configserver.noderepository.NodeSpec;
import com.yahoo.vespa.hosted.node.admin.nodeadmin.NodeAdminStateUpdater;
import org.junit.Test;
import java.util.List;
import static com.yahoo.vespa.hosted.node.admin.integration.ContainerTester.HOST_HOSTNAME;
import static com.yahoo.vespa.hosted.node.admin.integration.ContainerTester.containerMatcher;
import static org.junit.Assert.assertTrue;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.eq;
/**
* Tests rebooting of Docker host
*
* @author musum
*/
public class RebootTest {
private final String hostname = "host1.test.yahoo.com";
private final DockerImage dockerImage = DockerImage.fromString("registry.example.com/dockerImage");
@Test
public void test() {
try (ContainerTester tester = new ContainerTester()) {
tester.addChildNodeRepositoryNode(NodeSpec.Builder.testSpec(hostname).wantedDockerImage(dockerImage).build());
ContainerName host1 = new ContainerName("host1");
tester.inOrder(tester.containerOperations).createContainer(containerMatcher(host1), any(), any());
try {
tester.setWantedState(NodeAdminStateUpdater.State.SUSPENDED);
} catch (RuntimeException ignored) { }
tester.inOrder(tester.orchestrator).suspend(
eq(HOST_HOSTNAME.value()), eq(List.of(hostname, HOST_HOSTNAME.value())));
tester.inOrder(tester.containerOperations).stopServices(containerMatcher(host1));
assertTrue(tester.nodeAdmin.setFrozen(true));
}
}
}
|