예제 #1
0
 static void shutdownDomain(
     final DomainClient client, final Map<ServerIdentity, ServerStatus> servers) {
   final ModelNode address = new ModelNode().setEmptyList().add("host", "master");
   try {
     // First shutdown the servers
     ModelNode op = Operations.createOperation("stop-servers");
     ModelNode response = client.execute(op);
     if (Operations.isSuccessfulOutcome(response)) {
       op = Operations.createOperation("shutdown", address);
       response = client.execute(op);
       if (Operations.isSuccessfulOutcome(response)) {
         // Wait until the process has died
         while (true) {
           if (isDomainRunning(client, servers, true)) {
             try {
               TimeUnit.MILLISECONDS.sleep(20L);
             } catch (InterruptedException e) {
               LOGGER.debug("Interrupted during sleep", e);
             }
           } else {
             break;
           }
         }
       } else {
         LOGGER.debugf("Failed to execute %s: %s", op, Operations.getFailureDescription(response));
       }
     } else {
       LOGGER.debugf("Failed to execute %s: %s", op, Operations.getFailureDescription(response));
     }
   } catch (IOException e) {
     LOGGER.debug("Error shutting down domain", e);
   }
 }
  @Test
  public void testServerReadResource() throws IOException {
    DomainClient domainClient = domainMasterLifecycleUtil.getDomainClient();
    final ModelNode serverOp = new ModelNode();
    serverOp.get(OP).set(READ_RESOURCE_OPERATION);
    ModelNode address = serverOp.get(OP_ADDR);
    address.add(HOST, "master");
    address.add(SERVER, "main-one");
    serverOp.get(RECURSIVE).set(true);
    serverOp.get(INCLUDE_RUNTIME).set(true);
    serverOp.get(PROXIES).set(false);

    ModelNode response = domainClient.execute(serverOp);
    validateResponse(response);
    // TODO make some more assertions about result content
    ModelNode result = response.get(RESULT);
    Assert.assertTrue(result.isDefined());
    Assert.assertTrue(result.hasDefined(PROFILE_NAME));

    address.setEmptyList();
    address.add(HOST, "slave");
    address.add(SERVER, "main-three");
    response = domainClient.execute(serverOp);
    validateResponse(response);
    // TODO make some more assertions about result content
    result = response.get(RESULT);
    Assert.assertTrue(result.isDefined());
    Assert.assertTrue(result.hasDefined(PROFILE_NAME));
  }
 private void readHostState(String host) throws Exception {
   ModelNode op = testSupport.createOperationNode("host=" + host, READ_RESOURCE_OPERATION);
   op.get(INCLUDE_RUNTIME).set(true);
   DomainClient client = domainMasterLifecycleUtil.getDomainClient();
   ModelNode response = client.execute(op);
   ModelNode result = validateResponse(response);
   Assert.assertTrue(result.hasDefined(HOST_STATE));
   Assert.assertEquals("running", result.get(HOST_STATE).asString());
 }
