You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@dlab.apache.org by of...@apache.org on 2020/01/03 14:55:25 UTC

[incubator-dlab] branch feature-integration-tests updated: Added stop/start project scenario; added logs for endpoint feature

This is an automated email from the ASF dual-hosted git repository.

ofuks pushed a commit to branch feature-integration-tests
in repository https://gitbox.apache.org/repos/asf/incubator-dlab.git


The following commit(s) were added to refs/heads/feature-integration-tests by this push:
     new c9ea6d3  Added stop/start project scenario; added logs for endpoint feature
c9ea6d3 is described below

commit c9ea6d3eca72109d6b8f18f41a5561497472ad3a
Author: Oleh Fuks <ol...@gmail.com>
AuthorDate: Fri Jan 3 16:54:11 2020 +0200

    Added stop/start project scenario; added logs for endpoint feature
---
 .../src/test/java/dlab/endpoint/EndpointSteps.java |  6 ++-
 .../src/test/java/dlab/project/ProjectSteps.java   | 43 +++++++++++++++++++++-
 .../src/test/resources/dlab/project.feature        | 36 +++++++++++++++++-
 3 files changed, 81 insertions(+), 4 deletions(-)

diff --git a/integration-tests-cucumber/src/test/java/dlab/endpoint/EndpointSteps.java b/integration-tests-cucumber/src/test/java/dlab/endpoint/EndpointSteps.java
index 79bb0b0..ce2cc98 100644
--- a/integration-tests-cucumber/src/test/java/dlab/endpoint/EndpointSteps.java
+++ b/integration-tests-cucumber/src/test/java/dlab/endpoint/EndpointSteps.java
@@ -8,6 +8,7 @@ import cucumber.api.java.en.Given;
 import cucumber.api.java.en.Then;
 import cucumber.api.java.en.When;
 import dlab.util.KeycloakUtil;
+import lombok.extern.slf4j.Slf4j;
 import org.apache.dlab.dto.EndpointDTO;
 import org.apache.dlab.util.JacksonMapper;
 
@@ -23,6 +24,7 @@ import static dlab.Constants.API_URI;
 import static org.hamcrest.MatcherAssert.assertThat;
 import static org.hamcrest.core.IsEqual.equalTo;
 
