private static void initFromZk(NodeRepository nodeRepository, Path pathToZkSnapshot) throws Exception {
        NodeSerializer nodeSerializer = new NodeSerializer(nodeRepository.flavors(), CloudAccount.from("aws:999123456789"));
        Map<Pattern, BiConsumer<byte[], NestedTransaction>> jsonConsumerByPathPattern = Map.of(
                Pattern.compile(".?/provision/v1/nodes/[a-z0-9.-]+\\.(com|cloud).?"), (json, transaction) -> {
                    Node node = nodeSerializer.fromJson(json);
                    nodeRepository.database().addNodesInState(new LockedNodeList(List.of(node), () -> { }), node.state(), Agent.system, transaction);
                },
                Pattern.compile(".?/provision/v1/applications/[a-z0-9:-]+.?"), (json, transaction) ->
                        nodeRepository.database().writeApplication(ApplicationSerializer.fromJson(json), transaction));

        try (StringsIterator iterator = new StringsIterator(pathToZkSnapshot); NestedTransaction transaction = new NestedTransaction()) {
            while (iterator.hasNext()) {
                String s1 = iterator.next();
                if (!iterator.hasNext()) break;
                for (var entry : jsonConsumerByPathPattern.entrySet()) {
                    if (!entry.getKey().matcher(s1).matches()) continue;
                    String s2 = iterator.next();
                    byte[] json = s2.substring(s2.indexOf("{\""), s2.lastIndexOf('}') + 1).getBytes(UTF_8);
                    entry.getValue().accept(json, transaction);
                    break;
                }
            }
            transaction.commit();
        }
    }
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
node-repository/src/test/java/com/yahoo/vespa/hosted/provision/RealDataScenarioTest.java