Skip to content

Commit a8c2465

Browse files
committed
Fix workflow
1 parent 7b3f0d6 commit a8c2465

File tree

7 files changed

+84
-38
lines changed

7 files changed

+84
-38
lines changed

Diff for: .github/workflows/fips-test.yml

+32-13
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,6 @@
11
name: Test FIPS
22

33
on:
4-
workflow_dispatch:
5-
inputs:
6-
agent-image:
7-
description: "Agent image to use"
8-
required: false
9-
type: string
10-
target:
11-
description: "Target to test"
12-
required: false
13-
type: string
144
pull_request:
155
path:
166
- datadog_checks_base/datadog_checks/**
@@ -26,20 +16,49 @@ jobs:
2616
strategy:
2717
matrix:
2818
os: [ubuntu-22.04, windows-2022]
19+
agent-image: ["datadog/agent-dev:master-py3", "datadog/agent-dev:master-fips", "datadog/agent-dev:master-py3-win-servercore"]
20+
server-image: ["alpine:3.14", "mcr.microsoft.com/windows/nanoserver:ltsc2022"]
21+
exclude:
22+
- os: windows-2022
23+
agent-image: "datadog/agent-dev:master-fips"
24+
- os: windows-2022
25+
server-image: "alpine:3.14"
26+
- os: windows-2022
27+
agent-image: "datadog/agent-dev:master-py3"
28+
- os: ubuntu-22.04
29+
agent-image: "datadog/agent-dev:master-py3-win-servercore"
30+
- os: ubuntu-22.04
31+
server-image: "windows:ltsc2022"
32+
runs-on: ${{ matrix.os }}
2933
name: "Test FIPS"
3034

3135
env:
3236
FORCE_COLOR: "1"
3337
PYTHON_VERSION: "3.12"
34-
AGENT_IMAGE: "${{ inputs.agent-image }}"
3538

3639
steps:
3740

41+
- uses: actions/checkout@v4
42+
43+
- name: Set up Python ${{ env.PYTHON_VERSION }}
44+
uses: actions/setup-python@v5
45+
with:
46+
python-version: "${{ env.PYTHON_VERSION }}"
47+
cache: 'pip'
48+
49+
- name: Install pytest
50+
run: |
51+
pip install pytest
52+
3853
- name: Set up containers
54+
env:
55+
AGENT_IMAGE: "${{ matrix.agent-image }}"
56+
SERVER_IMAGE: "${{ matrix.server-image }}"
57+
DD_API_KEY: ${{ secrets.DD_API_KEY }}
3958
run: |
40-
docker compose up -d ./compose/docker-compose.yml
59+
docker compose -f .github/workflows/fips/compose/docker-compose.yml up -d
4160
4261
- name: Run tests
4362
run: |
44-
pytest -v ./tests
63+
pytest -v .github/workflows/fips/tests
4564

Diff for: .github/workflows/fips/compose/agent/Dockerfile

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
ARG BASE_IMAGE
2+
3+
FROM ${BASE_IMAGE}
4+
5+
RUN echo "Using base image: ${BASE_IMAGE}"
6+
7+
ADD conf.d/connections.yaml /etc/datadog-agent/conf.d/connections.yaml
8+
ADD checks.d/connections.py /etc/datadog-agent/checks.d/connections.py

Diff for: .github/workflows/fips/compose/agent/checks.d/connections.py

+7-1
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,10 @@
33

44
class HelloCheck(AgentCheck):
55
def check(self, instance):
6-
self.gauge('hello.world', 1)
6+
try:
7+
self.http.get(instance.get('http_endpoint'))
8+
except Exception as e:
9+
self.gauge('http_status', 1)
10+
print(f"Exception when trying to connect to {instance.get('http_endpoint')}: {e}")
11+
else:
12+
self.gauge('https_status', 0)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
init_config:
2+
3+
instances:
4+
- http_endpoint: http://localhost:8080
5+

Diff for: .github/workflows/fips/compose/docker-compose.yml

+21-21
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,36 @@
11
services:
22
agent:
3-
image: ${AGENT_IMAGE}
3+
build:
4+
context: agent
5+
dockerfile: Dockerfile
6+
args:
7+
- BASE_IMAGE=$AGENT_IMAGE
8+
pid: host
9+
environment:
10+
- DD_API_KEY=$DD_API_KEY
11+
- DD_SITE=datad0g.com
412
volumes:
5-
- ./agent/checks.d:/etc/datadog-agent/checks.d
6-
- ./agent/conf.d:/etc/datadog-agent/conf.d
13+
- /var/run/docker.sock:/var/run/docker.sock
14+
- /proc/:/host/proc/:ro
15+
- /sys/fs/cgroup:/host/sys/fs/cgroup:ro
716
healthcheck:
8-
test: ["CMD", "agent", "status"]
17+
test: ["CMD", "agent", "run"]
918
interval: 5s
1019
timeout: 2s
1120
retries: 3
12-
fips-server:
13-
build: ./server
21+
http-server:
22+
build:
23+
context: server
24+
dockerfile: Dockerfile
25+
args:
26+
- BASE_IMAGE=$SERVER_IMAGE
27+
- CIPHER=$CIPHER
1428
ports:
1529
- "8443:443"
1630
volumes:
1731
- ./server/ca.crt:/etc/ssl/certs/server.crt
1832
- ./server/ca.key:/etc/ssl/private/server.key
19-
command: ["/usr/local/bin/start-server.sh", "ECDHE-RSA-AES128-SHA256"]
20-
healthcheck:
21-
test: ["CMD", "curl", "-f", "https://localhost:443"]
22-
interval: 30s
23-
timeout: 10s
24-
retries: 3
25-
26-
non-fips-server:
27-
build: ./server
28-
ports:
29-
- "9443:443"
30-
volumes:
31-
- ./server/ca.crt:/etc/ssl/certs/server.crt
32-
- ./server/ca.key:/etc/ssl/private/server.key
33-
command: ["/usr/local/bin/start-server.sh", "ECDHE-RSA-CHACHA20-POLY1305"]
33+
command: ["/usr/local/bin/start-server.sh", $CIPHER]
3434
healthcheck:
3535
test: ["CMD", "curl", "-f", "https://localhost:443"]
3636
interval: 30s

Diff for: .github/workflows/fips/compose/server/Dockerfile

+7-3
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,15 @@
1-
FROM alpine:3.18
1+
ARG BASE_IMAGE
22

3-
# Install OpenSSL and necessary tools
4-
RUN apk add --no-cache openssl bash
3+
FROM ${BASE_IMAGE}
4+
5+
SHELL ["sh", "-c"]
56

67
COPY start-server.sh /usr/local/bin/start-server.sh
78
COPY ca.* /tmp/
89
RUN chmod +x /usr/local/bin/start-server.sh
910

11+
# Install OpenSSL and necessary tools
12+
RUN apk add --no-cache openssl bash
13+
1014
# Expose port 443
1115
EXPOSE 443

Diff for: .github/workflows/fips/tests/test_connections.py

+4
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,6 @@
1+
import subprocess
2+
3+
14
def test_connections():
5+
subprocess.run(["docker", "exec", "compose-agent-1", "agent", "check", "connections", "--json"], check=True)
26
pass

0 commit comments

Comments
 (0)