Search in sources :

Example 41 with Then

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

the class MetricsSteps method checkDateFrom.

/*e.g. Since Dec 19th 10:42*/
@Then("^check that startdate for ([^\"]*) pod is valid$")
public void checkDateFrom(String integration) throws ParseException, InterruptedException {
    String startTime = metricsTab.getStartTime();
    Date uiStartDate = parseUiSinceDate(startTime);
    // UI date and start date cannot be same, Issue: gh-4303
    int timeout = 0;
    while (isSameAsCurrentDate(uiStartDate)) {
        timeout++;
        log.info("UI time is same as actual, probably the issue: gh-4303. Waiting 30 seconds and refresh UI. " + timeout + ". attempt.");
        Thread.sleep(30000);
        refresh();
        startTime = metricsTab.getStartTime();
        uiStartDate = parseUiSinceDate(startTime);
        if (timeout == 10) {
            fail("UI time is same as actual time which is impossible");
        }
    }
    Optional<Pod> pod = OpenShiftUtils.getPodByPartialName(integration);
    if (pod.isPresent()) {
        String openshiftTime = pod.get().getStatus().getStartTime();
        SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'");
        format.setTimeZone(TimeZone.getTimeZone("UTC"));
        Date openshiftStartDate = format.parse(openshiftTime);
        Calendar uiDate = Calendar.getInstance();
        uiDate.setTime(uiStartDate);
        uiDate.clear(Calendar.SECOND);
        Calendar openshiftDate = Calendar.getInstance();
        openshiftDate.setTime(openshiftStartDate);
        // because UI doesn't contains seconds and minutes are rounded e.g. 8:23:42 is in UI 8:24
        openshiftDate = DateUtils.round(openshiftDate, Calendar.MINUTE);
        openshiftDate.clear(Calendar.SECOND);
        assertThat(uiDate.getTime()).as("Check that UI date of pod '%s' is same as date in the openshift '%s'.", startTime, openshiftTime).isCloseTo(openshiftDate.getTime(), // UI sometimes round time UP sometimes not
        60000L);
    } else {
        fail("Pod with name " + integration + " doesn't exist!");
    }
}
Also used : Pod(io.fabric8.kubernetes.api.model.Pod) Calendar(java.util.Calendar) SimpleDateFormat(java.text.SimpleDateFormat) Date(java.util.Date) Then(io.cucumber.java.en.Then)

Example 42 with Then

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

the class MetricsSteps method checkUptime.

@Then("^check that uptime for ([^\"]*) pod is valid$")
public void checkUptime(String integration) throws ParseException, InterruptedException {
    Optional<Pod> pod = OpenShiftUtils.getPodByPartialName(integration);
    if (pod.isPresent()) {
        refresh();
        // To minimize inaccuracy they should be called together
        String uptime = metricsTab.getUpTime();
        String openshiftTime = pod.get().getStatus().getStartTime();
        if (uptime.contains("No Data Available")) {
            // gh-5100
            TestUtils.sleepIgnoreInterrupt(61000);
            refresh();
            uptime = metricsTab.getUpTime();
            openshiftTime = pod.get().getStatus().getStartTime();
        }
        Pattern pattern = Pattern.compile("^(\\d{1,2}) (second|minute)(s)?$");
        Matcher matcher = pattern.matcher(uptime);
        if (!matcher.find()) {
            fail("UI uptime " + uptime + " doesn't match pattern.");
        }
        Long uiMinute = (matcher.group(2).contains("second")) ? 1 : Long.parseLong(matcher.group(1));
        SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'");
        format.setTimeZone(TimeZone.getTimeZone("UTC"));
        Date openShiftStartDate = format.parse(openshiftTime);
        long diff = new Date().getTime() - openShiftStartDate.getTime();
        long openShiftMinutes = TimeUnit.MILLISECONDS.toMinutes(diff);
        assertThat(uiMinute).as("Check that UI uptime '%s' is same as openshift uptime '%s'.", uiMinute, openShiftMinutes).isCloseTo(openShiftMinutes, // 1-second inaccuracy can happen
        within(Long.valueOf(1)));
    } else {
        fail("Pod with name " + integration + " doesn't exist!");
    }
}
Also used : Pattern(java.util.regex.Pattern) Pod(io.fabric8.kubernetes.api.model.Pod) Matcher(java.util.regex.Matcher) SimpleDateFormat(java.text.SimpleDateFormat) Date(java.util.Date) Then(io.cucumber.java.en.Then)

Example 43 with Then

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

the class DocsVerificationSteps method checkVersion.

@Then("^check version in about page$")
public void checkVersion() {
    By versionOnAboutPage = By.cssSelector("[data-testid=\"about-modal-content-version-list-item\"]");
    assertThat($(versionOnAboutPage).shouldBe(visible).getText()).isNotEmpty();
    assertThat($(versionOnAboutPage).getText()).isEqualTo(TestUtils.getSyndesisVersion());
}
Also used : By(org.openqa.selenium.By) Then(io.cucumber.java.en.Then)

Example 44 with Then

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

the class DocsVerificationSteps method verifyDocsVersion.

@Then("verify whether the docs has right version")
public void verifyDocsVersion() {
    Selenide.switchTo().window(1);
    TestUtils.waitFor(() -> url().contains(".redhat.com"), 1, 15, "URL was not found");
    if (TestUtils.isProdBuild()) {
        assertThat(url().split("/")[6]).isEqualTo(currentVersion);
    } else {
        assertThat(url().split("/")[6]).isEqualTo(latestReleasedVersion);
        By versionOnUserGuide = By.cssSelector(".productnumber");
        assertThat($(versionOnUserGuide).shouldBe(visible).getText()).isNotEmpty();
        assertThat($(versionOnUserGuide).getText()).isEqualTo(latestReleasedVersion);
    }
    Selenide.closeWindow();
}
Also used : By(org.openqa.selenium.By) Then(io.cucumber.java.en.Then)

Example 45 with Then

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

the class ODataSteps method oDataServiceDoesntContain.

@Then("^.*check that entity \"([^\"]*)\" is not present in \"([^\"]*)\" collection on OData( V2)? service$")
public void oDataServiceDoesntContain(final String entityKey, final String collection, String v2) {
    HTTPResponse response = HTTPUtils.doGetRequest((v2 != null && !v2.isEmpty() ? ODataUtils.getCurrentV2Url() : ODataUtils.getV4OpenshiftRoute()) + collection + "(" + entityKey + ")");
    assertThat(response.getCode()).isEqualTo(404);
}
Also used : HTTPResponse(io.syndesis.qe.utils.http.HTTPResponse) 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