use of com.yahoo.vespa.hosted.provision.node.Generation 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());
}
Aggregations