Skip to content

Commit 831a816

Browse files
committed
fix(compress): fix response for compression plugin and add tests
1 parent 165dab1 commit 831a816

23 files changed

+2706
-80
lines changed

.github/workflows/integration.yaml

+57
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
name: CI - Integration Test
2+
3+
on:
4+
push:
5+
branches: [ master ]
6+
pull_request:
7+
branches: [ master ]
8+
9+
jobs:
10+
build:
11+
runs-on: ubuntu-latest
12+
container-job:
13+
# Containers must run in Linux based operating systems
14+
runs-on: ubuntu-latest
15+
# Docker Hub image that `container-job` executes in
16+
container: node:10.18-jessie
17+
18+
# Service containers to run with `container-job`
19+
services:
20+
# Label used to access the service container
21+
redis:
22+
# Docker Hub image
23+
image: redis
24+
# Set health checks to wait until redis has started
25+
options: >-
26+
--health-cmd "redis-cli ping"
27+
--health-interval 10s
28+
--health-timeout 5s
29+
--health-retries 5
30+
# Steps represent a sequence of tasks that will be executed as part of the job
31+
steps:
32+
- name: Git checkout
33+
uses: actions/checkout@v2
34+
35+
- name: Install Node JS
36+
uses: actions/setup-node@v1
37+
with:
38+
node-version: 17
39+
40+
- name: Install npm deps
41+
run: npm install
42+
43+
- name: Start Redis
44+
uses: supercharge/[email protected]
45+
with:
46+
redis-version: 6.2
47+
48+
- name: Run the integrations tests
49+
run: |
50+
make run-test-server
51+
sleep 10
52+
npm run tests
53+
kill -9 `lsof -i:8091 -t`
54+
env:
55+
MORT_HOST: localhost
56+
MORT_PORT: 8081
57+
CI: true

Dockerfile.integrations

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
FROM node:17-slim
2+
3+
WORKDIR /workdir
4+
RUN mkdir -p /workdir
5+
6+
COPY package.json /workdir/package.json
7+
COPY package-lock.json /workdir/package-lock.json
8+
RUN npm install
9+
10+
COPY scripts/ /workdir/scripts
11+
COPY tests-int /workdir/tests-int
12+
COPY pkg/ /workdir/pkg

Makefile

+3-5
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,8 @@ run-server:
2828
go run cmd/mort/mort.go -config configuration/config.yml
2929

3030
run-test-server:
31-
mkdir -p /tmp/mort-tests/remote
32-
mkdir -p /tmp/mort-tests/remote-query
33-
mkdir -p /tmp/mort-tests/local
34-
fallocate -l 1G /tmp/mort-tests/local/big.img
35-
go run cmd/mort/mort.go -config ./tests-int/config.yml
31+
scripts/prepare-for-tests.sh
32+
go run cmd/mort/mort.go -config ./tests-int/mort.yml
3633

3734
clean-prof:
3835
find . -name ".test" -depth -exec rm {} \;
@@ -43,6 +40,7 @@ release:
4340
docker build . -f Dockerfile.build --build-arg GITHUB_TOKEN=${GITHUB_TOKEN}
4441

4542
docker-tests:
43+
scripts/prepare-for-tests.sh
4644
docker-compose up --build
4745

4846
base-docker-push:

cmd/mort/mort.go

+2
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,7 @@ func startServer(s *http.Server, ln net.Listener) {
198198
if err != nil && err != http.ErrServerClosed {
199199
fmt.Println("Error listen", err)
200200
}
201+
fmt.Println("Server listen", ln.Addr().String())
201202
}
202203

203204
func main() {
@@ -317,6 +318,7 @@ func main() {
317318

318319
var wg sync.WaitGroup
319320

321+
monitoring.Logs().Sync()
320322
wg.Add(1)
321323
go handleSignals(servers, socketPaths, &wg)
322324

configuration/config.yml

+6-6
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,14 @@ server:
44
cache:
55
type: "redis"
66
address:
7-
- "localhost:6379"
7+
- "redis:6379"
88
maxCacheItemSizeMB: 50
99
clientConfig:
10-
# lock:
11-
# type: "redis"
12-
# address:
13-
# - "localhost:6379"
14-
# clientConfig:
10+
lock:
11+
type: "redis"
12+
address:
13+
- "redis:6379"
14+
clientConfig:
1515

1616
listens:
1717
- ":8084"

docker-compose.yaml

+30-11
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,22 @@
11
version: '3'
22

33
services:
4-
# mort:
5-
# build:
6-
# context: .
7-
# dockerfile: Dockerfile
8-
# args:
9-
# - TAG=dev
10-
# - COMMIT=master
11-
# - DATE=now
12-
# restart: always
13-
# ports:
14-
# - 8084:8080
4+
redis:
5+
image: redis
6+
mort:
7+
build:
8+
context: .
9+
dockerfile: Dockerfile
10+
args:
11+
- TAG=tests
12+
- COMMIT=master
13+
- DATE=now
14+
restart: always
15+
ports:
16+
- 8091:8091
17+
volumes:
18+
- /tmp/mort-tests:/tmp/mort-tests
19+
- ./tests-int/:/etc/mort/
1520
tests:
1621
build:
1722
context: .
@@ -21,3 +26,17 @@ services:
2126
- COMMIT=master
2227
- DATE=now
2328
command: ["make", "unit"]
29+
integrations:
30+
build:
31+
context: .
32+
dockerfile: Dockerfile.integrations
33+
command: ["sh", "./scripts/run-tests-docker.sh"]
34+
environment:
35+
- MORT_PORT=8091
36+
- MORT_HOST=mort
37+
volumes:
38+
- /tmp/mort-tests:/tmp/mort-tests:ro
39+
depends_on:
40+
- mort
41+
42+

0 commit comments

Comments
 (0)