Package org.jclouds.chef.domain

Examples of org.jclouds.chef.domain.Node


   @Test(dependsOnMethods = "testCreateRole")
   public void testCreateNode() throws Exception {
      api.deleteNode(PREFIX);
      api.createNode(Node.builder().name(PREFIX).runListElement("role[" + PREFIX + "]").environment("_default").build());
      Node node = api.getNode(PREFIX);
      // TODO check recipes
      assertNotNull(node, "Created node should not be null");
      Set<String> nodes = api.listNodes();
      assertTrue(nodes.contains(PREFIX), String.format("node %s not in %s", PREFIX, nodes));
   }
View Full Code Here


   }

   @Test(dependsOnMethods = "testCreateNode")
   public void testUpdateNode() throws Exception {
      for (String nodename : api.listNodes()) {
         Node node = api.getNode(nodename);
         api.updateNode(node);
      }
   }
View Full Code Here

   @Test(dependsOnMethods = "testCreateEnvironment")
   public void testListNodesInEnvironment() {
      api.deleteNode(ENV_NODE);
      api.createNode(Node.builder().name(ENV_NODE).runListElement("role[" + PREFIX + "]").environment(PREFIX).build());
      Node node = api.getNode(ENV_NODE);
      assertNotNull(node, "Created node should not be null");
      Set<String> nodeList = api.listNodesInEnvironment(PREFIX);
      assertTrue(!nodeList.isEmpty());
   }
View Full Code Here

   public void test() {
      ChefApi chef = createMock(ChefApi.class);

      Map<String, JsonBall> automatic = ImmutableMap.<String, JsonBall> of();

      Node node = new Node("name", ImmutableSet.<String> of(), "_default");

      Supplier<Map<String, JsonBall>> automaticSupplier = Suppliers.<Map<String, JsonBall>> ofInstance(automatic);

      Node nodeWithAutomatic = new Node("name", ImmutableMap.<String, JsonBall> of(),
            ImmutableMap.<String, JsonBall> of(), ImmutableMap.<String, JsonBall> of(), automatic,
            ImmutableSet.<String> of(), "_default");

      expect(chef.getNode("name")).andReturn(node);
      node.getAutomatic().putAll(automaticSupplier.get());
View Full Code Here

   @Test
   public void testExecute() {
      Set<String> runList = ImmutableSet.of("role[" + prefix + "]");
      try {
         api.createNode(new Node(prefix, runList, "_default"));
         strategy.execute(prefix);
         Node node = api.getNode(prefix);
         assertEquals(node.getName(), prefix);
         assertEquals(node.getRunList(), runList);
         assertEquals(node.getAutomatic().get("current_user").toString(), currentUserProvider.get().toString());
      } finally {
         api.deleteNode(prefix);
      }
   }
View Full Code Here

   public void testWithNoRunlist() {
      ChefApi chef = createMock(ChefApi.class);

      Map<String, JsonBall> automatic = ImmutableMap.<String, JsonBall> of();

      Node node = new Node("name", ImmutableSet.<String> of(), "_default");

      Supplier<Map<String, JsonBall>> automaticSupplier = Suppliers.<Map<String, JsonBall>> ofInstance(automatic);

      Node nodeWithAutomatic = new Node("name", ImmutableMap.<String, JsonBall> of(),
            ImmutableMap.<String, JsonBall> of(), ImmutableMap.<String, JsonBall> of(), automatic,
            ImmutableSet.<String> of(), "_default");

      node.getAutomatic().putAll(automaticSupplier.get());
      chef.createNode(nodeWithAutomatic);
View Full Code Here

   }

   public void testCreateNode() throws SecurityException, NoSuchMethodException, IOException {
      Invokable<?, ?> method = method(ChefApi.class, "createNode", Node.class);
      GeneratedHttpRequest httpRequest = processor.apply(Invocation.create(method,
            ImmutableList.<Object> of(new Node("testnode", ImmutableSet.of("recipe[java]"), "_default"))));

      assertRequestLineEquals(httpRequest, "POST http://localhost:4000/nodes HTTP/1.1");
      assertNonPayloadHeadersEqual(httpRequest, "Accept: application/json\nX-Chef-Version: " + ChefApi.VERSION
            + "-test\n");
      assertPayloadEquals(httpRequest,
View Full Code Here

   }

   public void testUpdateNode() throws SecurityException, NoSuchMethodException, IOException {
      Invokable<?, ?> method = method(ChefApi.class, "updateNode", Node.class);
      GeneratedHttpRequest httpRequest = processor.apply(Invocation.create(method,
            ImmutableList.<Object> of(new Node("testnode", ImmutableSet.of("recipe[java]"), "_default"))));

      assertRequestLineEquals(httpRequest, "PUT http://localhost:4000/nodes/testnode HTTP/1.1");
      assertNonPayloadHeadersEqual(httpRequest, "Accept: application/json\nX-Chef-Version: " + ChefApi.VERSION
            + "-test\n");
      assertPayloadEquals(httpRequest,
View Full Code Here

   }

   @Test(dependsOnMethods = "testCreateRole")
   public void testCreateNode() throws Exception {
      api.deleteNode(PREFIX);
      api.createNode(new Node(PREFIX, Collections.singleton("role[" + PREFIX + "]"), "_default"));
      node = api.getNode(PREFIX);
      // TODO check recipes
      assertNotNull(node);
      Set<String> nodes = api.listNodes();
      assert nodes.contains(PREFIX) : String.format("node %s not in %s", PREFIX, nodes);
View Full Code Here

   }

   @Test(dependsOnMethods = "testNodeExists")
   public void testUpdateNode() throws Exception {
      for (String nodename : api.listNodes()) {
         Node node = api.getNode(nodename);
         api.updateNode(node);
      }
   }
View Full Code Here

TOP

Related Classes of org.jclouds.chef.domain.Node

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.