Package com.linkedin.databus2.test

Examples of com.linkedin.databus2.test.ConditionCheck


        dispatcher.enqueueMessage(SourcesMessage.createSetSourcesIdsMessage(sourcesMap.values()));
        dispatcher.enqueueMessage(SourcesMessage.createSetSourcesSchemasMessage(schemaMap));

        log.info("starting event dispatch");

        TestUtil.assertWithBackoff(new ConditionCheck()
        {
          @Override
          public boolean check()
          {
            return null != dispatcher.getDispatcherState().getEventsIterator() &&
View Full Code Here


        log.info("send both windows");
        StreamEventsResult streamRes = srcEventsBuf.streamEvents(cp, writerStream, new StreamEventsArgs(win1Size));
        Assert.assertEquals("num events streamed should equal total number of events plus 2", // EOP events, presumably?
                            numEvents + 2, streamRes.getNumEventsStreamed());

        TestUtil.assertWithBackoff(new ConditionCheck()
        {
          @Override
          public boolean check()
          {
            return 2 == mockConsumer.getNumBeginWindowCalls();
          }
        }, "second window processing started", 5000, log);

        dispatcher.shutdown();
        mockConsumer.getLatch().countDown(); // remove the barrier

        TestUtil.assertWithBackoff(new ConditionCheck()
        {
          @Override
          public boolean check()
          {
            return ! dispatcherThread.isAlive();
          }
        }, "Ensure Dispatcher thread is shutdown", 5000, log);

        TestUtil.assertWithBackoff(new ConditionCheck()
        {
          @Override
          public boolean check()
          {
            return 0 == mockConsumer.getNumRollbacks();
View Full Code Here

      {
        log.info("send first window -- that one should be OK");
        StreamEventsResult streamRes = srcEventsBuf.streamEvents(cp, writerStream, new StreamEventsArgs(win1Size));
        Assert.assertEquals(numEventsPerWindow + 1, streamRes.getNumEventsStreamed());

        TestUtil.assertWithBackoff(new ConditionCheck()
        {
          @Override
          public boolean check()
          {
            return 1 == callbackStats.getNumSysEventsProcessed();
          }
        }, "first window processed", 5000, log);

        log.info("send the second partial window -- that one should cause an error");
        streamRes = srcEventsBuf.streamEvents(cp, writerStream, new StreamEventsArgs(win2Size));
        Assert.assertEquals(numOfFailureEvent - numEventsPerWindow, streamRes.getNumEventsStreamed());

        log.info("wait for dispatcher to finish");
        TestUtil.assertWithBackoff(new ConditionCheck()
        {
          @Override
          public boolean check()
          {
            log.info("events received: " + callbackStats.getNumDataEventsReceived());
            return numOfFailureEvent <= callbackStats.getNumDataEventsProcessed();
          }
        }, "all events until the error processed", 5000, log);

        log.info("all data events have been received but no EOW");
        Assert.assertEquals(numOfFailureEvent, clientStats.getTotalStats().getNumDataEvents());
        Assert.assertEquals(1, clientStats.getTotalStats().getNumSysEvents());
        //at least one failing event therefore < numOfFailureEvent events can be processed
        Assert.assertTrue(numOfFailureEvent <= callbackStats.getNumDataEventsProcessed());
        //onDataEvent callbacks for e2_1 and e2_2 get cancelled
        Assert.assertEquals(2, callbackStats.getNumDataErrorsProcessed());
        //only one EOW
        Assert.assertEquals(1, callbackStats.getNumSysEventsProcessed());

        log.info("Send the remainder of the window");
        streamRes = srcEventsBuf.streamEvents(cp, writerStream, new StreamEventsArgs(100000));
        //remaining events + EOWs
        Assert.assertEquals(srcTestEvents.size() + numWindows - (numOfFailureEvent + 1),
                            streamRes.getNumEventsStreamed());

        log.info("wait for the rollback");
        TestUtil.assertWithBackoff(new ConditionCheck()
        {
          @Override
          public boolean check()
          {
            return 1 == mockConsumer.getNumRollbacks();
          }
        }, "rollback seen", 5000, log);

        log.info("wait for dispatcher to finish after the rollback");
        TestUtil.assertWithBackoff(new ConditionCheck()
        {
          @Override
          public boolean check()
          {
            log.info("num windows processed: " + callbackStats.getNumSysEventsProcessed());
View Full Code Here

    try {Thread.sleep(300);} catch (InterruptedException ie){};
    //System.err.println("Done Waiting for 300");

    //the client should have timed out and closed the connection

    TestUtil.assertWithBackoff(new ConditionCheck()
        {
          @Override
          public boolean check()
          {
            return null != clientExceptionListener.getLastException();
View Full Code Here

    }

        public boolean shutdown(long timeoutMs, final Logger log)
        {
            _conn.stop();
            TestUtil.assertWithBackoff(new ConditionCheck()
            {

              @Override
              public boolean check()
              {
View Full Code Here

      log.info("process a normal startSCN which should establish the connection");
      sendStartScnHappyPath(conn, cp, bstCallback, SOURCE1_NAME, 100L, log);
      Assert.assertTrue(conn.isConnected());

      //wait for the response
      TestUtil.assertWithBackoff(new ConditionCheck()
      {
        @Override
        public boolean check()
        {
          return null != bstCallback.getCheckpoint();
        }
      }, "wait for /startSCN response", 100, log);

      log.info("verify /startSCN response");
      final Checkpoint startScnCp = bstCallback.getCheckpoint();
      Assert.assertNotNull(startScnCp);
      Assert.assertEquals(100L, startScnCp.getBootstrapStartScn().longValue());

      log.info("instrument the client pipeline so that we can intercept and delay the channelClosed message");
      final Semaphore passMessage = new Semaphore(1);
      final CountDownLatch closeSent = new CountDownLatch(1);
      passMessage.acquire();
      conn._channel.getPipeline().addBefore("handler", "closeChannelDelay",
          new SimpleChannelHandler(){
            @Override
            public void channelClosed(ChannelHandlerContext ctx, ChannelStateEvent e) throws Exception {
              closeSent.countDown();
              passMessage.acquire();
              try
              {
                super.channelClosed(ctx, e);
              }
              finally
              {
                passMessage.release();
              }
            }
      });

      final Channel serverChannel = getServerChannelForClientConn(conn);
      Thread asyncChannelClose = new Thread(new Runnable()
      {
        @Override
        public void run()
        {
          log.info("closing server channel");
          serverChannel.close();
          log.info("server channel: closed");
          closeSent.countDown();
        }
      }, "asyncChannelCloseThread");
      asyncChannelClose.setDaemon(true);

      Thread asyncBootstrapReq = new Thread(new Runnable()
      {
        @Override
        public void run()
        {
          conn.requestStream("1", null, 10000, startScnCp, bstCallback);
        }
      }, "asyncBootstrapReqThread");
      asyncBootstrapReq.setDaemon(true);

      log.info("simultaneously closing connection and sending /bootstrap request");
      bstCallback.reset();
      asyncChannelClose.start();
      Assert.assertTrue(closeSent.await(1000, TimeUnit.MILLISECONDS));
      TestUtil.assertWithBackoff(new ConditionCheck()
      {
        @Override
        public boolean check()
        {
          return !conn._channel.isConnected();
        }
      }, "waiting for disconnect on the client side", 1000, log);
      Assert.assertEquals(AbstractNettyHttpConnection.State.CONNECTED, conn.getNetworkState());
      log.info("asynchronously sending /bootstrap");
      asyncBootstrapReq.start();

      log.info("letting channelClose get through");
      TestUtil.assertWithBackoff(new ConditionCheck()
      {
        @Override
        public boolean check()
        {
          return bstCallback.isStreamRequestError();
View Full Code Here

      JsonMappingException
  {
    //send startSCN()
    conn.requestStartScn(cp, bstCallback, sourceNames);

    TestUtil.assertWithBackoff(new ConditionCheck()
    {
      @Override
      public boolean check()
      {
        return null != conn._channel && conn._channel.isConnected();
View Full Code Here

    relayPullerThread.start();

    relayPuller.enqueueMessage(LifecycleMessage.createStartMessage());

    // We will try the same relay 3 times and then our remote exception handler will be invoked.
    TestUtil.assertWithBackoff(new ConditionCheck()
    {
      @Override
      public boolean check()
      {
        return relayPuller.getComponentStatus().getStatus() == Status.SUSPENDED_ON_ERROR;
View Full Code Here

    relayPullerThread.setDaemon(true);
    relayPullerThread.start();

    relayPuller.enqueueMessage(LifecycleMessage.createStartMessage());

    TestUtil.assertWithBackoff(new ConditionCheck()
    {
      @Override
      public boolean check()
      {
        return mockFailConn.getSourcesCallCounter() == 6;
      }
    }, "failConn: correct number of /sources", 500, log);

    Assert.assertEquals(mockFailConn.getRegisterCallCounter(),
                        0,
                        "failConn: correct number of /register");
    Assert.assertEquals(mockFailConn.getStreamCallCounter(),
                        0,
                        "failConn: correct number of /stream");

    TestUtil.assertWithBackoff(new ConditionCheck()
    {
      @Override
      public boolean check()
      {
        return mockSuccessConn.getSourcesCallCounter() == 3;
      }
    }, "successConn: correct number of /sources", 500, log);
    Assert.assertEquals(mockSuccessConn.getRegisterCallCounter(),
                        3,
                        "successConn: correct number of /register");
    Assert.assertEquals(mockSuccessConn.getStreamCallCounter(),
                        0,
                        "successConn: correct number of /stream");

    TestUtil.assertWithBackoff(new ConditionCheck()
    {
      @Override
      public boolean check()
      {
        return relayPuller.getComponentStatus().getStatus() ==
View Full Code Here

    relayPullerThread.start();

    relayPuller.enqueueMessage(LifecycleMessage.createStartMessage());

    //wait for the puller to go the STREAM_REQUEST_SUCCESS state
    TestUtil.assertWithBackoff(new ConditionCheck()
    {
      @Override
      public boolean check()
      {
        return null != relayConn1.getLastStateMsg();
      }
    }, "wait for call from the puller to the relay connection", 500, log);

    //wait for puller thread to shutdown
    TestUtil.assertWithBackoff(new ConditionCheck()
    {
      @Override
      public boolean check()
      {
        log.debug(relayPuller.getMessageHistoryLog());
View Full Code Here

TOP

Related Classes of com.linkedin.databus2.test.ConditionCheck

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.