Skip to content

Commit

Permalink
Add waiting for housekeeping
Browse files Browse the repository at this point in the history
  • Loading branch information
janslifka committed Nov 29, 2024
1 parent d9b0e82 commit 0b45bf1
Show file tree
Hide file tree
Showing 6 changed files with 47 additions and 10 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ jobs:

- name: Prepare
run: |
npm ci
docker login -u "$PRIVATE_REGISTRY_USERNAME" -p "$PRIVATE_REGISTRY_PASSWORD" "$PRIVATE_REGISTRY_URL"
make clean
make init
Expand All @@ -60,7 +61,6 @@ jobs:
- name: Start DS Wizard
run: |
make start
make wait
- name: Run Cypress
uses: cypress-io/github-action@v6
Expand Down
10 changes: 2 additions & 8 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -30,27 +30,21 @@ run:
all:
@make clean && make init && make start && ($(CYPRESS) run || true) && make stop

.PHONY: wait
wait:
@while ! curl http://localhost:3000/ 2>/dev/null; \
do \
echo "Retrying ..."; \
sleep 2; \
done

.PHONY: open
open:
$(CYPRESS) open --browser chrome --e2e


.PHONY: clean
clean:
@rm -rf output && rm -f dsw/docker-compose.yml


.PHONY: ci
ci:
make clean
make init
make start
make wait
make run
make stop
File renamed without changes.
34 changes: 34 additions & 0 deletions dsw/scripts/wait-housekeeping.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#!/usr/bin/env node

const request = require('@cypress/request');

const wizardApiUrl = 'http://localhost:3000/wizard-api'
const wizardBootstrapConfig = `${wizardApiUrl}/configs/bootstrap?clientUrl=http%3A%2F%2Flocalhost%3A8080%2Fwizard`

function log(message) {
process.stdout.write(message)
}

function waitForWizard(cb) {
log('Waiting for wizard server... ')
request({
method: 'GET',
url: wizardBootstrapConfig,
json: true
}, (error, response, body) => {
if (error) {
log('not ready, retrying\n')
setTimeout(() => waitForWizard(cb), 3000)
} else if (body.type === 'HousekeepingInProgressClientConfig') {
log('housekeeping in progress, retrying\n')
setTimeout(() => waitForWizard(cb), 3000)
} else {
log('ready\n')
cb()
}
})
}

waitForWizard(() => {
process.exit(0)
})
7 changes: 7 additions & 0 deletions dsw/scripts/wait.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/bin/sh

while ! curl http://localhost:3000/ 2>/dev/null; \
do \
echo "Retrying ..."; \
sleep 2; \
done
4 changes: 3 additions & 1 deletion scripts/start.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,6 @@ docker pull --platform linux/amd64 $DOCWORKER_IMAGE
docker pull --platform linux/amd64 $CLIENT_IMAGE

docker compose up -d
./create-bucket.sh
./scripts/wait.sh
./scripts/create-bucket.sh
./scripts/wait-housekeeping.js

0 comments on commit 0b45bf1

Please sign in to comment.