Skip to content

Commit

Permalink
Merge pull request #9 from code42/network
Browse files Browse the repository at this point in the history
  • Loading branch information
Juliya Smith authored Mar 2, 2021
2 parents 7a75e73 + 78fbdab commit f00c51f
Show file tree
Hide file tree
Showing 5 changed files with 64 additions and 41 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ It is not necessary to do this for every response property. Here are reasons you

* Prism complains about the type returned. If ths happens, setting the example will control the output so Prism can't generate faulty
examples by mistake.
* You are expecting a specific response value in a test. This is how the Key-Value mock endpoints work: they return localhost with
* You are expecting a specific response value in a test. This is how the Key-Value mock endpoints work: they return the container host with
different ports (see section below).
* You want to constrain the response value. Prism likes to use negative integers when the type is an integer, but you might not want that,
especially for IDs like the `userId`.
Expand All @@ -122,7 +122,7 @@ Example:
'*/*':
schema:
type: string
example: http://127.0.0.1:4220
example: http://service-name:4220
```

Then, in the `docker-compose.yml` file, add another entry using your service's mock `.yml` file and an incremented port (the same one you used in
Expand Down Expand Up @@ -163,7 +163,7 @@ First, add a healthcheck endpoint to your OpenAPI yml file:
Then, in `docker-compose.yml`, add a `healthcheck` configuration section to your service definition. Be sure to modify the port to match the port exposed by your mock microservice container.
```yml
healthcheck:
test: ["CMD-SHELL", "curl -f http://localhost:4200 || exit 1"]
test: ["CMD-SHELL", "curl -f http://service:4200 || exit 1"]
interval: 10s
timeout: 5s
retries: 3
Expand Down
75 changes: 49 additions & 26 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
version: '3'
version: '2.4'
services:

core:
Expand All @@ -12,10 +12,12 @@ services:
- "4200:4200"
command: mock docs/core.yml -p 4200 -h 0.0.0.0
healthcheck:
test: ["CMD-SHELL", "curl -f http://localhost:4200 || exit 1"]
test: ["CMD-SHELL", "curl -f http://core:4200 || exit 1"]
interval: 10s
timeout: 5s
retries: 3
networks:
- api-integration-test-network

alerts:
image: c42/mock-microservice-endpoints:1.0
Expand All @@ -28,12 +30,14 @@ services:
- "4201:4201"
command: mock docs/alerts.yml -p 4201 -h 0.0.0.0
healthcheck:
test: ["CMD-SHELL", "curl -f http://localhost:4201 || exit 1"]
test: ["CMD-SHELL", "curl -f http://alerts:4201 || exit 1"]
interval: 10s
timeout: 5s
retries: 3
networks:
- api-integration-test-network

alert_rules:
alert-rules:
image: c42/mock-microservice-endpoints:1.0
build:
context: .
Expand All @@ -44,12 +48,14 @@ services:
- "4202:4202"
command: mock docs/alert-rules.yml -p 4202 -h 0.0.0.0
healthcheck:
test: ["CMD-SHELL", "curl -f http://localhost:4202 || exit 1"]
test: ["CMD-SHELL", "curl -f http://alert-rules:4202 || exit 1"]
interval: 10s
timeout: 5s
retries: 3
networks:
- api-integration-test-network

detection_lists:
detection-lists:
image: c42/mock-microservice-endpoints:1.0
build:
context: .
Expand All @@ -60,10 +66,12 @@ services:
- "4203:4203"
command: mock docs/detection-lists.yml -p 4203 -h 0.0.0.0
healthcheck:
test: ["CMD-SHELL", "curl -f http://localhost:4203 || exit 1"]
test: ["CMD-SHELL", "curl -f http://detection-lists:4203 || exit 1"]
interval: 10s
timeout: 5s
retries: 3
networks:
- api-integration-test-network

cases:
image: c42/mock-microservice-endpoints:1.0
Expand All @@ -76,10 +84,12 @@ services:
- "4204:4204"
command: mock docs/cases.yml -p 4204 -h 0.0.0.0
healthcheck:
test: ["CMD-SHELL", "curl -f http://localhost:4204 || exit 1"]
test: ["CMD-SHELL", "curl -f http://cases:4204 || exit 1"]
interval: 10s
timeout: 5s
retries: 3
networks:
- api-integration-test-network

storage:
image: c42/mock-microservice-endpoints:1.0
Expand All @@ -92,12 +102,14 @@ services:
- "4205:4205"
command: mock docs/storage.yml -p 4205 -h 0.0.0.0
healthcheck:
test: ["CMD-SHELL", "curl -f http://localhost:4205 || exit 1"]
test: ["CMD-SHELL", "curl -f http://storage:4205 || exit 1"]
interval: 10s
timeout: 5s
retries: 3
networks:
- api-integration-test-network

connected_server:
connected-server:
image: c42/mock-microservice-endpoints:1.0
build:
context: .
Expand All @@ -108,28 +120,32 @@ services:
- "4206:4206"
command: mock docs/connected-server.yml -p 4206 -h 0.0.0.0
healthcheck:
test: ["CMD-SHELL", "curl -f http://localhost:4206 || exit 1"]
test: ["CMD-SHELL", "curl -f http://connected-server:4206 || exit 1"]
interval: 10s
timeout: 5s
retries: 3

