Search in sources :

Example 31 with Server

use of io.fabric8.insight.metrics.model.Server in project vertx-openshift-it by cescoffier.

the class MqttIT method initialize.

@BeforeClass
public static void initialize() throws IOException {
    File template = new File("target/classes/META-INF/fabric8/openshift.yml");
    ensureThat(String.format("template file %s can be deployed", template), () -> deploymentAssistant.deploy("mqtt-broker", template));
    ensureThat("the mqtt server is up and running", () -> await("Waiting for the mqtt server to be ready..").atMost(5, TimeUnit.MINUTES).untilAsserted(() -> {
        Service service = client.services().withName("mqtt-secured-service").get();
        assertThat(service).isNotNull();
        assertThat(client.deploymentConfigs().withName("vertx-mqtt-it").isReady()).isTrue();
    }));
    mqttRoute = securedUrlForRoute(client.routes().withName("mqtt-secured-route").get()).getHost();
    /* on OSO, the only way to test the insecure MQTT client connecting to server running in OpenShift
    is through port forwarding. */
    String pod = OC.executeWithQuotes(false, "get", "po", "--selector", "app=vertx-mqtt-it", "-o", "jsonpath='{.items[0].metadata.name}'").replace("'", "");
    p1 = Runtime.getRuntime().exec("oc port-forward " + pod + " :1883");
    BufferedReader reader = new BufferedReader(new InputStreamReader(p1.getInputStream()));
    Pattern pattern = Pattern.compile(".*:(\\d+)");
    Matcher matcher = pattern.matcher(reader.readLine());
    String podString = "";
    while (matcher.find()) {
        podString = matcher.group(1);
    }
    port = Integer.parseInt(podString);
    vertx = Vertx.vertx();
    mqttSecuredClient = clientSetup(MqttClient.create(vertx, mqttClientOptions));
    mqttInsecureClient = clientSetup(MqttClient.create(vertx));
}
Also used : Pattern(java.util.regex.Pattern) InputStreamReader(java.io.InputStreamReader) Matcher(java.util.regex.Matcher) BufferedReader(java.io.BufferedReader) Service(io.fabric8.kubernetes.api.model.Service) File(java.io.File)

Example 32 with Server

use of io.fabric8.insight.metrics.model.Server in project vertx-openshift-it by cescoffier.

the class SockJsIT method checkSockStatuses.

@Test
public void checkSockStatuses() throws InterruptedException {
    ensureThat("we can navigate to application ", () -> {
        final Route route = client.routes().withName(deploymentAssistant.applicationName()).get();
        webDriver.navigate().to(urlForRoute(route));
    });
    ensureThat("both statuses are updated", () -> {
        await().atMost(3, TimeUnit.MINUTES).catchUncaughtExceptions().until(() -> isElementEmpty(EB_STATUS));
        await().atMost(3, TimeUnit.MINUTES).catchUncaughtExceptions().until(() -> isElementEmpty(SOCK_STATUS));
    });
    ensureThat("all transports are working and asserted", () -> {
        final JsonPath serverStatus = get("/status").body().jsonPath();
        final JsonObject clientSideEbStatus = getJsonById(EB_STATUS);
        final JsonObject clientSideSockStatus = getJsonById(SOCK_STATUS);
        for (Transport t : Transport.values()) {
            softly.assertThat(serverStatus.getBoolean(t + "-EB")).as("Transport " + t + " should be used on server side (on EventBus). ").isTrue();
            softly.assertThat(serverStatus.getBoolean(t + "-sock")).as("Transport " + t + " should be used on server side (on SockJS). ").isTrue();
            softly.assertThat(clientSideEbStatus.getInteger(t.name())).as("Transport " + t + " should be used on client side (on EventBus). ").isGreaterThan(0);
            softly.assertThat(clientSideSockStatus.getInteger(t.name())).as("Transport " + t + " should be used on client side (on SockJS). ").isGreaterThan(0);
        }
    });
}
Also used : JsonObject(io.vertx.core.json.JsonObject) JsonPath(io.restassured.path.json.JsonPath) Transport(io.vertx.ext.web.handler.sockjs.Transport) Route(io.fabric8.openshift.api.model.Route) Kube.urlForRoute(io.vertx.it.openshift.utils.Kube.urlForRoute) Test(org.junit.Test)

Example 33 with Server

use of io.fabric8.insight.metrics.model.Server in project syndesis by syndesisio.

the class PrometheusMetricsProviderImplTest method setUp.

