Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 4 additions & 6 deletions haproxy-healthcheck/compose.yml
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
version: "3.7"
services:
mock-couchdb:
image: mockserver/mockserver:5.15.0
environment:
MOCKSERVER_SERVER_PORT: 5984
# MOCKSERVER_LOG_LEVEL: WARN
MOCKSERVER_INITIALIZATION_JSON_PATH: /config/initializerJson.json
image: nginx:1-alpine-slim
volumes:
- ./mock-config/:/config/
- ./mock-config/conf.d/:/etc/nginx/conf.d/:ro
ports:
- 127.0.0.1:5984:5984

haproxy-healthcheck:
build: .
Expand Down
20 changes: 20 additions & 0 deletions haproxy-healthcheck/mock-config/conf.d/mock-couchdb.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
server {
listen 5984;
server_name localhost;

#access_log /var/log/nginx/host.access.log main;

location = / {
add_header Content-Type application/json;
return 200 '{ "couchdb": "Welcome to mock-couchdb", "status": "this field is not used" }';
}

location = /_membership {
add_header Content-Type application/json;
return 200 '{ "all_nodes": [ "mock-couchdb" ], "cluster_nodes": [ "mock-couchdb" ] }';
}

location = /error/drop {
return 444;
}
}
36 changes: 0 additions & 36 deletions haproxy-healthcheck/mock-config/initializerJson.json

This file was deleted.

3 changes: 3 additions & 0 deletions haproxy/tests/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,6 @@ test_with_docker_compose:
bats with_mock.bats
docker compose down

.PHONY: clean
clean:
docker compose down --rmi local || :
63 changes: 29 additions & 34 deletions haproxy/tests/compose.yml
Original file line number Diff line number Diff line change
@@ -1,38 +1,33 @@
version: "3.7"
services:
haproxy:
build:
context: ../
ports:
- 127.0.0.1:5984:5984
environment:
COUCHDB_SERVERS: mock-couchdb
COUCHDB_USER: someuser
COUCHDB_PASSWORD: insecure_pw
HAPROXY_IP: 0.0.0.0
HAPROXY_PORT: 5984
HEALTHCHECK_ADDR: haproxy-healthcheck
depends_on:
- mock-couchdb
- haproxy-healthcheck
haproxy:
build:
context: ../
ports:
- 127.0.0.1:5984:5984
environment:
COUCHDB_SERVERS: mock-couchdb1,mock-couchdb2,mock-couchdb3
COUCHDB_USER: someuser
COUCHDB_PASSWORD: insecure_pw
HAPROXY_IP: 0.0.0.0
HAPROXY_PORT: 5984
HEALTHCHECK_ADDR: haproxy-healthcheck
depends_on:
- mock-couchdb1
- haproxy-healthcheck

mock-couchdb:
image: mockserver/mockserver:5.15.0
ports:
- 127.0.0.1:5985:5984
environment:
MOCKSERVER_SERVER_PORT: 5984
# MOCKSERVER_LOG_LEVEL: WARN
MOCKSERVER_INITIALIZATION_JSON_PATH: /config/initializerJson.json
volumes:
- ./mock-config/initializerJson.json:/config/initializerJson.json

haproxy-healthcheck:
build: ../../haproxy-healthcheck
ports:
- 127.0.0.1:5555:5555
environment:
COUCHDB_SERVERS: mock-couchdb
COUCHDB_USER: someuser
COUCHDB_PASSWORD: insecure_pw
mock-couchdb1: &mockserver
image: nginx:1-alpine-slim
volumes:
- ./mock-config/conf.d/:/etc/nginx/conf.d/:ro
mock-couchdb2: *mockserver
mock-couchdb3: *mockserver

haproxy-healthcheck:
build: ../../haproxy-healthcheck
ports:
- 127.0.0.1:5555:5555
environment:
COUCHDB_SERVERS: mock-couchdb1,mock-couchdb2,mock-couchdb3
COUCHDB_USER: someuser
COUCHDB_PASSWORD: insecure_pw
20 changes: 20 additions & 0 deletions haproxy/tests/mock-config/conf.d/mock-couchdb.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
server {
listen 5984;
server_name localhost;

#access_log /var/log/nginx/host.access.log main;

location = / {
add_header Content-Type application/json;
return 200 '{ "couchdb": "Welcome to mock-couchdb", "status": "this field is not used" }';
}

location = /_membership {
add_header Content-Type application/json;
return 200 '{ "all_nodes": [ "mock-couchdb1","mock-couchdb2","mock-couchdb3" ], "cluster_nodes": [ "mock-couchdb1","mock-couchdb2","mock-couchdb3" ] }';
}

location = /error/drop {
return 444;
}
}
36 changes: 0 additions & 36 deletions haproxy/tests/mock-config/initializerJson.json

This file was deleted.

6 changes: 5 additions & 1 deletion nginx/tests/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,8 @@ test:

docker compose up --wait --build
bats with_mock.bats
docker compose down
docker compose down

.PHONY: clean
clean:
docker compose down --rmi local || :
44 changes: 20 additions & 24 deletions nginx/tests/compose.yml
Original file line number Diff line number Diff line change
@@ -1,29 +1,25 @@
version: "3.7"
services:
cht-nginx:
build:
context: ../
ports:
- 127.0.0.1:1080:80
- 127.0.0.1:1443:443
environment:
API_HOST: cht-api
API_PORT: 5988
CERTIFICATE_MODE: SELF_SIGNED
volumes:
- cht-ssl:/root/.acme.sh/
depends_on:
- cht-api
cht-nginx:
build:
context: ../
ports:
- 127.0.0.1:1080:80
- 127.0.0.1:1443:443
environment:
API_HOST: mock-api
API_PORT: 5988
CERTIFICATE_MODE: SELF_SIGNED
volumes:
- cht-ssl:/root/.acme.sh/
depends_on:
- mock-api

cht-api:
image: mockserver/mockserver:5.15.0
command: -serverPort 5988
environment:
MOCKSERVER_PROPERTY_FILE: /config/mockserver.properties
MOCKSERVER_INITIALIZATION_JSON_PATH: /config/initializerJson.json
volumes:
- ./mock-config:/config
mock-api:
image: nginx:1-alpine-slim
volumes:
- ./mock-config/conf.d/:/etc/nginx/conf.d/:ro

volumes:
cht-ssl:
name: cht-ssl
cht-ssl:
name: cht-ssl
18 changes: 18 additions & 0 deletions nginx/tests/mock-config/conf.d/mock-api.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
server {
listen 5988;
server_name localhost;

#access_log /var/log/nginx/host.access.log main;

location = / {
return 200 'Hello from CHT api mock';
}

location = /somepath {
return 200 'Test';
}

location = /error/drop {
return 444;
}
}
26 changes: 0 additions & 26 deletions nginx/tests/mock-config/initializerJson.json

This file was deleted.

32 changes: 0 additions & 32 deletions nginx/tests/mock-config/mockserver.properties

This file was deleted.