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();
}
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();
}
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();
}
}
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();
}
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);
}
}
}
Aggregations