Search in sources :

Example 81 with Node

use of com.yahoo.vespa.hosted.provision.Node in project vespa by vespa-engine.

the class SerializationTest method testSetFailCount.

@Test
public void testSetFailCount() {
    Node node = createNode();
    node = node.allocate(ApplicationId.from(TenantName.from("myTenant"), ApplicationName.from("myApplication"), InstanceName.from("myInstance")), ClusterMembership.from("content/myId/0/0", Vtag.currentVersion), clock.instant());
    node = node.with(node.status().setFailCount(0));
    Node copy2 = nodeSerializer.fromJson(Node.State.provisioned, nodeSerializer.toJson(node));
    assertEquals(0, copy2.status().failCount());
}
Also used : Node(com.yahoo.vespa.hosted.provision.Node) Test(org.junit.Test)

Example 82 with Node

use of com.yahoo.vespa.hosted.provision.Node in project vespa by vespa-engine.

the class SerializationTest method testReservedNodeSerialization.

@Test
public void testReservedNodeSerialization() {
    Node node = createNode();
    clock.advance(Duration.ofMinutes(3));
    assertEquals(0, node.history().events().size());
    node = node.allocate(ApplicationId.from(TenantName.from("myTenant"), ApplicationName.from("myApplication"), InstanceName.from("myInstance")), ClusterMembership.from("content/myId/0/0", Vtag.currentVersion), clock.instant());
    assertEquals(1, node.history().events().size());
    node = node.withRestart(new Generation(1, 2));
    node = node.withReboot(new Generation(3, 4));
    node = node.with(FlavorConfigBuilder.createDummies("large").getFlavorOrThrow("large"));
    node = node.with(node.status().withVespaVersion(Version.fromString("1.2.3")));
    node = node.with(node.status().withIncreasedFailCount().withIncreasedFailCount());
    node = node.with(node.status().withHardwareFailureDescription(Optional.of("memory_mcelog")));
    node = node.with(NodeType.tenant);
    Node copy = nodeSerializer.fromJson(Node.State.provisioned, nodeSerializer.toJson(node));
    assertEquals(node.id(), copy.id());
    assertEquals(node.hostname(), copy.hostname());
    assertEquals(node.state(), copy.state());
    assertEquals(1, copy.allocation().get().restartGeneration().wanted());
    assertEquals(2, copy.allocation().get().restartGeneration().current());
    assertEquals(3, copy.status().reboot().wanted());
    assertEquals(4, copy.status().reboot().current());
    assertEquals("large", copy.flavor().name());
    assertEquals("1.2.3", copy.status().vespaVersion().get().toString());
    assertEquals(2, copy.status().failCount());
    assertEquals("memory_mcelog", copy.status().hardwareFailureDescription().get());
    assertEquals(node.allocation().get().owner(), copy.allocation().get().owner());
    assertEquals(node.allocation().get().membership(), copy.allocation().get().membership());
    assertEquals(node.allocation().get().isRemovable(), copy.allocation().get().isRemovable());
    assertEquals(1, copy.history().events().size());
    assertEquals(clock.instant(), copy.history().event(History.Event.Type.reserved).get().at());
    assertEquals(NodeType.tenant, copy.type());
}
Also used : Generation(com.yahoo.vespa.hosted.provision.node.Generation) Node(com.yahoo.vespa.hosted.provision.Node) Test(org.junit.Test)

Example 83 with Node

use of com.yahoo.vespa.hosted.provision.Node in project vespa by vespa-engine.

the class SerializationTest method testAssimilatedDeserialization.

@Test
public void testAssimilatedDeserialization() {
    Node node = nodeSerializer.fromJson(Node.State.active, ("{\n" + "  \"type\": \"tenant\",\n" + "  \"hostname\": \"assimilate2.vespahosted.yahoo.tld\",\n" + "  \"ipAddresses\": [\"127.0.0.1\"],\n" + "  \"openStackId\": \"\",\n" + "  \"flavor\": \"ugccloud-container\",\n" + "  \"instance\": {\n" + "    \"tenantId\": \"by_mortent\",\n" + "    \"applicationId\": \"ugc-assimilate\",\n" + "    \"instanceId\": \"default\",\n" + "    \"serviceId\": \"container/ugccloud-container/0/0\",\n" + "    \"restartGeneration\": 0,\n" + "    \"wantedVespaVersion\": \"6.42.2\"\n" + "  }\n" + "}\n").getBytes());
    assertEquals(0, node.history().events().size());
    assertTrue(node.allocation().isPresent());
    assertEquals("ugccloud-container", node.allocation().get().membership().cluster().id().value());
    assertEquals("container", node.allocation().get().membership().cluster().type().name());
    assertEquals(0, node.allocation().get().membership().cluster().group().get().index());
    Node copy = nodeSerializer.fromJson(Node.State.provisioned, nodeSerializer.toJson(node));
    assertEquals(0, copy.history().events().size());
}
Also used : Node(com.yahoo.vespa.hosted.provision.Node) Test(org.junit.Test)