예제 #4
0
 protected void removeResource(String address) throws IOException {
   ModelNode op = createOpNode(address, READ_RESOURCE_OPERATION);
   DomainClient domainClient = testSupport.getDomainMasterLifecycleUtil().getDomainClient();
   ModelNode result = domainClient.execute(op);
   if (SUCCESS.equals(result.get(OUTCOME).asString())) {
     op = createOpNode(address, REMOVE);
     result = domainClient.execute(op);
     assertEquals(result.asString(), SUCCESS, result.get(OUTCOME).asString());
   }
 }
 @Test
 public void testEnablingConfigurationChangesOnHC2() throws Exception {
   DomainClient client = domainSlaveLifecycleUtil.getDomainClient();
   final ModelNode add = Util.createAddOperation(PathAddress.pathAddress().append(getAddress()));
   add.get(LegacyConfigurationChangeResourceDefinition.MAX_HISTORY.getName())
       .set(MAX_HISTORY_SIZE);
   ModelNode response = client.execute(add);
   assertThat(response.asString(), response.get(OUTCOME).asString(), is(FAILED));
   assertThat(response.get(FAILURE_DESCRIPTION).asString(), containsString("WFLYDC0032"));
 }
  @Test
  public void testResolveExpressionOnMasterHost() throws Exception {
    ModelNode op = testSupport.createOperationNode("host=master", "resolve-expression-on-domain");
    op.get("expression").set("${file.separator}");

    DomainClient domainClient = domainMasterLifecycleUtil.getDomainClient();
    ModelNode response = domainClient.execute(op);
    validateResponse(response);
    validateResolveExpressionOnMaster(response);
  }
  @Test
  public void testDomainReadConfigAsXml() throws IOException {

    DomainClient domainClient = domainMasterLifecycleUtil.getDomainClient();
    ModelNode request = new ModelNode();
    request.get(OP).set("read-config-as-xml");
    request.get(OP_ADDR).setEmptyList();

    ModelNode response = domainClient.execute(request);
    validateResponse(response);
    // TODO make some more assertions about result content
  }
  @Test
  public void testHostReadResourceViaSlave() throws IOException {
    DomainClient domainClient = domainSlaveLifecycleUtil.getDomainClient();
    final ModelNode hostOp = new ModelNode();
    hostOp.get(OP).set(READ_RESOURCE_OPERATION);
    hostOp.get(OP_ADDR).setEmptyList().add(HOST, "slave");
    hostOp.get(RECURSIVE).set(true);
    hostOp.get(INCLUDE_RUNTIME).set(true);
    hostOp.get(PROXIES).set(false);

    ModelNode response = domainClient.execute(hostOp);
    validateResponse(response);
    // TODO make some more assertions about result content
  }
  @Test
  public void testRunningServerReadResourceDescription() throws IOException {

    DomainClient domainClient = domainMasterLifecycleUtil.getDomainClient();
    ModelNode request = new ModelNode();
    request.get(OP).set("read-resource-description");
    ModelNode address = request.get(OP_ADDR);
    address.add(HOST, "master");
    address.add(RUNNING_SERVER, "reload-one");

    // Check the stopped server has a resource description too
    ModelNode response = domainClient.execute(request);
    validateResponse(response);
  }
  @Test
  public void testDomainReadResourceDescription() throws IOException {

    DomainClient domainClient = domainMasterLifecycleUtil.getDomainClient();
    ModelNode request = new ModelNode();
    request.get(OP).set("read-resource-description");
    request.get(OP_ADDR).setEmptyList();
    request.get(RECURSIVE).set(true);
    request.get(OPERATIONS).set(true);

    ModelNode response = domainClient.execute(request);
    validateResponse(response);
    // TODO make some more assertions about result content
  }
  @Test
  public void testCompositeOperation() throws IOException {
    final DomainClient domainClient = domainMasterLifecycleUtil.getDomainClient();
    final ModelNode request = new ModelNode();
    request.get(OP).set(READ_RESOURCE_OPERATION);
    request.get(OP_ADDR).add("profile", "*");

    final ModelNode composite = new ModelNode();
    composite.get(OP).set(COMPOSITE);
    composite.get(OP_ADDR).setEmptyList();
    composite.get(STEPS).add(request);

    ModelNode response = domainClient.execute(composite);
    validateResponse(response);
    System.out.println(response);
  }
