Skip to content

Commit 5c22967

Browse files
authored
Add docker compose yml file (#161)
1 parent 280396c commit 5c22967

File tree

5 files changed

+100
-16
lines changed

5 files changed

+100
-16
lines changed

docker-compose.yml

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
#################################################################################################
2+
#
3+
# Copyright 2018 Ericsson AB.
4+
# For a full list of individual contributors, please see the commit history.
5+
#
6+
# Licensed under the Apache License, Version 2.0 (the "License");
7+
# you may not use this file except in compliance with the License.
8+
# You may obtain a copy of the License at
9+
#
10+
# http://www.apache.org/licenses/LICENSE-2.0
11+
#
12+
# Unless required by applicable law or agreed to in writing, software
13+
# distributed under the License is distributed on an "AS IS" BASIS,
14+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
# See the License for the specific language governing permissions and
16+
# limitations under the License.
17+
#
18+
##################################################################################################
19+
# Eiffel Sandbox
20+
#
21+
# run: docker-compose up
22+
# stop: docker-compose stop
23+
# stop/remove: docker-compose down --volumes
24+
#
25+
# Cleanup/Remove (if needed):
26+
# Dangling Volumes: docker volume rm `docker volume ls -q -f dangling=true`
27+
# Unused Images: docker images -q | xargs docker rmi
28+
# Stopped containers: docker rm `docker ps -a -q`
29+
#
30+
# Maintainer: michael.frick@ericsson.com
31+
##################################################################################################
32+
version: "2.1"
33+
services:
34+
mymongodb-mongodb:
35+
restart: always
36+
image: mongo:latest
37+
expose:
38+
- "27017"
39+
ports:
40+
- "27017:27017"
41+
healthcheck:
42+
test: ["CMD-SHELL","echo", "'db.stats().ok' | mongo localhost:27017/test", "--quiet"]
43+
interval: 30s
44+
timeout: 10s
45+
retries: 5
46+
networks:
47+
eiffel_2.0_1:
48+
aliases:
49+
- mymongodb-mongodb:27017
50+
51+
myrabbitmq-rabbitmq:
52+
restart: always
53+
image: rabbitmq:3.6.2-management
54+
expose:
55+
- "15672"
56+
- "5672"
57+
ports:
58+
- "15672:15672"
59+
- "5672:5672"
60+
healthcheck:
61+
test: ["CMD-SHELL", "if rabbitmqctl status; then \nexit 0 \nfi \nexit 1"]
62+
interval: 30s
63+
timeout: 10s
64+
retries: 5
65+
networks:
66+
eiffel_2.0_1:
67+
aliases:
68+
- myrabbitmq-rabbitmq:5672
69+
- myrabbitmq-rabbitmq:15672
70+
environment:
71+
- RABBITMQ_DEFAULT_PASS=myuser
72+
- RABBITMQ_DEFAULT_USER=myuser
73+
- RABBITMQ_DEFAULT_VHOST=/
74+
75+
networks:
76+
eiffel_2.0_1:

src/functionaltests/java/com/ericsson/ei/subscriptions/authentication/AuthenticationSteps.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ public class AuthenticationSteps extends FunctionalTestBase {
4444
public void beforeScenario() throws Throwable {
4545
httpRequest = new HttpRequest(HttpMethod.GET);
4646
httpRequest.setHost(hostName).setPort(applicationPort).setEndpoint("/auth/logout");
47+
4748
String auth = "gauss:password";
4849
String encodedAuth = new String(Base64.encodeBase64(auth.getBytes()), "UTF-8");
4950
httpRequest.addHeader("Authorization", "Basic " + encodedAuth);
@@ -55,11 +56,13 @@ public void beforeScenarioSecond() {
5556
client_is_replaced();
5657
}
5758

59+
5860
@Given("^LDAP is activated$")
5961
public void ldap_is_activated() throws Throwable {
6062
String expectedContent = new JSONObject().put("security", true).toString();
6163
httpRequest = new HttpRequest(HttpMethod.GET);
6264
httpRequest.setHost(hostName).setPort(applicationPort).setEndpoint("/auth");
65+
6366
response = httpRequest.performRequest();
6467
assertEquals(HttpStatus.OK, response.getStatusCode());
6568
assertEquals(expectedContent, response.getBody().toString());
@@ -77,7 +80,6 @@ public void request_to_rest_api(String method, String endpoint) throws Throwable
7780
case "GET":
7881
httpRequest = new HttpRequest(HttpMethod.GET);
7982
httpRequest.setHost(hostName).setPort(applicationPort).setEndpoint(endpoint);
80-
8183
break;
8284
}
8385
}
@@ -132,4 +134,5 @@ public void auth_token_saved() {
132134
public void client_is_replaced() {
133135
HttpExecutor.getInstance().recreateHttpClient();
134136
}
137+
135138
}

src/functionaltests/java/com/ericsson/ei/subscriptions/content/SubscriptionContentSteps.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ private void setUp() {
4545
postRequest = new HttpRequest(HttpMethod.POST);
4646
postRequest.setHost(hostName).setPort(applicationPort).setEndpoint("/subscriptions")
4747
.addHeader("content-type", "application/json").addHeader("Accept", "application/json");
48+
4849
}
4950

5051
// SCENARIO 1

src/functionaltests/java/com/ericsson/ei/utils/HttpExecutor.java

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -15,20 +15,25 @@
1515

1616
import java.io.IOException;
1717

18+
1819
public final class HttpExecutor {
1920

2021
private static HttpExecutor instance;
2122
private CloseableHttpClient client = HttpClientBuilder.create().build();
2223
private static final Logger LOGGER = LoggerFactory.getLogger(HttpExecutor.class);
2324

25+
private HttpExecutor() {
26+
27+
}
28+
2429
public static HttpExecutor getInstance() {
25-
if (instance == null) {
30+
if(instance == null) {
2631
instance = new HttpExecutor();
2732
}
28-
33+
2934
return instance;
3035
}
31-
36+
3237
/**
3338
* Close existing HttpClient and create a new one.
3439
*
@@ -44,35 +49,33 @@ public void recreateHttpClient() {
4449
}
4550
this.client = HttpClientBuilder.create().build();
4651
}
47-
52+
4853
/**
4954
* Handle the response from a HTTP request
50-
*
5155
* @param request
52-
* A HTTP request method, e.g. httpGet, httpPost
53-
* @return ResponseEntity containing the resulting body, headers and status
54-
* code from request
55-
*/
56+
* A HTTP request method, e.g. httpGet, httpPost
57+
* @return ResponseEntity
58+
* containing the json content of the http response and status code from request
59+
* */
5660
public ResponseEntity<String> executeRequest(HttpRequestBase request) {
5761
int statusCode = HttpStatus.PROCESSING.value();
5862
String jsonContent = "";
5963
Header[] headers = null;
6064

61-
try (CloseableHttpResponse httpResponse = client.execute(request)) {
62-
if (httpResponse.getEntity() != null) {
65+
try(CloseableHttpResponse httpResponse = client.execute(request)) {
66+
if(httpResponse.getEntity() != null) {
6367
jsonContent = EntityUtils.toString(httpResponse.getEntity(), "utf-8");
6468
}
6569
statusCode = httpResponse.getStatusLine().getStatusCode();
6670
headers = httpResponse.getAllHeaders();
67-
} catch (IOException e) {
71+
} catch(IOException e) {
6872
LOGGER.error(e.getMessage(), e);
6973
}
70-
74+
7175
MultiValueMap<String, String> headersMap = new LinkedMultiValueMap<String, String>();
7276
for (Header header : headers) {
7377
headersMap.add(header.getName(), header.getValue());
7478
}
75-
7679
return new ResponseEntity<>(jsonContent, headersMap, HttpStatus.valueOf(statusCode));
7780
}
7881
}

src/functionaltests/java/com/ericsson/ei/utils/HttpRequest.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,11 +41,12 @@ public enum HttpMethod {
4141
@Getter
4242
protected Map<String, String> params;
4343

44+
4445
private static final Logger LOGGER = LoggerFactory.getLogger(HttpRequest.class);
4546

4647
public HttpRequest(HttpMethod method) {
4748
params = new HashMap<>();
48-
49+
4950
switch (method) {
5051
case POST:
5152
request = new HttpPost();

0 commit comments

Comments
 (0)