Search in sources :

Example 1 with Then

use of io.cucumber.java.en.Then in project syndesis-qe by syndesisio.

the class OperatorValidationSteps method checkConfigMap.

@Then("^check that the \"([^\"]*)\" config map (contains|doesn't contain)$")
public void checkConfigMap(String cmName, String shouldContain, DataTable table) {
    SoftAssertions asserts = new SoftAssertions();
    if ("contains".equals(shouldContain)) {
        table.asLists(String.class).forEach(row -> asserts.assertThat(OpenShiftUtils.getInstance().getConfigMap(cmName).getData().get(row.get(0))).contains(row.get(1).toString()));
    } else {
        table.asLists(String.class).forEach(row -> asserts.assertThat(OpenShiftUtils.getInstance().getConfigMap(cmName).getData().get(row.get(0))).doesNotContain(row.get(1).toString()));
    }
    asserts.assertAll();
}
Also used : SoftAssertions(org.assertj.core.api.SoftAssertions) Then(io.cucumber.java.en.Then)

Example 2 with Then

use of io.cucumber.java.en.Then in project syndesis-qe by syndesisio.

the class OperatorValidationSteps method checkMemoryLimits.

@Then("check correct memory limits")
public void checkMemoryLimits() {
    final String file = "src/test/resources/operator/spec/components/resources.limits.requests.memory.cpu.yml";
    Yaml yaml = new Yaml();
    Object data = null;
    try (FileInputStream fis = FileUtils.openInputStream(new File(file))) {
        data = yaml.load(fis);
    } catch (IOException e) {
        fail("Unable to load file " + file, e);
    }
    SoftAssertions softAssertions = new SoftAssertions();
    JSONObject components = new JSONObject((Map) data).getJSONObject("spec").getJSONObject("components");
    components.keySet().forEach(component -> {
        String expectedMemoryLimit = components.getJSONObject(component).getJSONObject("resources").getJSONObject("limit").getString("memory");
        String expectedCpuLimit = components.getJSONObject(component).getJSONObject("resources").getJSONObject("limit").getString("cpu");
        String expectedMemoryRequests = components.getJSONObject(component).getJSONObject("resources").getJSONObject("request").getString("memory");
        String expectedCpuRequests = components.getJSONObject(component).getJSONObject("resources").getJSONObject("request").getString("cpu");
        List<DeploymentConfig> dcList = OpenShiftUtils.getInstance().deploymentConfigs().withLabel("syndesis.io/component", "syndesis-" + ("database".equals(component) ? "db" : component)).list().getItems();
        softAssertions.assertThat(dcList).hasSize(1);
        final Quantity currentMemoryLimit = dcList.get(0).getSpec().getTemplate().getSpec().getContainers().get(0).getResources().getLimits().get("memory");
        softAssertions.assertThat(currentMemoryLimit).as(component + " memory limit is null").isNotNull();
        if (currentMemoryLimit != null) {
            softAssertions.assertThat(currentMemoryLimit.getAmount() + currentMemoryLimit.getFormat()).as(component + " memory limit").isEqualTo(expectedMemoryLimit);
        }
        final Quantity currentCpuLimit = dcList.get(0).getSpec().getTemplate().getSpec().getContainers().get(0).getResources().getLimits().get("cpu");
        softAssertions.assertThat(currentCpuLimit).as(component + " cpu limit is null").isNotNull();
        if (currentCpuLimit != null) {
            softAssertions.assertThat(currentCpuLimit.getAmount() + currentCpuLimit.getFormat()).as(component + " cpu limit").isEqualTo(expectedCpuLimit);
        }
        final Quantity currentMemoryRequests = dcList.get(0).getSpec().getTemplate().getSpec().getContainers().get(0).getResources().getRequests().get("memory");
        softAssertions.assertThat(currentMemoryRequests).as(component + " memory requests is null").isNotNull();
        if (currentMemoryRequests != null) {
            softAssertions.assertThat(currentMemoryRequests.getAmount() + currentMemoryRequests.getFormat()).as(component + " memory requests").isEqualTo(expectedMemoryRequests);
        }
        final Quantity currentCpuRequests = dcList.get(0).getSpec().getTemplate().getSpec().getContainers().get(0).getResources().getRequests().get("cpu");
        softAssertions.assertThat(currentCpuRequests).as(component + " cpu requests is null").isNotNull();
        if (currentCpuRequests != null) {
            softAssertions.assertThat(currentCpuRequests.getAmount() + currentCpuRequests.getFormat()).as(component + " cpu requests").isEqualTo(expectedCpuRequests);
        }
    });
    softAssertions.assertAll();
}
Also used : JSONObject(org.json.JSONObject) SoftAssertions(org.assertj.core.api.SoftAssertions) Quantity(io.fabric8.kubernetes.api.model.Quantity) JSONObject(org.json.JSONObject) IOException(java.io.IOException) DeploymentConfig(io.fabric8.openshift.api.model.DeploymentConfig) ZipFile(java.util.zip.ZipFile) File(java.io.File) Yaml(org.yaml.snakeyaml.Yaml) FileInputStream(java.io.FileInputStream) Then(io.cucumber.java.en.Then)

