@Test
  @WithRunningServer({@RunningServer(name = CONTAINER1), @RunningServer(name = CONTAINER2)})
  public void testRebalanceWithFirstNodeStop() throws Exception {

    try {
      verifyRebalanceWith3rdNode();

      // Disabling rebalance.
      setAttribute(provider(0), LOCAL_TOPOLOGY_MANAGER, REBALANCE_ENABLED_ATTR_NAME, false);
      controller.stop(CONTAINER1);
      checkRpcManagerStatistics(
          new String[] {"null", OWNERS_2_MEMBERS_NODE1_NODE2},
          OWNERS_2_MEMBERS_NODE1_NODE2,
          provider(1),
          provider(2));
      checkRebalanceStatus(false, provider(1), provider(2));

      assertTrue(
          server(1)
                  .getCacheManager(getCacheManagerName())
                  .getCache(getCacheName())
                  .getNumberOfEntries()
              < NUMBER_ENTRIES);
      assertTrue(
          server(2)
                  .getCacheManager(getCacheManagerName())
                  .getCache(getCacheName())
                  .getNumberOfEntries()
              < NUMBER_ENTRIES);

      // Enabling rebalance
      setAttribute(provider(1), LOCAL_TOPOLOGY_MANAGER, REBALANCE_ENABLED_ATTR_NAME, true);
      checkRebalanceStatus(true, provider(1), provider(2));

      checkRpcManagerStatistics(
          new String[] {"null", OWNERS_2_MEMBERS_NODE1_NODE2},
          OWNERS_2_MEMBERS_NODE1_NODE2,
          provider(1),
          provider(2));

      assertTrue(
          server(1)
                  .getCacheManager(getCacheManagerName())
                  .getCache(getCacheName())
                  .getNumberOfEntries()
              == NUMBER_ENTRIES);
      assertTrue(
          server(2)
                  .getCacheManager(getCacheManagerName())
                  .getCache(getCacheName())
                  .getNumberOfEntries()
              == NUMBER_ENTRIES);
    } finally {
      controller.stop(CONTAINER3);
    }
  }
 @After
 public void tearDown() throws Exception {
   if (container.isStarted(SERVER1)) {
     container.stop(SERVER1);
   }
   restoreSnapshot(snapshotForServer1);
   if (container.isStarted(SERVER2)) {
     container.stop(SERVER2);
   }
   restoreSnapshot(snapshotForServer2);
 }
  @Test
  @InSequence(1)
  public void stopServers(
      @ArquillianResource @OperateOnDeployment(DEPLOYMENT_1) ManagementClient client1,
      @ArquillianResource @OperateOnDeployment(DEPLOYMENT_2) ManagementClient client2)
      throws Exception {

    SSOTestBase.removeSso(client1.getControllerClient());
    SSOTestBase.removeSso(client2.getControllerClient());

    deployer.undeploy(DEPLOYMENT_1);
    controller.stop(CONTAINER_1);
    deployer.undeploy(DEPLOYMENT_2);
    controller.stop(CONTAINER_2);
  }
  @After
  public void stop() throws Exception {
    inputCache.getRemoteCacheManager().stop();
    outputCache.getRemoteCacheManager().stop();

    // If the last test is executed stop servers.
    if (testCounter == numberOfTestMethods) {
      if (controller.isStarted("container1")) {
        controller.stop("container1");
      }

      if (controller.isStarted("container2")) {
        controller.stop("container2");
      }
    }
  }
  @Test
  @WithRunningServer({@RunningServer(name = CONTAINER1), @RunningServer(name = CONTAINER2)})
  public void testRebalanceDisabledWithNewNode() throws Exception {

    try {
      verifyRebalanceWith3rdNode();
    } finally {
      controller.stop(CONTAINER3);
    }
  }
 private void stop(String deployment, String container) {
   try {
     System.out.println(
         new Date() + "stopping deployment=" + deployment + ", container=" + container);
     deployer.undeploy(deployment);
     controller.stop(container);
     System.out.println(
         new Date() + "stopped deployment=" + deployment + ", container=" + container);
   } catch (Throwable e) {
     e.printStackTrace(System.err);
   }
 }
 @After
 public void stopContainer() throws Exception {
   final ModelControllerClient client = TestSuiteEnvironment.getModelControllerClient();
   try {
     // Remove the servlet
     deployer.undeploy(DEPLOYMENT);
     // Stop the container
     container.stop(CONTAINER);
   } finally {
     safeClose(client);
   }
 }
  @After
  public void tearDown() throws Exception {
    try (ModelControllerClient client = createClient1()) {
      JMSOperations jmsOperations = JMSOperationsProvider.getInstance(client);
      jmsOperations.removeJmsQueue(jmsQueueName);
      jmsOperations.removeJmsTopic(jmsTopicName);
    }
    try (ModelControllerClient client = createClient2()) {
      JMSOperations jmsOperations = JMSOperationsProvider.getInstance(client);
      jmsOperations.removeJmsQueue(jmsQueueName);
      jmsOperations.removeJmsTopic(jmsTopicName);
    }

    container.stop(CONTAINER_0);
    container.stop(CONTAINER_1);
  }
  @Test
  @InSequence(-1)
  public void setupSSO(
      @ArquillianResource @OperateOnDeployment(DEPLOYMENT_1) ManagementClient client1,
      @ArquillianResource @OperateOnDeployment(DEPLOYMENT_2) ManagementClient client2)
      throws Exception {

    // add sso valves
    SSOTestBase.addClusteredSso(client1.getControllerClient());
    SSOTestBase.addClusteredSso(client2.getControllerClient());

    controller.stop(CONTAINER_1);
    controller.stop(CONTAINER_2);

    controller.start(CONTAINER_1);
    controller.start(CONTAINER_2);

    deployer.deploy(DEPLOYMENT_1);
    deployer.deploy(DEPLOYMENT_2);
  }
  @Test
  @InSequence(4)
  public void resetTestConfiguration() throws Exception {

    LOGGER.info("*** reseting test configuration");
    ModelControllerClient client = getNativeModelControllerClient();
    ManagementClient managementClient =
        new ManagementClient(
            client, TestSuiteEnvironment.getServerAddress(), MANAGEMENT_NATIVE_PORT, "remoting");

    resetHttpInterfaceConfiguration(client);

    // reload to apply changes
    CustomCLIExecutor.execute(null, RELOAD, NATIVE_CONTROLLER);
    CustomCLIExecutor.waitForServerToReload(MAX_RELOAD_TIME, NATIVE_CONTROLLER);

    keystoreFilesSetup.tearDown(managementClient, CONTAINER);
    managementNativeRealmSetup.tearDown(managementClient, CONTAINER);

    LOGGER.info("*** stopping container");
    containerController.stop(CONTAINER);
  }