Example 84 with Node

use of com.yahoo.vespa.hosted.provision.Node in project vespa by vespa-engine.

the class SerializationTest method testRebootAndRestartAndTypeNoCurrentValuesSerialization.

@Test
public void testRebootAndRestartAndTypeNoCurrentValuesSerialization() {
    String nodeData = "{\n" + "   \"type\" : \"tenant\",\n" + "   \"rebootGeneration\" : 1,\n" + "   \"currentRebootGeneration\" : 2,\n" + "   \"flavor\" : \"large\",\n" + "   \"history\" : [\n" + "      {\n" + "         \"type\" : \"provisioned\",\n" + "         \"at\" : 1444391401389\n" + "      },\n" + "      {\n" + "         \"type\" : \"reserved\",\n" + "         \"at\" : 1444391402611\n" + "      }\n" + "   ],\n" + "   \"instance\" : {\n" + "      \"applicationId\" : \"myApplication\",\n" + "      \"tenantId\" : \"myTenant\",\n" + "      \"instanceId\" : \"myInstance\",\n" + "      \"serviceId\" : \"content/myId/0/0\",\n" + "      \"restartGeneration\" : 3,\n" + "      \"currentRestartGeneration\" : 4,\n" + "      \"removable\" : true,\n" + "      \"wantedVespaVersion\": \"6.42.2\"\n" + "   },\n" + "   \"openStackId\" : \"myId\",\n" + "   \"hostname\" : \"myHostname\",\n" + "   \"ipAddresses\" : [\"127.0.0.1\"]\n" + "}";
    Node node = nodeSerializer.fromJson(Node.State.provisioned, Utf8.toBytes(nodeData));
    assertEquals("large", node.flavor().canonicalName());
    assertEquals(1, node.status().reboot().wanted());
    assertEquals(2, node.status().reboot().current());
    assertEquals(3, node.allocation().get().restartGeneration().wanted());
    assertEquals(4, node.allocation().get().restartGeneration().current());
    assertEquals(Arrays.asList(History.Event.Type.provisioned, History.Event.Type.reserved), node.history().events().stream().map(History.Event::type).collect(Collectors.toList()));
    assertTrue(node.allocation().get().isRemovable());
    assertEquals(NodeType.tenant, node.type());
}
Also used : Node(com.yahoo.vespa.hosted.provision.Node) Test(org.junit.Test)

Example 85 with Node

use of com.yahoo.vespa.hosted.provision.Node in project vespa by vespa-engine.

the class SerializationTest method serialize_parentHostname.

@Test
public void serialize_parentHostname() {
    final String parentHostname = "parent.yahoo.com";
    Node node = Node.create("myId", singleton("127.0.0.1"), Collections.emptySet(), "myHostname", Optional.of(parentHostname), nodeFlavors.getFlavorOrThrow("default"), NodeType.tenant);
    Node deserializedNode = nodeSerializer.fromJson(State.provisioned, nodeSerializer.toJson(node));
    assertEquals(parentHostname, deserializedNode.parentHostname().get());
}
Also used : Node(com.yahoo.vespa.hosted.provision.Node) Test(org.junit.Test)

Aggregations

Node (com.yahoo.vespa.hosted.provision.Node)121 Test (org.junit.Test)67 ApplicationId (com.yahoo.config.provision.ApplicationId)40 ClusterSpec (com.yahoo.config.provision.ClusterSpec)33 List (java.util.List)26 ArrayList (java.util.ArrayList)23 Zone (com.yahoo.config.provision.Zone)22 Flavor (com.yahoo.config.provision.Flavor)21 HashSet (java.util.HashSet)19 Collectors (java.util.stream.Collectors)19 Optional (java.util.Optional)18 NodeRepository (com.yahoo.vespa.hosted.provision.NodeRepository)16 Duration (java.time.Duration)16 HostSpec (com.yahoo.config.provision.HostSpec)15 NodeType (com.yahoo.config.provision.NodeType)15 Agent (com.yahoo.vespa.hosted.provision.node.Agent)13 Map (java.util.Map)13 HashMap (java.util.HashMap)12 Collections (java.util.Collections)11 Set (java.util.Set)11