Example 3 with Then

use of io.cucumber.java.en.Then in project syndesis-qe by syndesisio.

the class OperatorValidationSteps method checkJaeger.

@Then("^check that jaeger pod \"([^\"]*)\" (is|is not) collecting metrics for integration \"([^\"]*)\"$")
public void checkJaeger(String jaegerPodName, String shouldCollect, String integrationName) {
    TestUtils.sleepIgnoreInterrupt(30000L);
    LocalPortForward lpf = OpenShiftUtils.createLocalPortForward(OpenShiftUtils.getPod(p -> p.getMetadata().getName().startsWith(jaegerPodName)), 16686, 16686);
    final String integrationId = integrations.getIntegrationId(integrationName).get();
    // host for default syndesis-jaeger
    String host = "localhost:16686";
    if (ResourceFactory.get(Syndesis.class).containsAddonProperty(Addon.JAEGER, "collectorUri")) {
        host = ResourceFactory.get(Jaeger.class).getQueryServiceHost();
    }
    JSONArray jsonData = new JSONObject(HTTPUtils.doGetRequest("http://" + host + "/api/traces?service=" + integrationId).getBody()).getJSONArray("data");
    OpenShiftUtils.terminateLocalPortForward(lpf);
    if ("is".equals(shouldCollect)) {
        assertThat(jsonData).size().isNotZero();
    } else {
        assertThat(jsonData).size().isZero();
    }
}
Also used : Quantity(io.fabric8.kubernetes.api.model.Quantity) Arrays(java.util.Arrays) Enumeration(java.util.Enumeration) Date(java.util.Date) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) Autowired(org.springframework.beans.factory.annotation.Autowired) TimeoutException(java.util.concurrent.TimeoutException) Random(java.util.Random) StringUtils(org.apache.commons.lang3.StringUtils) JSONObject(org.json.JSONObject) Matcher(java.util.regex.Matcher) IntegrationsEndpoint(io.syndesis.qe.endpoint.IntegrationsEndpoint) Map(java.util.Map) Addon(io.syndesis.qe.addon.Addon) ZipFile(java.util.zip.ZipFile) Syndesis(io.syndesis.qe.resource.impl.Syndesis) Path(java.nio.file.Path) ZipEntry(java.util.zip.ZipEntry) Affinity(io.fabric8.kubernetes.api.model.Affinity) AccountsDirectory(io.syndesis.qe.account.AccountsDirectory) Set(java.util.Set) DeploymentConfig(io.fabric8.openshift.api.model.DeploymentConfig) Jaeger(io.syndesis.qe.resource.impl.Jaeger) DoneablePersistentVolume(io.fabric8.kubernetes.api.model.DoneablePersistentVolume) Collectors(java.util.stream.Collectors) IOUtils(org.apache.commons.io.IOUtils) List(java.util.List) Slf4j(lombok.extern.slf4j.Slf4j) Assertions.fail(org.assertj.core.api.Assertions.fail) S3BucketNameBuilder(io.syndesis.qe.utils.aws.S3BucketNameBuilder) ResourceFactory(io.syndesis.qe.resource.ResourceFactory) Optional(java.util.Optional) Lazy(org.springframework.context.annotation.Lazy) Pattern(java.util.regex.Pattern) Component(io.syndesis.qe.component.Component) OpenShiftWaitUtils(io.syndesis.qe.wait.OpenShiftWaitUtils) SoftAssertions(org.assertj.core.api.SoftAssertions) NodeSelectorTerm(io.fabric8.kubernetes.api.model.NodeSelectorTerm) Then(io.cucumber.java.en.Then) ComponentUtils(io.syndesis.qe.component.ComponentUtils) LocalPortForward(io.fabric8.kubernetes.client.LocalPortForward) HashMap(java.util.HashMap) Yaml(org.yaml.snakeyaml.Yaml) Given(io.cucumber.java.en.Given) DataTable(io.cucumber.datatable.DataTable) Node(io.fabric8.kubernetes.api.model.Node) OutputStream(java.io.OutputStream) PersistentVolumeFluent(io.fabric8.kubernetes.api.model.PersistentVolumeFluent) Endpoints(io.fabric8.kubernetes.api.model.Endpoints) Files(java.nio.file.Files) When(io.cucumber.java.en.When) S3Utils(io.syndesis.qe.utils.aws.S3Utils) FileOutputStream(java.io.FileOutputStream) Pod(io.fabric8.kubernetes.api.model.Pod) FileUtils(org.apache.commons.io.FileUtils) IOException(java.io.IOException) NodeSelector(io.fabric8.kubernetes.api.model.NodeSelector) Toleration(io.fabric8.kubernetes.api.model.Toleration) OpenShiftUtils(io.syndesis.qe.utils.OpenShiftUtils) FileInputStream(java.io.FileInputStream) Account(io.syndesis.qe.account.Account) File(java.io.File) NodeAffinity(io.fabric8.kubernetes.api.model.NodeAffinity) HTTPUtils(io.syndesis.qe.utils.http.HTTPUtils) TestUtils(io.syndesis.qe.utils.TestUtils) Paths(java.nio.file.Paths) SecretBuilder(io.fabric8.kubernetes.api.model.SecretBuilder) ExternalDatabase(io.syndesis.qe.resource.impl.ExternalDatabase) JSONArray(org.json.JSONArray) InputStream(java.io.InputStream) LocalPortForward(io.fabric8.kubernetes.client.LocalPortForward) JSONObject(org.json.JSONObject) JSONArray(org.json.JSONArray) Syndesis(io.syndesis.qe.resource.impl.Syndesis) Then(io.cucumber.java.en.Then)