Ejemplo n.º 11
0
  @After
  public void afterTest() throws Exception {
    // stop syslog server
    SyslogServer.shutdown();
    server.setThread(null);
    server.getConfig().removeAllEventHandlers();

    final ModelControllerClient client = TestSuiteEnvironment.getModelControllerClient();
    ModelNode op =
        Util.getWriteAttributeOperation(
            auditLogConfigAddress,
            AuditLogLoggerResourceDefinition.ENABLED.getName(),
            new ModelNode(false));
    client.execute(op);
    op =
        Util.getWriteAttributeOperation(
            mgmtRealmConfigAddress, "default-user", new ModelNode("$local"));
    client.execute(op);

    op = Util.getResourceRemoveOperation(addSyslogHandler);
    client.execute(op);
    op = Util.getResourceRemoveOperation(syslogHandlerAddress);
    client.execute(op);

    if (file.exists()) {
      file.delete();
    }
    if (syslogFile.exists()) {
      syslogFile.delete();
    }
    try {
      // Stop the container
      container.stop(CONTAINER);
    } finally {
      IoUtils.safeClose(client);
    }
  }
Ejemplo n.º 12
0
  @Before
  public void beforeTest() throws Exception {
    file = new File(System.getProperty("jboss.home"));
    file = new File(file, "standalone");
    file = new File(file, "data");
    file = new File(file, "audit-log.log");
    if (file.exists()) {
      file.delete();
    }

    syslogFile = new File(System.getProperty("jboss.home"));
    syslogFile = new File(syslogFile, "standalone");
    syslogFile = new File(syslogFile, "data");
    syslogFile = new File(syslogFile, "syslog-audit-log.log");
    if (syslogFile.exists()) {
      syslogFile.delete();
    }

    // start and set syslog server
    server = SyslogServer.getInstance("udp");
    server.getConfig().setPort(PORT);
    queue = new LinkedBlockingQueue<String>();
    server
        .getConfig()
        .addEventHandler(
            new BlockedFileSyslogServerEventHandler(queue, syslogFile.getAbsolutePath(), false));
    SyslogServer.getThreadedInstance("udp");

    // Start the server
    container.start(CONTAINER);
    final ModelControllerClient client = TestSuiteEnvironment.getModelControllerClient();
    managementClient =
        new ManagementClient(
            client,
            TestSuiteEnvironment.getServerAddress(),
            TestSuiteEnvironment.getServerPort(),
            "http-remoting");

    ModelNode op;
    ModelNode result;

    mgmtRealmConfigAddress =
        PathAddress.pathAddress(
            PathElement.pathElement(CORE_SERVICE, MANAGEMENT),
            PathElement.pathElement(SECURITY_REALM, "ManagementRealm"),
            PathElement.pathElement(AUTHENTICATION, LOCAL));
    op =
        Util.getWriteAttributeOperation(
            mgmtRealmConfigAddress, "default-user", new ModelNode("IAmAdmin"));
    result = client.execute(op);

    auditLogConfigAddress =
        PathAddress.pathAddress(
            CoreManagementResourceDefinition.PATH_ELEMENT,
            AccessAuditResourceDefinition.PATH_ELEMENT,
            AuditLogLoggerResourceDefinition.PATH_ELEMENT);

    op =
        Util.getWriteAttributeOperation(
            auditLogConfigAddress,
            AuditLogLoggerResourceDefinition.ENABLED.getName(),
            new ModelNode(true));
    result = client.execute(op);
    Assert.assertEquals(
        result.get("failure-description").asString(), SUCCESS, result.get(OUTCOME).asString());

    ModelNode compositeOp = new ModelNode();
    compositeOp.get(OP).set(COMPOSITE);
    compositeOp.get(OP_ADDR).setEmptyList();
    ModelNode steps = compositeOp.get(STEPS);
    syslogHandlerAddress =
        PathAddress.pathAddress(
            PathElement.pathElement(CORE_SERVICE, MANAGEMENT),
            PathElement.pathElement(ACCESS, AUDIT),
            PathElement.pathElement(SYSLOG_HANDLER, SYSLOG_HANDLER_NAME));
    op = Util.createAddOperation(syslogHandlerAddress);
    op.get(FORMATTER).set(JSON_FORMATTER);
    op.get(SYSLOG_FORMAT).set("RFC5424");
    steps.add(op);
    op = new ModelNode();
    PathAddress syslogProtocol =
        PathAddress.pathAddress(syslogHandlerAddress, PathElement.pathElement(PROTOCOL, UDP));
    op = Util.createAddOperation(syslogProtocol);
    op.get("port").set(PORT);
    op.get("host").set("localhost");
    steps.add(op);
    result = client.execute(compositeOp);
    Assert.assertEquals(
        result.get("failure-description").asString(), SUCCESS, result.get(OUTCOME).asString());

    addSyslogHandler =
        PathAddress.pathAddress(
            auditLogConfigAddress, PathElement.pathElement(HANDLER, SYSLOG_HANDLER_NAME));
    op = Util.createAddOperation(addSyslogHandler);
    result = client.execute(op);
    Assert.assertEquals(
        result.get("failure-description").asString(), SUCCESS, result.get(OUTCOME).asString());

    container.stop(CONTAINER);
    Thread.sleep(1000);
    while (managementClient.isServerInRunningState()) {
      Thread.sleep(50);
    }
  }
  @Test
  public void testHotRodRollingUpgradesDiffVersions() throws Exception {
    // Target node
    final int managementPortServer1 = 9999;
    MBeanServerConnectionProvider provider1;
    // Source node
    final int managementPortServer2 = 10099;
    MBeanServerConnectionProvider provider2;

    controller.start("hotrod-rolling-upgrade-2-old");
    try {
      // we use PROTOCOL_VERSION_12 here because older servers does not support higher versions
      RemoteInfinispanMBeans s2 =
          createRemotes("hotrod-rolling-upgrade-2-old", "local", DEFAULT_CACHE_NAME);
      final RemoteCache<Object, Object> c2 =
          createCache(s2, ConfigurationProperties.PROTOCOL_VERSION_12);

      c2.put("key1", "value1");
      assertEquals("value1", c2.get("key1"));

      for (int i = 0; i < 50; i++) {
        c2.put("keyLoad" + i, "valueLoad" + i);
      }

      controller.start("hotrod-rolling-upgrade-1");

      RemoteInfinispanMBeans s1 =
          createRemotes("hotrod-rolling-upgrade-1", "local", DEFAULT_CACHE_NAME);
      final RemoteCache<Object, Object> c1 = createCache(s1);

      assertEquals(
          "Can't access etries stored in source node (target's RemoteCacheStore).",
          "value1",
          c1.get("key1"));

      provider1 =
          new MBeanServerConnectionProvider(
              s1.server.getHotrodEndpoint().getInetAddress().getHostName(), managementPortServer1);
      provider2 =
          new MBeanServerConnectionProvider(
              s2.server.getHotrodEndpoint().getInetAddress().getHostName(), managementPortServer2);

      final ObjectName rollMan =
          new ObjectName(
              "jboss.infinispan:type=Cache,"
                  + "name=\"default(local)\","
                  + "manager=\"local\","
                  + "component=RollingUpgradeManager");

      invokeOperation(
          provider2,
          rollMan.toString(),
          "recordKnownGlobalKeyset",
          new Object[] {},
          new String[] {});

      invokeOperation(
          provider1,
          rollMan.toString(),
          "synchronizeData",
          new Object[] {"hotrod"},
          new String[] {"java.lang.String"});

      invokeOperation(
          provider1,
          rollMan.toString(),
          "disconnectSource",
          new Object[] {"hotrod"},
          new String[] {"java.lang.String"});

      // is source (RemoteCacheStore) really disconnected?
      c2.put("disconnected", "source");
      assertEquals(
          "Can't obtain value from cache2 (source node).", "source", c2.get("disconnected"));
      assertNull(
          "Source node entries should NOT be accessible from target node (after RCS disconnection)",
          c1.get("disconnected"));

      // all entries migrated?
      assertEquals("Entry was not successfully migrated.", "value1", c1.get("key1"));
      for (int i = 0; i < 50; i++) {
        assertEquals(
            "Entry was not successfully migrated.", "valueLoad" + i, c1.get("keyLoad" + i));
      }
    } finally {
      if (controller.isStarted("hotrod-rolling-upgrade-1")) {
        controller.stop("hotrod-rolling-upgrade-1");
      }
      if (controller.isStarted("hotrod-rolling-upgrade-2-old")) {
        controller.stop("hotrod-rolling-upgrade-2-old");
      }
    }
  }
