Skip to content

Commit 117edcc

Browse files
author
Juliya Smith
authored
hooking up integration tests with mock servers (#253)
1 parent e0c438b commit 117edcc

5 files changed

Lines changed: 41 additions & 8 deletions

File tree

.github/workflows/build.yml

Lines changed: 29 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,15 +18,42 @@ jobs:
1818

1919
steps:
2020
- uses: actions/checkout@v2
21+
with:
22+
path: code42cli
2123
- name: Setup Python
2224
uses: actions/setup-python@v1
2325
with:
2426
python-version: ${{ matrix.python }}
2527
- name: Install tox
2628
run: pip install tox==3.17.1
2729
- name: Run Unit tests
28-
run: tox -e py # Run tox using the version of Python in `PATH`
30+
run: cd code42cli; tox -e py # Run tox using the version of Python in `PATH`
2931
- name: Submit coverage report
3032
uses: codecov/[email protected]
3133
with:
32-
file: ./coverage.xml
34+
file: code42cli/coverage.xml
35+
- name: Checkout mock servers
36+
uses: actions/checkout@v2
37+
with:
38+
repository: code42/code42-mock-servers
39+
path: code42-mock-servers
40+
- name: Add mock servers host addresses
41+
run: |
42+
sudo tee -a /etc/hosts <<EOF
43+
127.0.0.1 core
44+
127.0.0.1 alerts
45+
127.0.0.1 alert-rules
46+
127.0.0.1 detection-lists
47+
127.0.0.1 audit-log
48+
127.0.0.1 file-events
49+
127.0.0.1 storage
50+
127.0.0.1 preservation-data-service
51+
127.0.0.1 connected-server
52+
127.0.0.1 cases
53+
EOF
54+
- name: Install ncat
55+
run: sudo apt-get install ncat
56+
- name: Start up the mock servers
57+
run: cd code42-mock-servers; docker-compose up -d --build
58+
- name: Run the integration tests
59+
run: cd code42cli; tox -e integration

src/code42cli/cmds/search/options.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -152,10 +152,12 @@ def server_options(f):
152152
type=click.Choice(ServerProtocol(), case_sensitive=False),
153153
default=ServerProtocol.UDP,
154154
help="Protocol used to send logs to server. "
155-
"Use TLS for additional security. Defaults to UDP.",
155+
"Use TCP-TLS for additional security. Defaults to UDP.",
156156
)
157157
certs_option = click.option(
158-
"--certs", type=str, help="A CA certificates-chain file for the TLS protocol."
158+
"--certs",
159+
type=str,
160+
help="A CA certificates-chain file for the TCP-TLS protocol.",
159161
)
160162
ignore_cert_validation = click.option(
161163
"--ignore-cert-validation",

tests/integration/conftest.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,13 +49,13 @@ def append_profile(command):
4949
return "{} --profile {}".format(command, TEST_PROFILE_NAME)
5050

5151

52-
@pytest.yield_fixture(scope="session")
52+
@pytest.fixture(scope="session")
5353
def udp_dataserver():
5454
with DataServer(protocol="UDP"):
5555
yield
5656

5757

58-
@pytest.yield_fixture(scope="session")
58+
@pytest.fixture(scope="session")
5959
def tcp_dataserver():
6060
with DataServer(protocol="TCP"):
6161
yield

tests/integration/util.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import os
22
import subprocess
3+
import time
34
from shlex import split as split_command
45

56
from code42cli.main import cli
@@ -48,7 +49,8 @@ def __init__(self, protocol="TCP"):
4849
self.process = None
4950

5051
def __enter__(self):
51-
self.process = subprocess.Popen(self.command.split(" "))
52+
self.process = subprocess.Popen(self.command, shell=True)
53+
time.sleep(1)
5254

5355
def __exit__(self, exc_type, exc_val, exc_tb):
5456
self.process.kill()

tox.ini

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@ deps = pre-commit
3939
skip_install = true
4040
commands = pre-commit run --all-files --show-diff-on-failure
4141

42-
4342
[testenv:nightly]
4443
deps =
4544
pytest == 4.6.11
@@ -48,6 +47,9 @@ deps =
4847
git+https://github.com/code42/py42.git@master#egg=py42
4948
git+ssh://[email protected]/code42/c42eventextractor.git@master#egg=c42eventextractor
5049

50+
[testenv:integration]
51+
commands =
52+
pytest -v -rsxX -l --tb=short --strict -m integration
5153

5254
[pytest]
5355
markers =

0 commit comments

Comments
 (0)