Skip to content

Commit 6c2e0a6

Browse files
api-clients-generation-pipeline[bot]jirikuncarci.datadog-api-spec
authored
dev/tooling: enable dd agent in github actions (#189)
* Fix fixture loading * Regenerate client from commit 690ad2a of spec repo * ddtrace install Co-authored-by: Jiri Kuncar <[email protected]> Co-authored-by: api-clients-generation-pipeline[bot] <54105614+api-clients-generation-pipeline[bot]@users.noreply.github.com> Co-authored-by: ci.datadog-api-spec <[email protected]>
1 parent 3caadd3 commit 6c2e0a6

File tree

103 files changed

+1474
-1883
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

103 files changed

+1474
-1883
lines changed

.apigentools-info

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,14 @@
33
"info_version": "2",
44
"spec_versions": {
55
"v1": {
6-
"apigentools_version": "1.3.0",
7-
"regenerated": "2020-12-14 17:30:32.158008",
8-
"spec_repo_commit": "8276009"
6+
"apigentools_version": "1.4.0",
7+
"regenerated": "2020-12-15 12:13:29.100642",
8+
"spec_repo_commit": "690ad2a"
99
},
1010
"v2": {
11-
"apigentools_version": "1.3.0",
12-
"regenerated": "2020-12-14 17:30:41.733120",
13-
"spec_repo_commit": "8276009"
11+
"apigentools_version": "1.4.0",
12+
"regenerated": "2020-12-15 12:13:39.491922",
13+
"spec_repo_commit": "690ad2a"
1414
}
1515
}
1616
}

.azure-pipelines/all.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,8 @@ jobs:
4949
- script: |
5050
python -m pip install --upgrade pip setuptools
5151
python -m pip install cython
52-
python -m pip install -e .[apm,tests]
53-
python -m pip install -U --pre --find-links=https://s3.amazonaws.com/pypi.datadoghq.com/trace-dev/index.html ddtrace
52+
python -m pip install -e .[tests]
53+
python -m pip install --pre --find-links=https://s3.amazonaws.com/pypi.datadoghq.com/trace-dev/index.html ddtrace
5454
displayName: Install package
5555
- script: ./run-tests.sh
5656
displayName: Run integration tests

Dockerfile.test

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1-
FROM python:3.8
1+
FROM python:3.9
22
ENTRYPOINT [/datadog-api-client-python/run-tests.sh]
33

44
COPY . /datadog-api-client-python
55
WORKDIR /datadog-api-client-python/
6-
RUN pip install -e .[apm,tests]
6+
RUN pip install -U --pre --find-links=https://s3.amazonaws.com/pypi.datadoghq.com/trace-dev/index.html ddtrace && \
7+
pip install -e .[tests]

docs/v1/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,9 @@ Python >= 3.6
1818
If the python package is hosted on a repository, you can install directly using:
1919

2020
```sh
21-
pip install git+https://github.com/GIT_USER_ID/GIT_REPO_ID.git
21+
pip install git+https://github.com/DataDog/datadog-api-client-python.git
2222
```
23-
(you may need to run `pip` with root permission: `sudo pip install git+https://github.com/GIT_USER_ID/GIT_REPO_ID.git`)
23+
(you may need to run `pip` with root permission: `sudo pip install git+https://github.com/DataDog/datadog-api-client-python.git`)
2424

2525
Then import the package:
2626
```python

docs/v2/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,9 @@ Python >= 3.6
1818
If the python package is hosted on a repository, you can install directly using:
1919

2020
```sh
21-
pip install git+https://github.com/GIT_USER_ID/GIT_REPO_ID.git
21+
pip install git+https://github.com/DataDog/datadog-api-client-python.git
2222
```
23-
(you may need to run `pip` with root permission: `sudo pip install git+https://github.com/GIT_USER_ID/GIT_REPO_ID.git`)
23+
(you may need to run `pip` with root permission: `sudo pip install git+https://github.com/DataDog/datadog-api-client-python.git`)
2424