Ejemplo n.º 14
0
 @Test
 @InSequence(4)
 public void shouldBeAbleToStopServer() {
   controller.stop("frontend-1");
 }
 private void restart(final ManagementClient managementClient) {
   container.stop(CONTAINER);
   container.start(CONTAINER);
   // Just make sure it's running
   Assert.assertTrue("Container is not started", managementClient.isServerInRunningState());
 }
  @Test
  public void testHotRodRollingUpgradesDiffVersions() throws Exception {
    // Target node
    final int managementPortServer1 = 9990;
    MBeanServerConnectionProvider provider1;
    // Source node
    int managementPortServer2 = 10099; // jboss-as mgmt port
    MBeanServerConnectionProvider provider2;

    try {

      if (!Boolean.parseBoolean(System.getProperty("start.jboss.as.manually"))) {
        // start it by Arquillian
        controller.start("hotrod-rolling-upgrade-2-old");
        managementPortServer2 = 10090;
      }

      ConfigurationBuilder builder = new ConfigurationBuilder();
      builder
          .addServer()
          .host("127.0.0.1")
          .port(11322)
          .protocolVersion(ConfigurationProperties.PROTOCOL_VERSION_12);

      RemoteCacheManager rcm = new RemoteCacheManager(builder.build());
      final RemoteCache<String, String> c2 = rcm.getCache("default");

      c2.put("key1", "value1");
      assertEquals("value1", c2.get("key1"));

      for (int i = 0; i < 50; i++) {
        c2.put("keyLoad" + i, "valueLoad" + i);
      }

      controller.start("hotrod-rolling-upgrade-1");

      RemoteInfinispanMBeans s1 =
          createRemotes("hotrod-rolling-upgrade-1", "local", DEFAULT_CACHE_NAME);
      // hotrod.protocol.version, if explictily defined, is set in createRemotes() method
      final RemoteCache<Object, Object> c1 = createCache(s1);

      assertEquals(
          "Can't access etries stored in source node (target's RemoteCacheStore).",
          "value1",
          c1.get("key1"));

      provider2 = new MBeanServerConnectionProvider("127.0.0.1", managementPortServer2);

      final ObjectName rollMan =
          new ObjectName(
              "jboss."
                  + InfinispanSubsystem.SUBSYSTEM_NAME
                  + ":type=Cache,"
                  + "name=\"default(local)\","
                  + "manager=\"local\","
                  + "component=RollingUpgradeManager");

      invokeOperation(
          provider2,
          rollMan.toString(),
          "recordKnownGlobalKeyset",
          new Object[] {},
          new String[] {});

      provider1 =
          new MBeanServerConnectionProvider(
              s1.server.getHotrodEndpoint().getInetAddress().getHostName(), managementPortServer1);

      invokeOperation(
          provider1,
          rollMan.toString(),
          "synchronizeData",
          new Object[] {"hotrod"},
          new String[] {"java.lang.String"});

      invokeOperation(
          provider1,
          rollMan.toString(),
          "disconnectSource",
          new Object[] {"hotrod"},
          new String[] {"java.lang.String"});

      // is source (RemoteCacheStore) really disconnected?
      c2.put("disconnected", "source");
      assertEquals(
          "Can't obtain value from cache2 (source node).", "source", c2.get("disconnected"));
      assertNull(
          "Source node entries should NOT be accessible from target node (after RCS disconnection)",
          c1.get("disconnected"));

      // all entries migrated?
      assertEquals("Entry was not successfully migrated.", "value1", c1.get("key1"));
      for (int i = 0; i < 50; i++) {
        assertEquals(
            "Entry was not successfully migrated.", "valueLoad" + i, c1.get("keyLoad" + i));
      }
    } finally {
      if (controller.isStarted("hotrod-rolling-upgrade-1")) {
        controller.stop("hotrod-rolling-upgrade-1");
      }
      if (controller.isStarted("hotrod-rolling-upgrade-2-old")) {
        controller.stop("hotrod-rolling-upgrade-2-old");
      }
    }
  }
 @After
 public void after() {
   controller.stop(CONTAINER);
 }