Skip to content
Permalink
Browse files

Do not allow parallel deploys of a application

- The REST API responds with 409 when there is already a deployment for an
  app in progress.
- The AppsService is now managed by rocket
- Add a new dummy infrastructure in order to write more tests
  • Loading branch information...
schrieveslaach committed Mar 29, 2019
1 parent 9b01ed3 commit 3eb0d2e1790fae15f01853ad7d51841dc1c95023
@@ -29,6 +29,7 @@

import com.aixigo.preview.servant.rest.junit.extension.PREvantRestApiExtension;
import com.aixigo.preview.servant.rest.model.ServiceConfiguration;
import io.restassured.response.ResponseBodyExtractionOptions;
import io.restassured.response.ValidatableResponse;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
@@ -52,7 +53,7 @@

@Test
void shouldDeployDockerContainer_WhenRequestToDeployService(URI restApiURI) throws Exception {
String uri = postServiceConfiguration(restApiURI, "master", "nginx", "library", "nginx")
String uri = postServiceConfiguration(restApiURI, "master", "nginx", "nginx:1.15-alpine")
.extract()
.body()
.path("[0].url");
@@ -69,9 +70,9 @@ void shouldDeployDockerContainer_WhenRequestToDeployService(URI restApiURI) thro

@Test
void shouldLinkDockerContainerToNetwork_WhenRequestToDeployService(URI restApiURI) throws Exception {
postServiceConfiguration(restApiURI, "master", "httpd", "library", "httpd");
postServiceConfiguration(restApiURI, "master", "httpd", "httpd:2.4-alpine");
postServiceConfiguration(restApiURI, "master",
new ServiceConfiguration("nginx", "library", "nginx")
new ServiceConfiguration("nginx", "nginx:1.15-alpine")
.addVolume("/etc/nginx/conf.d/default.conf", createNginxConfigFile()));

Thread.sleep(WAIT_FOR_SERVICES);
@@ -87,11 +88,11 @@ void shouldLinkDockerContainerToNetwork_WhenRequestToDeployService(URI restApiUR
@Test
void shouldReplicateRemainingServicesFromMasterWhenDeployingToFeatureBranch(URI restApiURI) throws Exception {
postServiceConfiguration(restApiURI, "master", asList(
new ServiceConfiguration("httpd", "library", "httpd"),
new ServiceConfiguration("nginx", "library", "nginx")
new ServiceConfiguration("httpd", "httpd:2.4-alpine"),
new ServiceConfiguration("nginx", "nginx:1.15-alpine")
));

postServiceConfiguration(restApiURI, "master-1x", "httpd", "library", "httpd")
postServiceConfiguration(restApiURI, "master-1x", "httpd", "httpd:2.4-alpine")
.statusCode(200);

Thread.sleep(WAIT_FOR_SERVICES);
@@ -139,8 +140,8 @@ private String createNginxConfigFile() throws IOException {
return writer.toString();
}

private ValidatableResponse postServiceConfiguration(URI restApiURI, String appName, String serviceName, String imageUser, String imageRepository) {
return postServiceConfiguration(restApiURI, appName, new ServiceConfiguration(serviceName, imageUser, imageRepository));
private ValidatableResponse postServiceConfiguration(URI restApiURI, String appName, String serviceName, String image) {
return postServiceConfiguration(restApiURI, appName, new ServiceConfiguration(serviceName, image));
}

private ValidatableResponse postServiceConfiguration(URI restApiURI, String appName, ServiceConfiguration serviceConfiguration) {
@@ -44,7 +44,7 @@

private final GenericContainer prevantRestApiContainer = new GenericContainer("aixigo/prevant")
.withFileSystemBind("/var/run/docker.sock", "/var/run/docker.sock", BindMode.READ_WRITE)
.withLabel("traefik.frontend.rule", "ReplacePathRegex: ^/api(.*) /$1;PathPrefix:/api;")
.withLabel("traefik.frontend.rule", "PathPrefix:/;")
.withLogConsumer(new Consumer<OutputFrame>() {

private final Logger LOGGER = LoggerFactory.getLogger("rest api");
@@ -44,10 +44,7 @@
private final String serviceName;

@NonNull
private final String imageUser;

@NonNull
private final String imageRepository;
private final String image;

private Map<String, String> volumes = new HashMap<>();

Oops, something went wrong.

0 comments on commit 3eb0d2e

Please sign in to comment.
You can’t perform that action at this time.