Fix docker tests by increasing timeout (again) and move compose test to plugin (#2112)
* Fix docker tests by increasing timeout (again) and move compose test to plugin * Bump workflow timeout to 30 min * Test only alpine-slim and debian-full flavors
This commit is contained in:
parent
e161507d08
commit
0a114ca7d1
27
.github/workflows/docker-tests.yml
vendored
27
.github/workflows/docker-tests.yml
vendored
|
@ -17,6 +17,7 @@ on:
|
|||
jobs:
|
||||
test_docker_image:
|
||||
runs-on: ubuntu-latest
|
||||
timeout-minutes: 30
|
||||
steps:
|
||||
|
||||
- name: Check out the repo
|
||||
|
@ -29,17 +30,17 @@ jobs:
|
|||
with:
|
||||
config: .github/buildkit.toml
|
||||
|
||||
- name: "Build flavor: full"
|
||||
uses: docker/build-push-action@v4
|
||||
with:
|
||||
context: .
|
||||
file: ./Dockerfile
|
||||
tags: crowdsecurity/crowdsec:test
|
||||
target: full
|
||||
platforms: linux/amd64
|
||||
load: true
|
||||
cache-from: type=gha
|
||||
cache-to: type=gha,mode=min
|
||||
# - name: "Build flavor: full"
|
||||
# uses: docker/build-push-action@v4
|
||||
# with:
|
||||
# context: .
|
||||
# file: ./Dockerfile
|
||||
# tags: crowdsecurity/crowdsec:test
|
||||
# target: full
|
||||
# platforms: linux/amd64
|
||||
# load: true
|
||||
# cache-from: type=gha
|
||||
# cache-to: type=gha,mode=min
|
||||
|
||||
- name: "Build flavor: slim"
|
||||
uses: docker/build-push-action@v4
|
||||
|
@ -94,9 +95,9 @@ jobs:
|
|||
- name: "Run tests"
|
||||
env:
|
||||
CROWDSEC_TEST_VERSION: test
|
||||
CROWDSEC_TEST_FLAVORS: full,slim,debian
|
||||
CROWDSEC_TEST_FLAVORS: slim,debian
|
||||
CROWDSEC_TEST_NETWORK: net-test
|
||||
CROWDSEC_TEST_TIMEOUT: 60
|
||||
CROWDSEC_TEST_TIMEOUT: 90
|
||||
run: |
|
||||
cd docker/test
|
||||
pipenv run pytest -n 2 --durations=0 --color=yes
|
||||
|
|
|
@ -1,21 +0,0 @@
|
|||
#!/usr/bin/env python
|
||||
|
||||
import time
|
||||
|
||||
import pytest
|
||||
import requests
|
||||
|
||||
pytestmark = pytest.mark.compose
|
||||
|
||||
|
||||
def test_compose_simple(compose, datadir):
|
||||
with compose(datadir / 'docker-compose.yml') as project:
|
||||
j = project.ps()
|
||||
assert len(j) == 1
|
||||
assert j[0]['Name'] == 'test_compose-server-1'
|
||||
assert j[0]['State'] == 'running'
|
||||
assert j[0]['Publishers'][0]['TargetPort'] == 8000
|
||||
port = j[0]['Publishers'][0]['PublishedPort']
|
||||
# XXX: should retry with a timeout
|
||||
time.sleep(.5)
|
||||
assert requests.get(f'http://localhost:{port}').status_code == 200
|
|
@ -1,8 +0,0 @@
|
|||
version: "3"
|
||||
|
||||
services:
|
||||
server:
|
||||
image: python:alpine
|
||||
command: python -m http.server 8000
|
||||
ports:
|
||||
- 8000
|
|
@ -8,7 +8,7 @@ import pytest
|
|||
pytestmark = pytest.mark.docker
|
||||
|
||||
|
||||
def test_split_lapi_agent(crowdsec):
|
||||
def test_split_lapi_agent(crowdsec, flavor):
|
||||
rand = str(random.randint(0, 10000))
|
||||
lapiname = f'lapi-{rand}'
|
||||
agentname = f'agent-{rand}'
|
||||
|
@ -25,7 +25,10 @@ def test_split_lapi_agent(crowdsec):
|
|||
'LOCAL_API_URL': f'http://{lapiname}:8080',
|
||||
}
|
||||
|
||||
with crowdsec(name=lapiname, environment=lapi_env) as lapi, crowdsec(name=agentname, environment=agent_env) as agent:
|
||||
cs_lapi = crowdsec(name=lapiname, environment=lapi_env, flavor=flavor)
|
||||
cs_agent = crowdsec(name=agentname, environment=agent_env, flavor=flavor)
|
||||
|
||||
with cs_lapi as lapi, cs_agent as agent:
|
||||
lapi.wait_for_log("*CrowdSec Local API listening on 0.0.0.0:8080*")
|
||||
agent.wait_for_log("*Starting processing data*")
|
||||
lapi.wait_for_http(8080, '/health', want_status=HTTPStatus.OK)
|
||||
|
|
|
@ -6,8 +6,8 @@ pytestmark = pytest.mark.docker
|
|||
|
||||
|
||||
# XXX this is redundant, already tested in pytest_cs
|
||||
def test_crowdsec(crowdsec):
|
||||
with crowdsec() as cs:
|
||||
def test_crowdsec(crowdsec, flavor):
|
||||
with crowdsec(flavor=flavor) as cs:
|
||||
for waiter in cs.log_waiters():
|
||||
with waiter as matcher:
|
||||
matcher.fnmatch_lines(["*Starting processing data*"])
|
||||
|
|
Loading…
Reference in a new issue