@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 testDeployment(final Archive<?> archive) throws IOException { final ModelControllerClient client = domainMasterLifecycleUtil.getDomainClient(); final ModelNode readServerSubsystems = Operations.createOperation( ClientConstants.READ_CHILDREN_NAMES_OPERATION, Operations.createAddress("host", "master", "server", "main-one")); readServerSubsystems.get(ClientConstants.CHILD_TYPE).set(ClientConstants.SUBSYSTEM); final String name = archive.getName(); // Deploy the archive execute( client, createDeployAddOperation(archive.as(ZipExporter.class).exportAsInputStream(), name, null)); Assert.assertTrue("Deployment " + name + " was not deployed.", hasDeployment(client, name)); // Validate the subsystem child names on a server ModelNode result = execute(client, readServerSubsystems); validateSubsystemModel("/host=master/server=main-one", result); // Fully replace the deployment, but with the 'enabled' flag set to false, triggering undeploy final Operation fullReplaceOp = createReplaceAndDisableOperation( archive.as(ZipExporter.class).exportAsInputStream(), name, null); execute(client, fullReplaceOp); // Below validates that WFCORE-1577 is fixed, the model should not be missing on the // /host=master/server=main-one or main-two // Validate the subsystem child names result = execute(client, readServerSubsystems); validateSubsystemModel("/host=master/server=main-one", result); }
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()); }
@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 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 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 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); }
@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 }
@Test public void testResolveExpressionOnSlaveHostDirect() throws Exception { resolveExpressionOnSlaveHostTest(domainSlaveLifecycleUtil.getDomainClient()); }
private void testReconnect(ReconnectTestScenario[] scenarios) throws Exception { int initialisedScenarios = -1; try { DomainClient masterClient = domainMasterLifecycleUtil.getDomainClient(); DomainClient slaveClient = domainSlaveLifecycleUtil.getDomainClient(); for (int i = 0; i < scenarios.length; i++) { initialisedScenarios = i; scenarios[i].setUpDomain(testSupport, masterClient, slaveClient); } for (ReconnectTestScenario scenario : scenarios) { scenario.testOnInitialStartup(masterClient, slaveClient); } // Restart the DC as admin-only ModelNode restartAdminOnly = Util.createEmptyOperation("reload", PathAddress.pathAddress(HOST, "master")); restartAdminOnly.get("admin-only").set(true); domainMasterLifecycleUtil.executeAwaitConnectionClosed(restartAdminOnly); domainMasterLifecycleUtil.connect(); domainMasterLifecycleUtil.awaitHostController(System.currentTimeMillis()); masterClient = domainMasterLifecycleUtil.createDomainClient(); for (ReconnectTestScenario scenario : scenarios) { scenario.testWhileMasterInAdminOnly(masterClient, slaveClient); } // Restart the DC as normal restartAdminOnly.get("admin-only").set(false); domainMasterLifecycleUtil.executeAwaitConnectionClosed(restartAdminOnly); domainMasterLifecycleUtil.connect(); domainMasterLifecycleUtil.awaitHostController(System.currentTimeMillis()); masterClient = domainMasterLifecycleUtil.createDomainClient(); // Wait for the slave to reconnect, look for the slave in the list of hosts long end = System.currentTimeMillis() + 20 * ADJUSTED_SECOND; boolean slaveReconnected = false; do { Thread.sleep(1 * ADJUSTED_SECOND); slaveReconnected = checkSlaveReconnected(masterClient); } while (!slaveReconnected && System.currentTimeMillis() < end); // Wait for master servers to come up end = System.currentTimeMillis() + 60 * ADJUSTED_SECOND; boolean serversUp = false; do { Thread.sleep(1 * ADJUSTED_SECOND); serversUp = checkHostServersStarted(masterClient, "master"); } while (!serversUp && System.currentTimeMillis() < end); for (ReconnectTestScenario scenario : scenarios) { scenario.testAfterReconnect(masterClient, slaveClient); } } finally { for (int i = initialisedScenarios; i >= 0; i--) { scenarios[i].tearDownDomain( domainMasterLifecycleUtil.getDomainClient(), domainSlaveLifecycleUtil.getDomainClient()); } } }