예제 #12
0
 private static boolean isDomainRunning(
     final DomainClient client,
     final Map<ServerIdentity, ServerStatus> servers,
     boolean shutdown) {
   try {
     final Map<ServerIdentity, ServerStatus> statuses = client.getServerStatuses();
     for (ServerIdentity id : statuses.keySet()) {
       final ServerStatus status = statuses.get(id);
       switch (status) {
         case DISABLED:
         case STARTED:
           {
             servers.put(id, status);
             break;
           }
       }
     }
     if (shutdown) {
       return statuses.isEmpty();
     }
     return statuses.size() == servers.size();
   } catch (Exception e) {
     LOGGER.debug("Interrupted determining if domain is running", e);
   }
   return false;
 }
 private void checkRootConfigurationChangeWarning(DomainClient client) throws IOException {
   PathAddress address = getAddress();
   ModelNode addConfigurationChanges = Util.createAddOperation(address);
   addConfigurationChanges
       .get(LegacyConfigurationChangeResourceDefinition.MAX_HISTORY.getName())
       .set(MAX_HISTORY_SIZE);
   ModelNode response = client.execute(addConfigurationChanges);
   assertThat(response.asString(), response.get(OUTCOME).asString(), is(SUCCESS));
   assertThat(response.get(RESULT).asString(), containsString("WFLYDM0135"));
 }
  @Test
  public void testHostPathOverride() throws IOException {
    final DomainClient client = domainSlaveLifecycleUtil.getDomainClient();

    final ModelNode address = new ModelNode();
    address.add(HOST, "slave");
    address.add(SERVER, "main-three");
    address.add(PATH, "domainTestPath");

    final ModelNode operation = new ModelNode();
    operation.get(OP).set(READ_RESOURCE_OPERATION);
    operation.get(OP_ADDR).set(address);

    final ModelNode response = client.execute(operation);
    validateResponse(response);

    final ModelNode result = response.get(RESULT);
    Assert.assertEquals("/tmp", result.get(PATH).asString());
    Assert.assertFalse(result.get(RELATIVE_TO).isDefined());
  }
  @Test
  public void testServerPathOverride() throws IOException {
    final DomainClient client = domainMasterLifecycleUtil.getDomainClient();

    final ModelNode address = new ModelNode();
    address.add(HOST, "master");
    address.add(SERVER, "main-one");
    address.add(PATH, "domainTestPath");

    final ModelNode operation = new ModelNode();
    operation.get(OP).set(READ_RESOURCE_OPERATION);
    operation.get(OP_ADDR).set(address);

    final ModelNode response = client.execute(operation);
    validateResponse(response);

    final ModelNode result = response.get(RESULT);
    Assert.assertEquals("main-one", result.get(PATH).asString());
    Assert.assertEquals("jboss.server.temp.dir", result.get(RELATIVE_TO).asString());
  }
  @Test
  public void testServerReadConfigAsXml() throws IOException {

    DomainClient domainClient = domainMasterLifecycleUtil.getDomainClient();
    ModelNode request = new ModelNode();
    request.get(OP).set("read-config-as-xml");
    ModelNode address = request.get(OP_ADDR);
    address.add(HOST, "master");
    address.add(SERVER, "main-one");

    ModelNode response = domainClient.execute(request);
    validateResponse(response);
    // TODO make some more assertions about result content

    address.setEmptyList();
    address.add(HOST, "slave");
    address.add(SERVER, "main-three");
    response = domainClient.execute(request);
    validateResponse(response);
    // TODO make some more assertions about result content
  }
  @Test
  public void testServerReadResourceDescription() throws IOException {

    DomainClient domainClient = domainMasterLifecycleUtil.getDomainClient();
    ModelNode request = new ModelNode();
    request.get(OP).set("read-resource-description");
    ModelNode address = request.get(OP_ADDR);
    address.add(HOST, "master");
    address.add(SERVER, "main-one");
    request.get(RECURSIVE).set(true);
    request.get(OPERATIONS).set(true);

    ModelNode response = domainClient.execute(request);
    validateResponse(response);
    // TODO make getDeploymentManager();some more assertions about result content

    address.setEmptyList();
    address.add(HOST, "slave");
    address.add(SERVER, "main-three");
    response = domainClient.execute(request);
    validateResponse(response);
    // TODO make some more assertions about result content
  }
 private void cleanUp() {
   try {
     if (client != null)
       try {
         client.close();
       } catch (Exception ignore) {
       } finally {
         client = null;
       }
     try {
       ProcessHelper.destroyProcess(currentProcess);
     } catch (InterruptedException ignore) {
     }
   } finally {
     servers.clear();
     currentProcess = null;
   }
 }