Skip to content

Commit 04bcdf5

Browse files
committed
add contract tests for instrumentation of the following:
* aws sdk * http * mongoose * mongodb * mysql2
1 parent 3d13263 commit 04bcdf5

Some content is hidden

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

54 files changed

+2222
-562
lines changed

.idea/.gitignore

Lines changed: 0 additions & 5 deletions
This file was deleted.

.idea/aws-otel-js-instrumentation.iml

Lines changed: 0 additions & 19 deletions
This file was deleted.

.idea/codeStyles/Project.xml

Lines changed: 0 additions & 136 deletions
This file was deleted.

.idea/codeStyles/codeStyleConfig.xml

Lines changed: 0 additions & 5 deletions
This file was deleted.

.idea/misc.xml

Lines changed: 0 additions & 6 deletions
This file was deleted.

.idea/modules.xml

Lines changed: 0 additions & 8 deletions
This file was deleted.

.idea/prettier.xml

Lines changed: 0 additions & 6 deletions
This file was deleted.

.idea/vcs.xml

Lines changed: 0 additions & 6 deletions
This file was deleted.

contract-tests/README.md

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,9 @@ The tests present here rely on the auto-instrumentation of a sample application
1111
# Types of tested frameworks
1212

1313
The frameworks and libraries that are tested in the contract tests should fall in the following categories (more can be added on demand):
14-
* http-servers - applications meant to test http servers (e.g. Django).
15-
* http-clients - applications meant to test http clients (e.g. requests).
16-
* aws-sdk - Applications meant to test the AWS SDK (e.g. botocore).
17-
* database-clients - Applications meant to test database clients (e.g. psychopg2).
14+
* http-servers - applications meant to test http servers (e.g. http module in node.js).
15+
* aws-sdk - Applications meant to test the AWS SDK (e.g. AWS SDK for JavaScript v3).
16+
* database-clients - Applications meant to test database clients (e.g. mysql2, Mongoose, Mongodb).
1817

1918
When testing a framework, we will create a sample application. The sample applications are stored following this convention: `contract-tests/images/applications/<framework-name>`.
2019

@@ -23,7 +22,7 @@ When testing a framework, we will create a sample application. The sample applic
2322
The steps to add a new test for a library or framework are:
2423
* Create a sample application.
2524
* The sample application should be created in `contract-tests/images/applications/<framework-name>`.
26-
* Implement a `pyproject.toml` (to ensure code style checks run), `Dockerfile`, and `requirements.txt` file. See the `requests` application for an example of this.
25+
* Implement a node.js application and create a `Dockerfile` to containerize the application
2726
* Add a test class for the sample application.
2827
* The test class should be created in `contract-tests/tests/amazon/<framework-name>`.
2928
* The test class should extend `contract_test_base.py`
@@ -34,9 +33,17 @@ Pre-requirements:
3433
* Have `docker` installed and running - verify by running the `docker` command.
3534

3635
Steps:
37-
* From `aws-otel-python-instrumentation` dir, execute:
36+
* From `aws-otel-js-instrumentation` dir, execute:
3837
```sh
38+
# create a virtual environment in python for the tests
39+
python3 -m venv venv
40+
source venv/bin/activate
41+
# build the instrumentation SDK
3942
./scripts/build_and_install_distro.sh
43+
# build the relevant images for sample app and build the contract tests
4044
./scripts/set-up-contract-tests.sh
45+
# run all the tests
4146
pytest contract-tests/tests
47+
# exit the virtual python environment
48+
deactivate
4249
```
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# Use an official Node.js runtime as the base image
2+
FROM node:20-alpine
3+
#FROM node:20
4+
5+
# Set the working directory inside the container
6+
WORKDIR /aws-sdk
7+
8+
# Copy the relevant files
9+
COPY ./dist/$DISTRO /aws-sdk
10+
COPY ./contract-tests/images/applications/aws-sdk /aws-sdk
11+
12+
13+
ARG DISTRO
14+
# Install dependencies
15+
RUN npm install
16+
RUN npm install ./${DISTRO}
17+
18+
# Expose the port the app runs on
19+
EXPOSE 8080
20+
21+
# Run the app with nodejs auto instrumentation
22+
CMD ["node", "--require", "@aws/aws-distro-opentelemetry-node-autoinstrumentation/register", "server.js"]

0 commit comments

Comments
 (0)