diff options
author | Martin Polden <mpolden@mpolden.no> | 2021-07-15 13:54:34 +0200 |
---|---|---|
committer | Martin Polden <mpolden@mpolden.no> | 2021-07-15 13:54:34 +0200 |
commit | b7775c901add178a1773eb25a576333e2096a107 (patch) | |
tree | 780a9ac9d3a686fea43caea8ce83cbd4119f16a1 | |
parent | 36ab145d9bb4504ce530202b2bf745181a7ba4a0 (diff) |
Document how to use RealDataScenarioTest
-rw-r--r-- | node-repository/src/test/java/com/yahoo/vespa/hosted/provision/RealDataScenarioTest.java | 21 |
1 files changed, 16 insertions, 5 deletions
diff --git a/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/RealDataScenarioTest.java b/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/RealDataScenarioTest.java index 2b180853d83..bdb93294cd1 100644 --- a/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/RealDataScenarioTest.java +++ b/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/RealDataScenarioTest.java @@ -35,6 +35,7 @@ import java.io.UncheckedIOException; import java.nio.file.Files; import java.nio.file.Path; import java.nio.file.Paths; +import java.util.Collection; import java.util.List; import java.util.concurrent.atomic.AtomicReference; import java.util.function.Consumer; @@ -49,13 +50,21 @@ import static com.yahoo.config.provision.NodeResources.DiskSpeed.fast; import static com.yahoo.config.provision.NodeResources.StorageType.local; import static com.yahoo.config.provision.NodeResources.StorageType.remote; import static java.nio.charset.StandardCharsets.UTF_8; +import static org.junit.Assert.assertEquals; /** * Scenario tester with real node-repository data loaded from ZK snapshot file * + * How to use: + * + * 1. Copy /opt/vespa/conf/configserver-app/node-flavors.xml from config server to /tmp/node-flavors.xml + * 2. Copy /opt/vespa/var/zookeeper/version-2/snapshot.XXX from config server to /tmp/snapshot + * 3. Set capacities and specs according to the wanted scenario + * * @author valerijf */ public class RealDataScenarioTest { + private static final Logger log = Logger.getLogger(RealDataScenarioTest.class.getSimpleName()); @Ignore @@ -63,11 +72,11 @@ public class RealDataScenarioTest { public void test() { ProvisioningTester tester = new ProvisioningTester.Builder() .zone(new Zone(Cloud.builder().dynamicProvisioning(true).build(), SystemName.defaultSystem(), Environment.prod, RegionName.defaultName())) - .flavorsConfig(parseFlavors(Paths.get(System.getProperty("user.home"), ".flavors.xml"))) + .flavorsConfig(parseFlavors(Paths.get("/tmp/node-flavors.xml"))) .nameResolver(new DnsNameResolver()) .spareCount(1) .build(); - initFromZk(tester.nodeRepository(), Paths.get(System.getProperty("user.home"), "snapshot")); + initFromZk(tester.nodeRepository(), Paths.get("/tmp/snapshot")); ApplicationId app = ApplicationId.from("tenant", "app", "default"); Version version = Version.fromString("7.123.4"); @@ -91,10 +100,11 @@ public class RealDataScenarioTest { } private void deploy(ProvisioningTester tester, ApplicationId app, ClusterSpec[] specs, Capacity[] capacities) { + assertEquals("Equal capacity and spec count", capacities.length, specs.length); List<HostSpec> hostSpecs = IntStream.range(0, capacities.length) - .mapToObj(i -> tester.provisioner().prepare(app, specs[i], capacities[i], log::log).stream()) - .flatMap(s -> s) - .collect(Collectors.toList()); + .mapToObj(i -> tester.provisioner().prepare(app, specs[i], capacities[i], log::log)) + .flatMap(Collection::stream) + .collect(Collectors.toList()); NestedTransaction transaction = new NestedTransaction(); tester.provisioner().activate(hostSpecs, new ActivationContext(0), new ApplicationTransaction(new ProvisionLock(app, () -> {}), transaction)); transaction.commit(); @@ -144,4 +154,5 @@ public class RealDataScenarioTest { throw new UncheckedIOException(e); } } + } |