Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

split e2e in 3 different gh jobs #181

Merged
merged 13 commits into from
Feb 22, 2022
2 changes: 1 addition & 1 deletion .github/workflows/bench.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,5 @@ jobs:
- name: Run Regression Test
run: |
yarn start lang --dim 100 &
sleep 15s && yarn start nlu --doc false --verbose 0 --ducklingEnabled false --languageURL http://localhost:3100 &
sleep 15s && yarn start nlu --doc false --log-level "critical" --ducklingEnabled false --languageURL http://localhost:3100 &
sleep 25s && yarn bench --skip="clinc150"
185 changes: 139 additions & 46 deletions .github/workflows/e2e.yml
Original file line number Diff line number Diff line change
@@ -1,15 +1,67 @@
name: E2E
on: [pull_request]
jobs:
run_e2e:
name: Run e2e tests using binary executable file
fs:
name: file system
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@master
- uses: actions/setup-node@v1
with:
node-version: '16.13.0'
- name: Fetch Node Packages
run: |
yarn --verbose
- name: Build
run: |
yarn build
- name: package
run: |
yarn package --linux
- name: Rename binary
id: rename_binary
run: |
bin_original_name=$(node -e "console.log(require('./scripts/utils/binary').getFileName())")
echo "Moving ./dist/$bin_original_name to ./nlu ..."
mv ./dist/$bin_original_name ./nlu
- name: Download language models
run: |
./nlu lang download --lang en --dim 25
- name: Start Language Server
run: |
./nlu lang --dim 25 &
echo "Lang Server started on pid $!"
- name: Sleep
uses: jakejarvis/wait-action@master
with:
time: '15s'
- name: Start NLU Server
run: |
./nlu \
--log-level "critical" \
--ducklingEnabled false \
--languageURL http://localhost:3100 \
--port 3200 &
nlu_pid=$!
echo "NLU Server started on pid $nlu_pid"
- name: Sleep
uses: jakejarvis/wait-action@master
with:
time: '15s'
- name: Run Tests
run: |
yarn e2e --nlu-endpoint http://localhost:3200

db:
name: database
runs-on: ubuntu-latest
services:
postgres:
# Docker Hub image
image: postgres
env:
POSTGRES_DB: botpress-nlu
POSTGRES_DB: botpress-nlu-1
POSTGRES_PASSWORD: postgres
POSTGRES_USER: postgres
POSTGRES_PORT: 5432
Expand Down Expand Up @@ -53,70 +105,111 @@ jobs:
uses: jakejarvis/wait-action@master
with:
time: '15s'
- name: Run Tests on File System
- name: Start NLU Server
run: |
test_and_cleanup() {
yarn e2e --nlu-endpoint http://localhost:3200
kill -9 $1
}

./nlu \
--verbose 0 \
--log-level "critical" \
--ducklingEnabled false \
--languageURL http://localhost:3100 \
--port 3200 >/dev/null &
--port 3201 \
--dbURL postgres://postgres:postgres@localhost:5432/botpress-nlu-1 & \
nlu_pid=$!
echo "NLU Server started on pid $nlu_pid"

sleep 10s && (test_and_cleanup $nlu_pid)

- name: Run Tests on Database
- name: Sleep
uses: jakejarvis/wait-action@master
with:
time: '15s'
- name: Run Tests
run: |
test_and_cleanup() {
yarn e2e --nlu-endpoint http://localhost:3200
kill -9 $1
}
yarn e2e --nlu-endpoint http://localhost:3201

./nlu \
--verbose 0 \
--ducklingEnabled false \
--languageURL http://localhost:3100 \
--port 3200 \
--dbURL postgres://postgres:postgres@localhost:5432/botpress-nlu >/dev/null & \
nlu_pid=$!
echo "NLU Server started on pid $nlu_pid"

sleep 10s && sleep 10s && (test_and_cleanup $nlu_pid)

