Search in sources :

Example 6 with Block

use of io.fabric8.utils.Block in project fabric8 by fabric8io.

the class ExampleTest method testDoubleAttribute.

@Test
public void testDoubleAttribute() throws Exception {
    assertThat(client).doubleAttribute("java.lang:type=OperatingSystem", "SystemCpuLoad").isGreaterThanOrEqualTo(0.0);
    assertAssertionError(new Block() {

        @Override
        public void invoke() throws Exception {
            assertThat(client).doubleAttribute("java.lang:type=OperatingSystem", "SystemCpuLoad").isLessThan(-2000.0);
        }
    });
}
Also used : Block(io.fabric8.utils.Block) Test(org.junit.Test)

Example 7 with Block

use of io.fabric8.utils.Block in project fabric8 by fabric8io.

the class JenkinsAsserts method assertWaitForNoRunningBuilds.

/**
 * Asserts that we can trigger the job defined by the given path
 */
public static void assertWaitForNoRunningBuilds(JenkinsServer jenkins, long timeMillis) throws Exception {
    LOG.info("Waiting for no running Jenkins jobs");
    Asserts.assertWaitFor(timeMillis, new Block() {

        @Override
        public void invoke() throws Exception {
            List<QueueItem> items = jenkins.getQueue().getItems();
            assertTrue("Waiting for build queue to be empty but has " + items.size(), items.isEmpty());
        }
    });
}
Also used : Block(io.fabric8.utils.Block) List(java.util.List) URISyntaxException(java.net.URISyntaxException) IOException(java.io.IOException)

Example 8 with Block

use of io.fabric8.utils.Block in project fabric8 by fabric8io.

the class JenkinsAsserts method assertWaitForJobPathExists.

/**
 * Waits for the given time period for the given job path to exist in Jenkins
 *
 * @return the job details
 */
public static JobWithDetails assertWaitForJobPathExists(final JenkinsServer jenkins, long timeMillis, String... jobPath) throws Exception {
    final AtomicReference<JobWithDetails> holder = new AtomicReference<>(null);
    LOG.info("Waiting for Jenkins job " + fullJobPath(jobPath));
    Asserts.assertWaitFor(timeMillis, new Block() {

        @Override
        public void invoke() throws Exception {
            holder.set(assertJobPathExists(jenkins, jobPath));
        }
    });
    return holder.get();
}
Also used : Block(io.fabric8.utils.Block) AtomicReference(java.util.concurrent.atomic.AtomicReference) JobWithDetails(com.offbytwo.jenkins.model.JobWithDetails) URISyntaxException(java.net.URISyntaxException) IOException(java.io.IOException)

Example 9 with Block

use of io.fabric8.utils.Block in project fabric8 by fabric8io.

the class JenkinsAsserts method assertWaitForJobPathNotExist.

public static void assertWaitForJobPathNotExist(final JenkinsServer jenkins, long timeMillis, String... jobPath) throws Exception {
    final String fullPath = fullJobPath(jobPath);
    LOG.info("Waiting for Jenkins job to no longer exist " + fullPath);
    Asserts.assertWaitFor(timeMillis, new Block() {

        @Override
        public void invoke() throws Exception {
            assertTrue("Jenkins job " + fullPath + " should not exist", findJobPath(jenkins, jobPath) == null);
        }
    });
}
Also used : Block(io.fabric8.utils.Block) URISyntaxException(java.net.URISyntaxException) IOException(java.io.IOException)

Example 10 with Block

use of io.fabric8.utils.Block in project fabric8 by fabric8io.

the class BrokerProducerConsumerIT method testMQConsumer.

@Test
public void testMQConsumer() throws Exception {
    assertThat(client).replicationController(brokerReplicationControllerId).isNotNull();
    assertThat(client).replicationController(consumerReplicationControllerId).isNotNull();
    assertThat(client).pods().runningStatus().filterNamespace(session.getNamespace()).haveAtLeast(1, new Condition<Pod>() {

        @Override
        public boolean matches(Pod podSchema) {
            return true;
        }
    });
    Asserts.assertWaitFor(10 * 60 * 1000, new Block() {

        @Override
        public void invoke() throws Exception {
            J4pClient brokerClient = jolokiaClients.assertClientForReplicationController(brokerReplicationControllerId);
            J4pClient consumerClient = jolokiaClients.assertClientForReplicationController(consumerReplicationControllerId);
            assertThat(consumerClient).stringAttribute("org.apache.camel:context=camel-1,type=context,name=\"camel-1\"", "State").isEqualTo("Started");
            assertThat(brokerClient).longAttribute("org.apache.activemq:type=Broker,brokerName=default,destinationType=Queue,destinationName=TEST.FOO", "EnqueueCount").isGreaterThan(1000);
            assertThat(brokerClient).longAttribute("org.apache.activemq:type=Broker,brokerName=default,destinationType=Queue,destinationName=TEST.FOO", "DequeueCount").isGreaterThan(1000);
        }
    });
}
Also used : Pod(io.fabric8.kubernetes.api.model.Pod) J4pClient(org.jolokia.client.J4pClient) Block(io.fabric8.utils.Block) Test(org.junit.Test)

Aggregations

Block (io.fabric8.utils.Block)11 Test (org.junit.Test)7 Pod (io.fabric8.kubernetes.api.model.Pod)4 IOException (java.io.IOException)3 URISyntaxException (java.net.URISyntaxException)3 HashMap (java.util.HashMap)3 ObjectMeta (io.fabric8.kubernetes.api.model.ObjectMeta)2 JobWithDetails (com.offbytwo.jenkins.model.JobWithDetails)1 ResolverPolicyEnum (io.fabric8.boot.commands.support.ResolverPolicyEnum)1 PodList (io.fabric8.kubernetes.api.model.PodList)1 ReplicationController (io.fabric8.kubernetes.api.model.ReplicationController)1 DefaultKubernetesClient (io.fabric8.kubernetes.client.DefaultKubernetesClient)1 KubernetesClient (io.fabric8.kubernetes.client.KubernetesClient)1 KubernetesClientException (io.fabric8.kubernetes.client.KubernetesClientException)1 ImageConfiguration (io.fabric8.maven.docker.config.ImageConfiguration)1 LogDispatcher (io.fabric8.maven.docker.log.LogDispatcher)1 Container (io.fabric8.maven.docker.model.Container)1 QueryService (io.fabric8.maven.docker.service.QueryService)1 Asserts.assertAssertionError (io.fabric8.utils.Asserts.assertAssertionError)1 BootstrapConfiguration (io.fabric8.zookeeper.bootstrap.BootstrapConfiguration)1