+@Slf4j
 public class EndpointSteps {
 	private RequestSpecification request;
 	private Response response;
@@ -35,7 +37,6 @@ public class EndpointSteps {
 				.auth()
 				.oauth2(KeycloakUtil.getToken())
 				.contentType(ContentType.JSON);
-
 	}
 
 	@When("User send create new endpoint request")
@@ -74,7 +75,7 @@ public class EndpointSteps {
 		assertThat(dto.getName(), equalTo(name));
 		assertThat(dto.getUrl(), equalTo(uri));
 		assertThat(dto.getTag(), equalTo(tag));
-
+		log.info("Endpoint {} information is successfully returned", dto.getName());
 	}
 
 	@When("User try to get information about endpoints")
@@ -92,6 +93,7 @@ public class EndpointSteps {
 
 		assertTrue(endpoints.contains("test1"));
 		assertTrue(endpoints.contains("test2"));
+		log.info("Endpoints information is successfully returned");
 	}
 
 	@And("Remove endpoint with name {string}")
diff --git a/integration-tests-cucumber/src/test/java/dlab/project/ProjectSteps.java b/integration-tests-cucumber/src/test/java/dlab/project/ProjectSteps.java
index 8aa7a4f..d8250ea 100644
--- a/integration-tests-cucumber/src/test/java/dlab/project/ProjectSteps.java
+++ b/integration-tests-cucumber/src/test/java/dlab/project/ProjectSteps.java
@@ -13,6 +13,7 @@ import dlab.util.KeycloakUtil;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.dlab.dto.CreateProjectDTO;
 import org.apache.dlab.dto.EndpointStatusDTO;
+import org.apache.dlab.dto.ProjectActionDTO;
 import org.apache.dlab.dto.ProjectDTO;
 import org.apache.dlab.dto.ProjectKeyDTO;
 import org.apache.dlab.dto.ProjectStatusDTO;
@@ -138,6 +139,20 @@ public class ProjectSteps {
 		request = authenticatedRequest().contentType(ContentType.JSON);
 	}
 
+	@And("User tries to stop the project")
+	public void userTriesToStopTheProject() {
+		request = authenticatedRequest()
+				.body(JacksonMapper.marshall(new ProjectActionDTO(projectName, Collections.singletonList(LOCAL_ENDPOINT))))
+				.contentType(ContentType.JSON);
+	}
+
+	@And("User tries to start the project")
+	public void userTriesToStartTheProject() {
+		request = authenticatedRequest()
+				.body(JacksonMapper.marshall(new ProjectActionDTO(projectName, Collections.singletonList(LOCAL_ENDPOINT))))
+				.contentType(ContentType.JSON);
+	}
+
 	@When("User sends create new project request")
 	public void userSendsCreateNewProjectRequest() {
 		response = request.post(API_URI + "project");
@@ -163,6 +178,16 @@ public class ProjectSteps {
 		response = request.get(API_URI + "project");
 	}
 
+	@When("User sends request to stop the project")
+	public void userSendsRequestToStopTheProject() {
+		response = request.post(API_URI + "project/stop");
+	}
+
+	@When("User sends request to start the project")
+	public void userSendsRequestToStartTheProject() {
+		response = request.post(API_URI + "project/start");
+	}
+
 	@Then("Status code is {int}")
 	public void statusCodeIs(int code) {
 		assertThat(response.getStatusCode(), equalTo(code));
@@ -176,7 +201,7 @@ public class ProjectSteps {
 		log.info("Project {} successfully created", projectName);
 	}
 
-	@Then("User waits maximum {int} minutes while project is terminated")
+	@Then("User waits maximum {int} minutes while project is terminating")
 	public void userWaitsMaximumTimeoutMinutesWhileProjectIsTerminated(int timeout) throws URISyntaxException, InterruptedException {
 		boolean isTerminated = waitForStatus(timeout, EndpointStatusDTO.Status.TERMINATED);
 
@@ -184,6 +209,22 @@ public class ProjectSteps {
 		log.info("Project {} successfully terminated", projectName);
 	}
 
+	@Then("User waits maximum {int} minutes while project is stopping")
+	public void userWaitsMaximumTimeoutMinutesWhileProjectIsStopping(int timeout) throws URISyntaxException, InterruptedException {
+		boolean isStopped = waitForStatus(timeout, EndpointStatusDTO.Status.STOPPED);
+
+		assertTrue("Timeout for project status check reached!", isStopped);
+		log.info("Project {} successfully stopped", projectName);
+	}
+
+	@Then("User waits maximum {int} minutes while project is starting")
+	public void userWaitsMaximumTimeoutMinutesWhileProjectIsStarting(int timeout) throws URISyntaxException, InterruptedException {
+		boolean isRunning = waitForStatus(timeout, EndpointStatusDTO.Status.RUNNING);
+
+		assertTrue("Timeout for project status check reached!", isRunning);
+		log.info("Project {} successfully started", projectName);
+	}
+
 	@And("Project information is successfully returned with name {string}, endpoints, groups")
 	public void projectInformationIsSuccessfullyReturnedWithNameEndpointsGroups(String expectedProjectName) {
 		ProjectDTO project = response.getBody().as(ProjectDTO.class);
diff --git a/integration-tests-cucumber/src/test/resources/dlab/project.feature b/integration-tests-cucumber/src/test/resources/dlab/project.feature
index 3379849..c478c7f 100644
--- a/integration-tests-cucumber/src/test/resources/dlab/project.feature
+++ b/integration-tests-cucumber/src/test/resources/dlab/project.feature
@@ -118,13 +118,47 @@ Feature: Project management in DLab
       | prj2 |
 
 
+  Scenario Outline: Stop a project that exists
+
+    Given There is a project with name "<name>" in DLab
+    And User tries to stop the project
+    When User sends request to stop the project
+    Then Status code is 202
+    Then User waits maximum <timeout> minutes while project is stopping
+    @v1
+    Examples:
+      | name | timeout |
+      | prj1 | 20      |
+    @v2
+    Examples:
+      | name | timeout |
+      | prj2 | 20      |
+
+
+  Scenario Outline: Start a project that exists
+
+    Given There is a project with name "<name>" in DLab
+    And User tries to start the project
+    When User sends request to start the project
+    Then Status code is 202
+    Then User waits maximum <timeout> minutes while project is starting
+    @v1
+    Examples:
+      | name | timeout |
+      | prj1 | 20      |
+    @v2
+    Examples:
+      | name | timeout |
+      | prj2 | 20      |
+
+
   @terminate
   Scenario Outline: Terminate a project/edge node that exits
 
     Given There is a project with name "<name>" in DLab
     And User tries to terminate the project with name "<name>"
     When User sends termination request
-    Then User waits maximum <timeout> minutes while project is terminated
+    Then User waits maximum <timeout> minutes while project is terminating
     Then Status code is 200
     @v1
     Examples:


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@dlab.apache.org
For additional commands, e-mail: commits-help@dlab.apache.org