Example 4 with Then

use of io.cucumber.java.en.Then in project syndesis-qe by syndesisio.

the class OperatorValidationSteps method checkEndpoint.

@Then("verify whether operator metrics endpoint is active")
public void checkEndpoint() {
    Endpoints operatorEndpoint = OpenShiftUtils.getInstance().getEndpoint("syndesis-operator-metrics");
    assertThat(operatorEndpoint.getSubsets()).isNotEmpty();
}
Also used : Endpoints(io.fabric8.kubernetes.api.model.Endpoints) Then(io.cucumber.java.en.Then)

Example 5 with Then

use of io.cucumber.java.en.Then in project syndesis-qe by syndesisio.

the class OperatorValidationSteps method checkThatMeteringLabelsHaveCorrectValues.

/**
 * Checks whether pods contains metering labels with correct values.
 * It is a feature for Fuse Online product, therefore check runs only in case of the productized build.
 */
@Then("check that metering labels have correct values for \"([^\"]*)\"$")
public void checkThatMeteringLabelsHaveCorrectValues(Component component) {
    final String version = "8.0";
    final String company = "Red_Hat";
    final String prodName = "Red_Hat_Integration";
    final String componentName = "Fuse";
    final String subcomponent_t = "infrastructure";
    List<Pod> pods = OpenShiftUtils.getInstance().pods().withLabel("syndesis.io/component").list().getItems().stream().filter(p -> !"integration".equals(p.getMetadata().getLabels().get("syndesis.io/component"))).collect(Collectors.toList());
    for (Pod p : pods) {
        if (p.getStatus().getPhase().contains("Running") && p.getMetadata().getName().contains(component.getName())) {
            Map<String, String> labels = p.getMetadata().getLabels();
            assertThat(labels).containsKey("com.company");
            assertThat(labels).containsKey("rht.prod_name");
            assertThat(labels).containsKey("rht.prod_ver");
            assertThat(labels).containsKey("rht.comp");
            assertThat(labels).containsKey("rht.comp_ver");
            assertThat(labels).containsKey("rht.subcomp");
            assertThat(labels).containsKey("rht.subcomp_t");
            assertThat(labels.get("com.company")).isEqualTo(company);
            assertThat(labels.get("rht.prod_name")).isEqualTo(prodName);
            assertThat(labels.get("rht.prod_ver")).isEqualTo(version);
            assertThat(labels.get("rht.comp")).isEqualTo(componentName);
            assertThat(labels.get("rht.comp_ver")).isEqualTo(version);
            assertThat(labels.get("rht.subcomp")).isEqualTo(component.getName());
            assertThat(labels.get("rht.subcomp_t")).isEqualTo(subcomponent_t);
        }
    }
}
Also used : Quantity(io.fabric8.kubernetes.api.model.Quantity) Arrays(java.util.Arrays) Enumeration(java.util.Enumeration) Date(java.util.Date) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) Autowired(org.springframework.beans.factory.annotation.Autowired) TimeoutException(java.util.concurrent.TimeoutException) Random(java.util.Random) StringUtils(org.apache.commons.lang3.StringUtils) JSONObject(org.json.JSONObject) Matcher(java.util.regex.Matcher) IntegrationsEndpoint(io.syndesis.qe.endpoint.IntegrationsEndpoint) Map(java.util.Map) Addon(io.syndesis.qe.addon.Addon) ZipFile(java.util.zip.ZipFile) Syndesis(io.syndesis.qe.resource.impl.Syndesis) Path(java.nio.file.Path) ZipEntry(java.util.zip.ZipEntry) Affinity(io.fabric8.kubernetes.api.model.Affinity) AccountsDirectory(io.syndesis.qe.account.AccountsDirectory) Set(java.util.Set) DeploymentConfig(io.fabric8.openshift.api.model.DeploymentConfig) Jaeger(io.syndesis.qe.resource.impl.Jaeger) DoneablePersistentVolume(io.fabric8.kubernetes.api.model.DoneablePersistentVolume) Collectors(java.util.stream.Collectors) IOUtils(org.apache.commons.io.IOUtils) List(java.util.List) Slf4j(lombok.extern.slf4j.Slf4j) Assertions.fail(org.assertj.core.api.Assertions.fail) S3BucketNameBuilder(io.syndesis.qe.utils.aws.S3BucketNameBuilder) ResourceFactory(io.syndesis.qe.resource.ResourceFactory) Optional(java.util.Optional) Lazy(org.springframework.context.annotation.Lazy) Pattern(java.util.regex.Pattern) Component(io.syndesis.qe.component.Component) OpenShiftWaitUtils(io.syndesis.qe.wait.OpenShiftWaitUtils) SoftAssertions(org.assertj.core.api.SoftAssertions) NodeSelectorTerm(io.fabric8.kubernetes.api.model.NodeSelectorTerm) Then(io.cucumber.java.en.Then) ComponentUtils(io.syndesis.qe.component.ComponentUtils) LocalPortForward(io.fabric8.kubernetes.client.LocalPortForward) HashMap(java.util.HashMap) Yaml(org.yaml.snakeyaml.Yaml) Given(io.cucumber.java.en.Given) DataTable(io.cucumber.datatable.DataTable) Node(io.fabric8.kubernetes.api.model.Node) OutputStream(java.io.OutputStream) PersistentVolumeFluent(io.fabric8.kubernetes.api.model.PersistentVolumeFluent) Endpoints(io.fabric8.kubernetes.api.model.Endpoints) Files(java.nio.file.Files) When(io.cucumber.java.en.When) S3Utils(io.syndesis.qe.utils.aws.S3Utils) FileOutputStream(java.io.FileOutputStream) Pod(io.fabric8.kubernetes.api.model.Pod) FileUtils(org.apache.commons.io.FileUtils) IOException(java.io.IOException) NodeSelector(io.fabric8.kubernetes.api.model.NodeSelector) Toleration(io.fabric8.kubernetes.api.model.Toleration) OpenShiftUtils(io.syndesis.qe.utils.OpenShiftUtils) FileInputStream(java.io.FileInputStream) Account(io.syndesis.qe.account.Account) File(java.io.File) NodeAffinity(io.fabric8.kubernetes.api.model.NodeAffinity) HTTPUtils(io.syndesis.qe.utils.http.HTTPUtils) TestUtils(io.syndesis.qe.utils.TestUtils) Paths(java.nio.file.Paths) SecretBuilder(io.fabric8.kubernetes.api.model.SecretBuilder) ExternalDatabase(io.syndesis.qe.resource.impl.ExternalDatabase) JSONArray(org.json.JSONArray) InputStream(java.io.InputStream) Pod(io.fabric8.kubernetes.api.model.Pod) Then(io.cucumber.java.en.Then)

Aggregations

Then (io.cucumber.java.en.Then)124 SelenideElement (com.codeborne.selenide.SelenideElement)20 AttributeType (com.vaticle.typedb.core.concept.type.AttributeType)16 List (java.util.List)13 HashMap (java.util.HashMap)10 SyndesisRootPage (io.syndesis.qe.pages.SyndesisRootPage)9 Map (java.util.Map)9 ThingType (com.vaticle.typedb.core.concept.type.ThingType)8 DataTable (io.cucumber.datatable.DataTable)8 When (io.cucumber.java.en.When)8 Pod (io.fabric8.kubernetes.api.model.Pod)8 Quantity (io.fabric8.kubernetes.api.model.Quantity)8 ArrayList (java.util.ArrayList)8 Date (java.util.Date)8 TimeoutException (java.util.concurrent.TimeoutException)8 TestUtils (io.syndesis.qe.utils.TestUtils)7 HTTPResponse (io.syndesis.qe.utils.http.HTTPResponse)7 OpenShiftWaitUtils (io.syndesis.qe.wait.OpenShiftWaitUtils)7 Slf4j (lombok.extern.slf4j.Slf4j)7 Assertions.assertThat (org.assertj.core.api.Assertions.assertThat)7