/** * Test compatability between version 4.1.0 and the current version. * * <p>A current client running message filter would fail on 4.1.0 hub servers. */ @Test(timeout = 60000) public void testClientMessageFilterCompat410() throws Exception { ByteString topic = ByteString.copyFromUtf8("TestUpdateMessageBoundCompat410"); ByteString subid = ByteString.copyFromUtf8("mysub"); // start bookkeeper BookKeeperCluster410 bkc410 = new BookKeeperCluster410(3); bkc410.start(); int port = PortManager.nextFreePort(); int sslPort = PortManager.nextFreePort(); // start hub server 410 Server410 s410 = new Server410(zkUtil.getZooKeeperConnectString(), port, sslPort); s410.start(); ClientCurrent ccur = new ClientCurrent("localhost:" + port + ":" + sslPort); ccur.subscribe(topic, subid); ccur.closeSubscription(topic, subid); ccur.publishInts(topic, 0, 100); try { ccur.receiveNumModM(topic, subid, 0, 50, 2); fail("client-side filter could not run on 4.1.0 hub server"); } catch (Exception e) { logger.info("Should fail to run client-side message filter on 4.1.0 hub server.", e); ccur.closeSubscription(topic, subid); } // stop 410 server s410.stop(); // stop bookkeeper cluster bkc410.stop(); }
/** * Test compatability between version 4.1.0 and the current version. * * <p>A current server could read subscription data recorded by 4.1.0 server. */ @Test(timeout = 60000) public void testSubscriptionDataCompat410() throws Exception { ByteString topic = ByteString.copyFromUtf8("TestCompat410"); ByteString sub410 = ByteString.copyFromUtf8("sub410"); ByteString subcur = ByteString.copyFromUtf8("subcur"); // start bookkeeper 410 BookKeeperCluster410 bkc410 = new BookKeeperCluster410(3); bkc410.start(); int port = PortManager.nextFreePort(); int sslPort = PortManager.nextFreePort(); // start 410 server Server410 s410 = new Server410(zkUtil.getZooKeeperConnectString(), port, sslPort); s410.start(); Client410 c410 = new Client410("localhost:" + port + ":" + sslPort); c410.subscribe(topic, sub410); c410.closeSubscription(topic, sub410); Thread.sleep(1000); // give server time to run disconnect logic (BOOKKEEPER-513) ClientCurrent ccur = new ClientCurrent("localhost:" + port + ":" + sslPort); ccur.subscribe(topic, subcur); ccur.closeSubscription(topic, subcur); // publish messages using old client c410.publishInts(topic, 0, 10); // stop 410 server s410.stop(); // start 420 server Server420 s420 = new Server420(zkUtil.getZooKeeperConnectString(), port, sslPort); s420.start(); c410.subscribe(topic, sub410); c410.receiveInts(topic, sub410, 0, 10); ccur.subscribe(topic, subcur); ccur.receiveInts(topic, subcur, 0, 10); // publish messages using current client ccur.publishInts(topic, 10, 10); c410.receiveInts(topic, sub410, 10, 10); ccur.receiveInts(topic, subcur, 10, 10); // stop 420 server s420.stop(); c410.close(); ccur.close(); // stop bookkeeper cluster bkc410.stop(); }