Skip to content

Commit

Permalink
[Sage-1407] Add support for beehive ID in /register API. (#25)
Browse files Browse the repository at this point in the history
* added -b flag to specify beehive

* added support for beehive_id in registration api

* restrict exposed bk-api port to localhost. upped mysql version from 8.0.20 to 8.0.29 for arm64 support.

* added Makefile to run tests and setup / teardown services

* using shorter ./ instead of PWD for relative paths

* added note about retry

* added TODO about contextmanager for db

* added test cases for registering with specific beehive. replaced prints with logging and turned down default level to INFO.

* updated tests for specific beehive registration. using POST instead of GET for endpoint.

* added note about locks

* removed unused block

* removed echo lines as this output is sent directly to registration service.

* make svc-up inits test keys. make svc-down cleans up volumes.

* using docker-compose to exec command

* added tests for valid node ids

* minor clean up

* added note

* moved app creation into create_app function to provide us with a cleaner way to later create instances for testing

* removed unused node_id

* removed unused config.update

* using test discovery and -v flag to show test names

* added comment on random node id. use random beehive id for assign beehive test.

* replaced raw http status codes with HTTPStatus constants

* added -s flag to curl. added --no-TTY to docker-compose exec to allow running in CI.

* addressed comments in pr

* using Makefile for managing services and tests in CI. restore TTY for pytest step.

* falling back to old docker command, but using docker-compose ps to get container id

* falling back to old docker command for ssh check, but using docker-compose ps to get container id

* updated log message
  • Loading branch information
seanshahkarami authored Jul 18, 2022
1 parent f7555e7 commit 1778f56
Show file tree
Hide file tree
Showing 12 changed files with 285 additions and 336 deletions.
2 changes: 1 addition & 1 deletion .env
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ KEY_GEN_ARGS=""
# e.g. KEY_GEN_ARGS="-b 4096" for rsa
USE_CONFIG_VOLUME=1
#DEFAULT_BEEHIVE=my-beehive
FAKE_DEPLOYMENT=1
FAKE_DEPLOYMENT=1
20 changes: 6 additions & 14 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,19 +12,11 @@ jobs:
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v2
- name: Create keys
run: ./create-keys.sh init --nopassword
- name: Create reg cert
run: ./create-keys.sh cert untilforever forever
- name: Build docker images
run: docker-compose build
- name: Start docker-compose
run: docker-compose up -d
- name: Build and run services
run: make svc-up
- name: Wait for docker-compose services
run: while [ $(curl -s localhost:5000)_ != "SAGE Beekeeper API_" ] ; do echo waiting... ; sleep 2 ; done

- name: Unit tests
run: ./unit-tests.sh

- name: Clean-up
run: docker-compose down
- name: Run tests
run: make test
- name: Clean up services
run: make svc-down
15 changes: 15 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
all:

.PHONY: test
test:
./unit-tests.sh

.PHONY: svc-up
svc-up:
./create-keys.sh init --nopassword
./create-keys.sh cert untilforever forever
docker-compose up -d --build

.PHONY: svc-down
svc-down:
docker-compose down --volumes
3 changes: 1 addition & 2 deletions bk-api/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -27,5 +27,4 @@ COPY . /usr/src/app


#CMD ./bk_api.py
CMD gunicorn bk_api:app --timeout=120 --bind=0.0.0.0:5000

CMD gunicorn 'bk_api:create_app()' --timeout=120 --bind=0.0.0.0:5000
Loading

0 comments on commit 1778f56

Please sign in to comment.