Skip to content
New issue

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

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

Already on GitHub? # to your account

Server improvements #32

Merged
merged 22 commits into from
Feb 21, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 26 additions & 8 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
version: 2.1

jobs:
suse-qt5-notests:
client-suse-qt5-notests:
docker:
- image: kdeorg/ci-suse-qt515
steps:
Expand All @@ -11,11 +11,11 @@ jobs:
- checkout
- run:
name: Cmake
command: cmake client -DQT_MAJOR_VERSION=5
command: cmake . -DBUILD_SERVER=OFF -DQT_MAJOR_VERSION=5
- run:
name: Make
command: make all
suse-qt6-notests:
command: make cavoke_client
client-suse-qt6-notests:
docker:
- image: kdeorg/ci-suse-qt62
steps:
Expand All @@ -25,13 +25,31 @@ jobs:
command: chmod +x .circleci/suse-qt6-install-karchive.sh && .circleci/suse-qt6-install-karchive.sh
- run:
name: Cmake
command: cmake client -DQT_MAJOR_VERSION=6 # QT_MAJOR_VERSION=6 by default, so not necessary
command: cmake . -DBUILD_SERVER=OFF -DQT_MAJOR_VERSION=6 # QT_MAJOR_VERSION=6 by default, so not necessary
- run:
name: Make
command: make all
command: make cavoke_client
server-docker-healthcheck:
docker:
- image: ghcr.io/cavoke-project/cavoke_ci:drogon # TODO: use circleci orbs
auth:
username: $GHCR_USERNAME
password: $GHCR_PASSWORD
steps:
- checkout
- run:
name: Cmake
command: cmake . -DBUILD_CLIENT=OFF
- run:
name: Make
command: make cavoke_server
- run:
name: Simple healthcheck
command: chmod +x .circleci/server-test-health.py && .circleci/server-test-health.py ./server/cavoke_server

workflows:
client-workflow:
jobs:
- suse-qt5-notests
- suse-qt6-notests
- client-suse-qt5-notests
- client-suse-qt6-notests
- server-docker-healthcheck
43 changes: 43 additions & 0 deletions .circleci/server-test-health.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
#!/usr/bin/env python3
import atexit
import time

import requests
import subprocess
import sys


def check_eq(expected, actual):
if expected != actual:
print(f'Check failed: expected {repr(expected)}, got {repr(actual)}')
sys.exit(1)


def main():
_, *server_cmd = sys.argv
assert server_cmd, 'Expected usage: ./server-test-health.py <command-to-run>'

port = 8080
print(f'Booting server... at {server_cmd}', flush=True)

server = subprocess.Popen(args=[*server_cmd, '-p', str(port)])
def kill_server():
try:
server.wait(timeout=0.1)
except subprocess.TimeoutExpired:
print('Server terminating...', flush=True)
server.kill()
atexit.register(kill_server)
time.sleep(2) # FIXME
print('Checks starting...', flush=True)

with requests.get(f'http://localhost:{port}/health') as r:
check_eq(200, r.status_code)
check_eq("OK", r.text)
print("Health ok.")

print('All ok.')


if __name__ == '__main__':
main()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

хмммммм, выглядит подозрительно знакомо, кажется, я это уже видел в лабе, хмммммм

Loading