audit_logs:
networks:
- api-integration-test-network

audit-log:
image: c42/mock-microservice-endpoints:1.0
build:
context: .
dockerfile: Dockerfile
container_name: mock_audit_logs
container_name: mock_audit_log
restart: always
ports:
- "4207:4207"
command: mock docs/audit-logs.yml -p 4207 -h 0.0.0.0
command: mock docs/audit-log.yml -p 4207 -h 0.0.0.0
healthcheck:
test: ["CMD-SHELL", "curl -f http://localhost:4207 || exit 1"]
test: ["CMD-SHELL", "curl -f http://audit-log:4207 || exit 1"]
interval: 10s
timeout: 5s
retries: 3
networks:
- api-integration-test-network

file_events:
file-events:
image: c42/mock-microservice-endpoints:1.0
build:
context: .
Expand All @@ -140,12 +156,14 @@ services:
- "4208:4208"
command: mock docs/file-events.yml -p 4208 -h 0.0.0.0
healthcheck:
test: ["CMD-SHELL", "curl -f http://localhost:4208 || exit 1"]
test: ["CMD-SHELL", "curl -f http://file-events:4208 || exit 1"]
interval: 10s
timeout: 5s
retries: 3
networks:
- api-integration-test-network

preservation_data_service:
preservation-data-service:
image: c42/mock-microservice-endpoints:1.0
build:
context: .
Expand All @@ -156,10 +174,12 @@ services:
- "4209:4209"
command: mock docs/preservation-data-service.yml -p 4209 -h 0.0.0.0
healthcheck:
test: ["CMD-SHELL", "curl -f http://localhost:4209 || exit 1"]
test: ["CMD-SHELL", "curl -f http://preservation-data-service:4209 || exit 1"]
interval: 10s
timeout: 5s
retries: 3
networks:
- api-integration-test-network

health_checker:
image: c42/mock-microservice-endpoints:1.0
Expand All @@ -170,19 +190,22 @@ services:
condition: service_healthy
alerts:
condition: service_healthy
alert_rules:
alert-rules:
condition: service_healthy
detection_lists:
detection-lists:
condition: service_healthy
cases:
condition: service_healthy
storage:
condition: service_healthy
connected_server:
connected-server:
condition: service_healthy
audit_logs:
audit-log:
condition: service_healthy
file_events:
file-events:
condition: service_healthy
preservation_data_service:
preservation-data-service:
condition: service_healthy

networks:
api-integration-test-network:
File renamed without changes.
22 changes: 11 additions & 11 deletions docs/core.yml
Original file line number Diff line number Diff line change
Expand Up @@ -413,7 +413,7 @@ paths:
'*/*':
schema:
type: string
example: http://127.0.0.1:4201
example: http://alerts:4201
/v1/FedObserver-API_URL:
get:
tags:
Expand All @@ -427,7 +427,7 @@ paths:
'*/*':
schema:
type: string
example: http://127.0.0.1:4202
example: http://alert-rules:4202
/v1/employeecasemanagementV2-API_URL:
get:
tags:
Expand All @@ -441,7 +441,7 @@ paths:
'*/*':
schema:
type: string
example: http://127.0.0.1:4203/svc/api/
example: http://detection-lists:4203/svc/api/
/v1/CASES_API-URL:
get:
tags:
Expand All @@ -454,8 +454,8 @@ paths:
content:
'*/*':
schema:
type: string
example: http://127.0.0.1:4204
type: string
example: http://cases:4204
/api/connectedServerUrl:
get:
tags:
Expand All @@ -472,7 +472,7 @@ paths:
properties:
serverUrl:
type: string
example: http://127.0.0.1:4206
example: http://connected-server:4206
/v1/AUDIT-LOG_API-URL:
get:
tags:
Expand All @@ -486,7 +486,7 @@ paths:
'*/*':
schema:
type: string
example: http://127.0.0.1:4207
example: http://audit-log:4207
/v1/FORENSIC_SEARCH-API_URL:
get:
tags:
Expand All @@ -500,7 +500,7 @@ paths:
'*/*':
schema:
type: string
example: http://127.0.0.1:4208
example: http://file-events:4208
/v1/PRESERVATION-DATA-SERVICE_API-URL:
get:
tags:
Expand All @@ -514,7 +514,7 @@ paths:
'*/*':
schema:
type: string
example: http://127.0.0.1:4209
example: http://preservation-data-service:4209
# DEVICES

/api/v14/agent-state/view-by-device-guid:
Expand Down Expand Up @@ -1451,7 +1451,7 @@ components:
type: string
serverUrl:
type: string
example: http://127.0.0.1:4205
example: http://storage:4205
FileDownloadTokenResponse_core:
type: object
properties:
Expand Down Expand Up @@ -1516,7 +1516,7 @@ components:
type: boolean
stsBaseUrl:
type: string
example: "http://127.0.0.1:4200"
example: "http://core:4200"
OrgResponse_core:
type: object
properties:
Expand Down
2 changes: 1 addition & 1 deletion docs/preservation-data-service.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ paths:
type: string
storageNodeURL:
type: string
example: http://127.0.0.1:4200
example: http://storage:4200
archiveGuid:
type: string
fileId:
Expand Down

0 comments on commit f00c51f

Please sign in to comment.