2525
Then import the package:
2626
```python

run-tests.sh

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,9 @@ set -e
33
echo "Ensuring all dependencies are present in LICENSE-3rdparty.csv ..."
44
ALL_DEPS="" # TODO
55
DEPS_NOT_FOUND=""
6-
for one_dep in `echo $ALL_DEPS`; do
6+
for one_dep in $ALL_DEPS; do
77
set +e
8-
cat LICENSE-3rdparty.csv | grep "$one_dep" > /dev/null 2>&1
9-
if [ $? -ne 0 ]; then
8+
if grep "$one_dep" LICENSE-3rdparty.csv > /dev/null 2>&1; then
109
DEPS_NOT_FOUND="${DEPS_NOT_FOUND}\n${one_dep}<LICENSE>,<COPYRIGHT>"
1110
fi
1211
set -e
@@ -18,14 +17,12 @@ else
1817
echo "LICENSE-3rdparty.csv is up to date"
1918
fi
2019

21-
# Install test dependencies
22-
python -m pip install -e .
2320
# Run tests
2421
set +e
25-
python -m pytest
22+
python -m pytest -vvv
2623
RESULT=$?
27-
if [ "$RERECORD_FAILED_TESTS" == "true" -a "$RESULT" -ne 0 ]; then
28-
RECORD=true python -m pytest --last-failed
24+
if [ "$RERECORD_FAILED_TESTS" == "true" ] && [ "$RESULT" -ne 0 ]; then
25+
RECORD=true python -m pytest -vvv --last-failed
2926
RESULT=$?
3027
fi
3128
exit $RESULT

tests/conftest.py

Lines changed: 21 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -5,18 +5,18 @@
55

66
# First patch httplib
77
tracer = None
8-
if "false" != os.getenv("RECORD", "false"):
9-
try:
10-
from ddtrace import config, patch, tracer
8+
try:
9+
from ddtrace import config, patch, tracer
1110

12-
config.httplib["distributed_tracing"] = True
13-
patch(httplib=True)
14-
except ImportError:
15-
pass
11+
config.httplib["distributed_tracing"] = True
12+
patch(httplib=True)
13+
except ImportError:
14+
pass
1615

1716
import importlib
1817
import json
1918
import logging
19+
import pathlib
2020
import re
2121
import sys
2222
import time
@@ -143,19 +143,17 @@ def __str__(self):
143143

144144

145145
@pytest.fixture
146-
def context(vcr_cassette, package_name, request, unique, unique_lower):
146+
def context(package_name, request, unique, unique_lower):
147147
"""
148148
Return a mapping with all defined fixtures, all objects created by `given` steps,
149149
and the undo operations to perform after a test scenario.
150150
"""
151-
ctx = {"undo_operations": []}
152-
for f in request.fixturenames:
153-
if f == "context":
154-
continue
155-
try:
156-
ctx[f] = request.getfixturevalue(f)
157-
except Exception:
158-
pass
151+
ctx = {
152+
"undo_operations": [],
153+
"unique": unique,
154+
"unique_lower": unique_lower,
155+
}
156+
159157
yield ctx
160158

161159
exceptions = importlib.import_module(package_name + ".exceptions")
@@ -188,28 +186,23 @@ def record_mode(request):
188186

189187
@pytest.fixture(scope="module")
190188
def vcr_config(record_mode):
191-
def before_record_request(request):
192-
if "Datadog-Meta-Tracer-Version" in request.headers:
193-
return None
194-
return request
195-
196189
config = dict(
197190
filter_headers=("DD-API-KEY", "DD-APPLICATION-KEY"),
198191
filter_query_parameters=("api_key", "application_key"),
199-
before_record_request=before_record_request,
200192
)
201193
return config
202194

203195

204196
@pytest.fixture
205-
def freezer(vcr_cassette_name, vcr_cassette, vcr):
197+
def freezer(vcr_cassette_name, record_mode, vcr):
206198
from freezegun import freeze_time
207199
from dateutil import parser
208200

209-
if vcr_cassette.record_mode != "none":
201+
if record_mode != "false":
210202
tzinfo = datetime.now().astimezone().tzinfo
211203
freeze_at = datetime.now().replace(tzinfo=tzinfo).isoformat()
212-
if vcr_cassette.record_mode == "all":
204+
if record_mode == "true":
205+
pathlib.Path(vcr.cassette_library_dir).mkdir(parents=True, exist_ok=True)
213206
with open(
214207
os.path.join(vcr.cassette_library_dir, vcr_cassette_name + ".frozen"),
215208
"w+",
@@ -273,9 +266,11 @@ def client(_package, configuration, record_mode, vcr_cassette):
273266
vcr_cassette.data.clear()
274267

275268
with _package.ApiClient(configuration) as api_client:
269+
print(f"starting with {vcr_cassette}")
276270
yield api_client
277271

278272

273+
279274
@given(parsers.parse('an instance of "{name}" API'))
280275
def api(context, package_name, client, name):
281276
"""Return an API instance."""
@@ -371,7 +366,7 @@ def cleanup(api, operation_id, response, client=client):
371366

372367

373368
@when("the request is sent")
374-
def execute_request(undo, context, vcr_cassette, client):
369+
def execute_request(undo, context, client):
375370
"""Execute the prepared request."""
376371
api_request = context["api_request"]
377372
api_request["response"] = api_request["request"].call_with_http_info(
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
2020-09-24T15:22:49.668210+02:00
1+
2020-12-14T13:39:55.657993+00:00

0 commit comments

Comments
 (0)