Search in sources :

Example 1 with MockNodeRepository

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

the class AuthorizerTest method before.

@Before
public void before() {
    NodeFlavors flavors = new MockNodeFlavors();
    nodeRepository = new MockNodeRepository(new MockCurator(), flavors);
    authorizer = new Authorizer(SystemName.main, nodeRepository, () -> "cfg1");
    {
        // Populate with nodes used in this test. Note that only nodes requiring node repository lookup are added here
        Set<String> ipAddresses = new HashSet<>(Arrays.asList("127.0.0.1", "::1"));
        Flavor flavor = flavors.getFlavorOrThrow("default");
        List<Node> nodes = new ArrayList<>();
        nodes.add(nodeRepository.createNode("host1", "host1", ipAddresses, Optional.empty(), flavor, NodeType.host));
        nodes.add(nodeRepository.createNode("child1-1", "child1-1", ipAddresses, Optional.of("host1"), flavor, NodeType.tenant));
        nodes.add(nodeRepository.createNode("child1-2", "child1-2", ipAddresses, Optional.of("host1"), flavor, NodeType.tenant));
        nodes.add(nodeRepository.createNode("host2", "host2", ipAddresses, Optional.empty(), flavor, NodeType.host));
        nodes.add(nodeRepository.createNode("child2-1", "child2-1", ipAddresses, Optional.of("host1.tld"), flavor, NodeType.tenant));
        nodes.add(nodeRepository.createNode("proxy1", "proxy1", ipAddresses, Optional.empty(), flavor, NodeType.proxy));
        nodes.add(nodeRepository.createNode("proxy1-host1", "proxy1-host", ipAddresses, Optional.empty(), flavor, NodeType.proxyhost));
        nodeRepository.addNodes(nodes);
    }
}
Also used : MockNodeFlavors(com.yahoo.vespa.hosted.provision.testutils.MockNodeFlavors) Set(java.util.Set) HashSet(java.util.HashSet) NodeFlavors(com.yahoo.config.provision.NodeFlavors) MockNodeFlavors(com.yahoo.vespa.hosted.provision.testutils.MockNodeFlavors) MockNodeRepository(com.yahoo.vespa.hosted.provision.testutils.MockNodeRepository) ArrayList(java.util.ArrayList) List(java.util.List) Flavor(com.yahoo.config.provision.Flavor) MockCurator(com.yahoo.vespa.curator.mock.MockCurator) Before(org.junit.Before)

Aggregations

Flavor (com.yahoo.config.provision.Flavor)1 NodeFlavors (com.yahoo.config.provision.NodeFlavors)1 MockCurator (com.yahoo.vespa.curator.mock.MockCurator)1 MockNodeFlavors (com.yahoo.vespa.hosted.provision.testutils.MockNodeFlavors)1 MockNodeRepository (com.yahoo.vespa.hosted.provision.testutils.MockNodeRepository)1 ArrayList (java.util.ArrayList)1 HashSet (java.util.HashSet)1 List (java.util.List)1 Set (java.util.Set)1 Before (org.junit.Before)1