Skip to content

Commit 826cd57

Browse files
authored
XDB-510 added joshua container creation (#219) (#220)
1 parent cf357bb commit 826cd57

5 files changed

Lines changed: 197 additions & 75 deletions

File tree

.github/workflows/build.yml

Lines changed: 5 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -183,70 +183,8 @@ jobs:
183183
184184
tests:
185185
needs: [calc_ver, build]
186-
runs-on: ubuntu-latest
187-
env:
188-
JOSHUA_DB_VER: "6.3.15"
189-
N_OF_TESTS: 500 # to fit in 360 minutes job run limit
190-
JOSHUA_AGENT_URL: "docker.io/1inker"
191-
JOSHUA_AGENT_TAG: "rhel8-20220816"
192-
193-
steps:
194-
- name: Checkout
195-
uses: actions/checkout@v4
196-
with:
197-
path: ${{github.workspace}}/src
198-
199-
- name: Install dependencies
200-
shell: bash
201-
run: |
202-
sudo apt-get update
203-
sudo apt-get install -y sudo wget crudini git python3 python3-pip
204-
sudo pip3 install wheel setuptools python-dateutil lxml boto3
205-
206-
- name: Install FoundationDb
207-
shell: bash
208-
run: |
209-
mkdir deb
210-
pushd deb
211-
MY_ARCH=`dpkg-architecture -q DEB_BUILD_ARCH`
212-
wget https://github.com/apple/foundationdb/releases/download/${{ env.JOSHUA_DB_VER }}/foundationdb-clients_${{ env.JOSHUA_DB_VER }}-1_${MY_ARCH}.deb https://github.com/apple/foundationdb/releases/download/${{ env.JOSHUA_DB_VER }}/foundationdb-server_${{ env.JOSHUA_DB_VER }}-1_${MY_ARCH}.deb
213-
sudo apt-get install -y ./foundationdb-clients_${{ env.JOSHUA_DB_VER }}-1_${MY_ARCH}.deb ./foundationdb-server_${{ env.JOSHUA_DB_VER }}-1_${MY_ARCH}.deb
214-
popd
215-
sudo systemctl stop foundationdb
216-
MY_IP=`hostname -I | awk '{print $1}'`
217-
sudo sed -i s/127.0.0.1/$MY_IP/ /etc/foundationdb/fdb.cluster
218-
sudo crudini --set /etc/foundationdb/foundationdb.conf fdbserver memory 4GiB
219-
sudo systemctl start foundationdb
220-
pip3 install 'foundationdb==${{ env.JOSHUA_DB_VER }}'
221-
222-
- name: Download the correctness package
223-
uses: actions/download-artifact@v4
224-
id: download_correctness
225-
with:
226-
name: correctness-${{needs.calc_ver.outputs.full_ver}}.tar.gz
227-
228-
- name: 'Echo download path'
229-
run: echo ${{steps.download_correctness.outputs.download-path}}
230-
231-
- name: Display structure of downloaded files
232-
run: ls -R
233-
working-directory: ${{github.workspace}}
234-
235-
- name: Download joshua
236-
shell: bash
237-
run: |
238-
git clone https://github.com/FoundationDB/fdb-joshua.git
239-
240-
- name: run joshua-agent
241-
shell: bash
242-
run: |
243-
podman pull ${{ env.JOSHUA_AGENT_URL }}/joshua-agent:${{ env.JOSHUA_AGENT_TAG }}
244-
podman create --name joshua-agent -v /etc/foundationdb:/etc/foundationdb -it joshua-agent:${{ env.JOSHUA_AGENT_TAG }}
245-
podman start joshua-agent
246-
247-
- name: run tests
248-
shell: bash
249-
working-directory: ${{github.workspace}}/fdb-joshua
250-
run: |
251-
podman ps
252-
${{github.workspace}}/src/build-scripts/for-linux/test-joshua.bash ${{github.workspace}}/correctness-${{needs.calc_ver.outputs.full_ver}}.tar.gz ${{env.N_OF_TESTS}}
186+
uses: ./.github/workflows/run-tests.yml
187+
with:
188+
full_ver: ${{needs.calc_ver.outputs.full_ver}}
189+
build_run_id: ${{ github.run_id }}
190+
secrets: inherit
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
---
2+
name: Make joshua agent image
3+
4+
on:
5+
workflow_dispatch:
6+
push:
7+
tags: ["*.joshua-image"]
8+
9+
jobs:
10+
build-joshua-image:
11+
permissions:
12+
contents: read
13+
packages: write
14+
runs-on: ubuntu-latest
15+
16+
env:
17+
IMAGE_NAME: joshua-agent
18+
REGISTRY: ghcr.io
19+
20+
steps:
21+
- name: Clone fdb-joshua
22+
run: git clone https://github.com/FoundationDB/fdb-joshua.git
23+
24+
- name: Build image
25+
working-directory: fdb-joshua
26+
run: |
27+
COMMIT_HASH=$(git rev-parse --short=10 HEAD)
28+
DATE_STR=$(date +"%Y%m%d%H%M%S")
29+
IMG_TAG="${DATE_STR}-${COMMIT_HASH}"
30+
REPO_OWNER="${GITHUB_REPOSITORY_OWNER,,}"
31+
32+
FULL_IMAGE_NAME="${REGISTRY}/${REPO_OWNER}/${IMAGE_NAME}:${IMG_TAG}"
33+
34+
echo "FULL_IMAGE_NAME=${FULL_IMAGE_NAME}" >> "$GITHUB_ENV"
35+
36+
podman build -t "${FULL_IMAGE_NAME}" .
37+
38+
- name: Log in to registry
39+
run: echo "${{ secrets.GITHUB_TOKEN }}" | podman login ghcr.io -u "${GITHUB_REPOSITORY_OWNER,,}" --password-stdin
40+
41+
- name: Push image
42+
run: podman push "${FULL_IMAGE_NAME}"

.github/workflows/run-tests.yml

Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
name: Run Tests (reusable)
2+
3+
on:
4+
workflow_call:
5+
inputs:
6+
full_ver:
7+
description: 'Version of the build to test (e.g. 7.4.0-3.1.ow)'
8+
required: true
9+
type: string
10+
build_run_id:
11+
description: 'Run ID to download the correctness package from'
12+
required: true
13+
type: string
14+
15+
jobs:
16+
tests:
17+
runs-on: ubuntu-latest
18+
env:
19+
JOSHUA_DB_VER: "7.1.57"
20+
N_OF_TESTS: 500 # to fit in 360 minutes job run limit
21+
JOSHUA_AGENT_TAG: "rockylinux9.6-20260309"
22+
# parameter that controls the maximum lifetime of the Joshua agent (in seconds).
23+
AGENT_TIMEOUT: 18000
24+
25+
steps:
26+
- name: Set agent URL
27+
run: |
28+
echo "JOSHUA_AGENT_URL=ghcr.io/${GITHUB_REPOSITORY_OWNER,,}" >> $GITHUB_ENV
29+
echo "Agent URL: ghcr.io/${GITHUB_REPOSITORY_OWNER,,}"
30+
31+
- name: Checkout
32+
uses: actions/checkout@v4
33+
with:
34+
path: ${{github.workspace}}/src
35+
36+
- name: Install dependencies
37+
shell: bash
38+
run: |
39+
sudo apt-get update
40+
sudo apt-get install -y sudo wget crudini git python3 python3-pip
41+
sudo pip3 install wheel setuptools python-dateutil lxml boto3
42+
43+
- name: Install FoundationDb
44+
shell: bash
45+
run: |
46+
mkdir deb
47+
pushd deb
48+
MY_ARCH=`dpkg-architecture -q DEB_BUILD_ARCH`
49+
wget https://github.com/apple/foundationdb/releases/download/${{ env.JOSHUA_DB_VER }}/foundationdb-clients_${{ env.JOSHUA_DB_VER }}-1_${MY_ARCH}.deb https://github.com/apple/foundationdb/releases/download/${{ env.JOSHUA_DB_VER }}/foundationdb-server_${{ env.JOSHUA_DB_VER }}-1_${MY_ARCH}.deb
50+
sudo apt-get install -y ./foundationdb-clients_${{ env.JOSHUA_DB_VER }}-1_${MY_ARCH}.deb ./foundationdb-server_${{ env.JOSHUA_DB_VER }}-1_${MY_ARCH}.deb
51+
popd
52+
sudo systemctl stop foundationdb
53+
MY_IP=`hostname -I | awk '{print $1}'`
54+
sudo sed -i s/127.0.0.1/$MY_IP/ /etc/foundationdb/fdb.cluster
55+
sudo crudini --set /etc/foundationdb/foundationdb.conf fdbserver memory 4GiB
56+
sudo systemctl start foundationdb
57+
pip3 install 'foundationdb==${{ env.JOSHUA_DB_VER }}'
58+
59+
- name: Download the correctness package
60+
uses: actions/download-artifact@v4
61+
id: download_correctness
62+
with:
63+
name: correctness-${{ inputs.full_ver }}.tar.gz
64+
run-id: ${{ inputs.build_run_id }}
65+
github-token: ${{ secrets.GITHUB_TOKEN }}
66+
67+
- name: Echo download path
68+
run: echo ${{steps.download_correctness.outputs.download-path}}
69+
70+
- name: Display structure of downloaded files
71+
run: ls -R
72+
working-directory: ${{github.workspace}}
73+
74+
- name: Download joshua
75+
shell: bash
76+
run: |
77+
git clone https://github.com/FoundationDB/fdb-joshua.git
78+
79+
- name: run joshua-agent
80+
shell: bash
81+
run: |
82+
podman pull ${{ env.JOSHUA_AGENT_URL }}/joshua-agent:${{ env.JOSHUA_AGENT_TAG }}
83+
for i in 1 2 3 4; do
84+
podman run -d \
85+
-v /etc/foundationdb:/etc/foundationdb \
86+
-e AGENT_TIMEOUT=${{ env.AGENT_TIMEOUT }} \
87+
joshua-agent:${{ env.JOSHUA_AGENT_TAG }}
88+
done
89+
90+
- name: run tests
91+
shell: bash
92+
working-directory: ${{github.workspace}}/fdb-joshua
93+
run: |
94+
podman ps
95+
${{github.workspace}}/src/build-scripts/for-linux/test-joshua.bash ${{github.workspace}}/correctness-${{ inputs.full_ver }}.tar.gz ${{env.N_OF_TESTS}}

.github/workflows/tests-only.yml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
name: Tests only
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
full_ver:
7+
description: 'Version of the build to test (e.g. 7.4.0-3.1.ow)'
8+
required: true
9+
build_run_id:
10+
description: 'Run ID of the build workflow (find it in the URL of the build run)'
11+
required: true
12+
13+
jobs:
14+
tests:
15+
uses: ./.github/workflows/run-tests.yml
16+
with:
17+
full_ver: ${{ github.event.inputs.full_ver }}
18+
build_run_id: ${{ github.event.inputs.build_run_id }}
19+
secrets: inherit

build-scripts/for-linux/test-joshua.bash

Lines changed: 36 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,39 @@
33
# $1 - the path to the correctness archive file, ex. correctness-7.3.49-2.ow.tar.gz
44
# $2 - number of tests
55

6-
res=$(python3 -m joshua.joshua start --tarball $1 --max-runs $2 && python3 -m joshua.joshua tail --errors)
7-
8-
substr="TestUID"
9-
echo $res
10-
if [[ $res == *$substr* ]]; then
11-
echo >&2 "Test failed."
12-
exit 1
13-
fi
6+
python3 -m joshua.joshua start --tarball $1 --max-runs $2
7+
8+
python3 -m joshua.joshua tail | python3 -c "
9+
import sys, re
10+
sys.stdout = open(sys.stdout.fileno(), 'w', buffering=1)
11+
from datetime import datetime
12+
failed = False
13+
count = 1
14+
for line in sys.stdin:
15+
m = re.search(r'TestFile=\"([^\"]+)\".*?Ok=\"(\d+)\"', line)
16+
if m:
17+
timestamp = datetime.now().strftime('%Y-%m-%d %H:%M:%S')
18+
print(f'[#{count} {timestamp}] TestFile=\"{m.group(1)}\" Ok=\"{m.group(2)}\"')
19+
if m.group(2) == '0':
20+
failed = True
21+
else:
22+
sys.stdout.write(line)
23+
count += 1
24+
sys.exit(1 if failed else 0)
25+
" &
26+
27+
TAIL_PID=$!
28+
29+
while kill -0 "$TAIL_PID" 2>/dev/null; do
30+
sleep 30
31+
if ! podman ps -q 2>/dev/null | grep -q .; then
32+
echo "ERROR: all joshua-agent containers have stopped unexpectedly" >&2
33+
kill "$TAIL_PID" 2>/dev/null
34+
echo "Stopping joshua due to container failure..."
35+
python3 -m joshua.joshua stop
36+
exit 1
37+
fi
38+
done
39+
40+
wait "$TAIL_PID"
41+
exit $?

0 commit comments

Comments
 (0)