- name: Run Tests on distributed Cluster
cluster:
name: cluster
runs-on: ubuntu-latest
services:
postgres:
# Docker Hub image
image: postgres
env:
POSTGRES_DB: botpress-nlu-2
POSTGRES_PASSWORD: postgres
POSTGRES_USER: postgres
POSTGRES_PORT: 5432
ports:
- 5432:5432
# Set health checks to wait until postgres has started
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
steps:
- name: Checkout code
uses: actions/checkout@master
- uses: actions/setup-node@v1
with:
node-version: '16.13.0'
- name: Fetch Node Packages
run: |
test_and_cleanup() {
yarn e2e --nlu-endpoint http://localhost:3201
kill -9 $1
kill -9 $2
}

# we start an instance of nlu-server on port 3201 that receive HTTP calls but is not allowed to train
# this way we make sure trainings are launched on the second instance, which listens on port 3202
yarn --verbose
- name: Build
run: |
yarn build
- name: package
run: |
yarn package --linux
- name: Rename binary
id: rename_binary
run: |
bin_original_name=$(node -e "console.log(require('./scripts/utils/binary').getFileName())")
echo "Moving ./dist/$bin_original_name to ./nlu ..."
mv ./dist/$bin_original_name ./nlu
- name: Download language models
run: |
./nlu lang download --lang en --dim 25
- name: Start Language Server
run: |
./nlu lang --dim 25 &
echo "Lang Server started on pid $!"
- name: Sleep
uses: jakejarvis/wait-action@master
with:
time: '15s'

- name: Start First NLU Server on port 3202
run: |
./nlu \
--verbose 0 \
--log-level "critical" \
--ducklingEnabled false \
--maxTraining 0 \
--maxLinting 0 \
--languageURL http://localhost:3100 \
--port 3201 \
--dbURL postgres://postgres:postgres@localhost:5432/botpress-nlu >/dev/null & \
--port 3202 \
--dbURL postgres://postgres:postgres@localhost:5432/botpress-nlu-2 & \
nlu_pid1=$!
echo "NLU Server started on pid $nlu_pid1"

- name: Sleep
uses: jakejarvis/wait-action@master
with:
time: '5s'

- name: Start Second NLU Server on port 3203
run: |
./nlu \
--verbose 0 \
--log-level "critical" \
--ducklingEnabled false \
--languageURL http://localhost:3100 \
--port 3202 \
--dbURL postgres://postgres:postgres@localhost:5432/botpress-nlu >/dev/null & \
--port 3203 \
--dbURL postgres://postgres:postgres@localhost:5432/botpress-nlu-2 & \
nlu_pid2=$!
echo "NLU Server started on pid $nlu_pid2"

sleep 10s && (test_and_cleanup $nlu_pid1 $nlu_pid2)
- name: Sleep
uses: jakejarvis/wait-action@master
with:
time: '15s'

- name: Run Tests
run: |
yarn e2e --nlu-endpoint http://localhost:3202
2 changes: 1 addition & 1 deletion packages/distributed/src/queues/pg-distributed-queue.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,6 @@ export class PGDistributedTaskQueue<TId, TInput, TData, TError>

private _cancelAndWaitForResponse = (taskId: TId, clusterId: string): Promise<void> =>
new Promise(async (resolve, reject) => {
await this._obs.emit('cancel_task', { taskId, clusterId })
this._obs.onceOrMore('cancel_task_done', async (response) => {
if (this._idToString(response.taskId) !== this._idToString(taskId)) {
return 'stay' // canceled task is not the one we're waiting for
Expand All @@ -96,6 +95,7 @@ export class PGDistributedTaskQueue<TId, TInput, TData, TError>
resolve()
return 'leave'
})
await this._obs.emit('cancel_task', { taskId, clusterId })
})

private _timeoutTaskCancelation = (ms: number): Promise<never> =>
Expand Down