@Before
public void setUp() {
    final PrometheusConfigurationProperties config = new PrometheusConfigurationProperties();
    config.setService("syndesis-prometheus-syndesis.192.168.64.22.nip.io");
    NamespacedOpenShiftClient openshiftClient = mock(NamespacedOpenShiftClient.class);
    when(openshiftClient.pods().withName("syndesis-server").get().getStatus().getStartTime()).thenReturn("2018-03-14T23:34:09Z");
    metricsProvider = new PrometheusMetricsProviderImpl(config, openshiftClient);
}
Also used : NamespacedOpenShiftClient(io.fabric8.openshift.client.NamespacedOpenShiftClient) Before(org.junit.Before)

Example 34 with Server

use of io.fabric8.insight.metrics.model.Server in project fabric8 by fabric8io.

the class ListEnvironments method main.

public static void main(String[] args) {
    KubernetesClient kubernetesClient = new DefaultKubernetesClient();
    Environments environments;
    if (args.length > 0) {
        String namespace = args[0];
        System.out.println("Listing environments for namespace: " + namespace);
        environments = Environments.load(namespace);
    } else {
        environments = Environments.load();
    }
    String environmentKey = "testing";
    if (args.length > 1) {
        environmentKey = args[1];
    }
    System.out.println("Space namespace: " + environments.getNamespace());
    SortedSet<Environment> set = environments.getEnvironmentSet();
    for (Environment environment : set) {
        String onCluster = "";
        String clusterAPiServer = environment.getClusterAPiServer();
        if (Strings.isNotBlank(clusterAPiServer)) {
            onCluster += " on API server: " + clusterAPiServer;
        }
        System.out.println("Environment " + environment.getName() + " maps to namespace: " + environment.getNamespace() + onCluster);
    }
    System.out.println("Namespace for environment key: " + environmentKey + " is " + Environments.namespaceForEnvironment(environmentKey));
}
Also used : KubernetesClient(io.fabric8.kubernetes.client.KubernetesClient) DefaultKubernetesClient(io.fabric8.kubernetes.client.DefaultKubernetesClient) DefaultKubernetesClient(io.fabric8.kubernetes.client.DefaultKubernetesClient)

Example 35 with Server

use of io.fabric8.insight.metrics.model.Server in project fabric8 by fabric8io.

the class CamelState method doCheck.

@Override
protected List<Check> doCheck() {
    MBeanServer server = this.mbeanServer.getService();
    if (server != null) {
        try {
            List<Check> checks = new ArrayList<>();
            Set<ObjectName> contexts = server.queryNames(new ObjectName("org.apache.camel:type=context,*"), null);
            for (ObjectName ctxName : contexts) {
                String state = server.getAttribute(ctxName, "State").toString();
                if (!"Started".equals(state)) {
                    String name = ctxName.getKeyProperty("name");
                    checks.add(new Check("camel-state", "Camel context " + name + " is in state " + state));
                }
            }
            return checks;
        } catch (Exception e) {
            return Collections.singletonList(new Check("camel-state", "Unable to check camel contexts: " + e.toString()));
        }
    }
    return Collections.emptyList();
}
Also used : Check(io.fabric8.karaf.checks.Check) ArrayList(java.util.ArrayList) MBeanServer(javax.management.MBeanServer) ObjectName(javax.management.ObjectName)

Aggregations

HashMap (java.util.HashMap)20 Test (org.junit.Test)19 IOException (java.io.IOException)18 File (java.io.File)9 Map (java.util.Map)9 ClientInvokerImpl (io.fabric8.dosgi.tcp.ClientInvokerImpl)8 ServerInvokerImpl (io.fabric8.dosgi.tcp.ServerInvokerImpl)8 ArrayList (java.util.ArrayList)8 Profile (io.fabric8.api.Profile)7 ServerInvoker (io.fabric8.dosgi.io.ServerInvoker)7 InvocationHandler (java.lang.reflect.InvocationHandler)7 DispatchQueue (org.fusesource.hawtdispatch.DispatchQueue)7 Container (io.fabric8.api.Container)6 KubernetesClient (io.fabric8.kubernetes.client.KubernetesClient)6 Version (io.fabric8.api.Version)5 CuratorFramework (org.apache.curator.framework.CuratorFramework)5 FabricException (io.fabric8.api.FabricException)4 RuntimeProperties (io.fabric8.api.RuntimeProperties)4 InputStream (java.io.InputStream)4 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)3