Skip to content

Commit

Permalink
Merge pull request #88 from kentbull/bump-version-upgrade-deps
Browse files Browse the repository at this point in the history
chore,test: bump version to 0.2.2; upgrade deps; cleanup code
  • Loading branch information
kentbull authored Jan 11, 2025
2 parents 2fd6a58 + e1c8767 commit 5b53bdc
Show file tree
Hide file tree
Showing 9 changed files with 83 additions and 28 deletions.
1 change: 1 addition & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ jobs:
run: |
python -m pip install --upgrade pip
pip install pytest
pip install requests
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
- name: Run tests
run: |
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
.PHONY: push-all

VERSION=0.2.2
IMAGE_NAME=kentbull/vlei
IMAGE_NAME=gleif/vlei

push-all:
@docker push $(IMAGE_NAME) --all-tags
Expand Down
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
# vLEI
# vLEI Server

Verifiable Legal Entity Identifier Schema Generator and Server

| main | dev |
|--------------------------------------------------------------------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------|
Expand Down
39 changes: 18 additions & 21 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,23 @@
from glob import glob
from os.path import basename
from os.path import splitext
from pathlib import Path

from setuptools import find_packages, setup

this_directory = Path(__file__).parent
if (this_directory / "README.md").exists(): # If building inside a container, like in the `container/Dockerfile`, this file won't exist and fails the build
long_description = (this_directory / "README.md").read_text()
else:
long_description = "Verifiable Legal Entity Identifier Schema Generator and Server"

setup(
name='vlei',
version='0.2.1', # also change in src/vlei/__init__.py
version='0.2.2', # also change in src/vlei/__init__.py
license='Apache Software License 2.0',
description='Verifiable Legal Entity Identifier',
long_description="Verifiable Legal Entity Identifier Schema Generator and Server",
long_description=long_description,
long_description_content_type='text/markdown',
author='Samuel M. Smith',
author_email='[email protected]',
url='https://github.com/WebOfTrust/vLEI',
Expand Down Expand Up @@ -65,32 +74,20 @@
],
python_requires='>=3.12.2',
install_requires=[
'lmdb>=1.4.1',
'pysodium>=0.7.17',
'blake3>=0.4.1',
'msgpack>=1.0.8',
'cbor2>=5.6.2',
'multidict>=6.0.5',
'ordered-set>=4.1.0',
'hio==0.6.14',
'multicommand>=1.0.0',
'jsonschema>=4.21.1',
'falcon>=3.1.3',
'daemonocle>=1.2.3',
'hjson>=3.1.0',
'PyYaml>=6.0.2',
'apispec>=6.8.0',
'mnemonic>=0.21',
'keri>=1.2.1',
'keri>=1.2.2',
'falcon>=4.0.2',
'multicommand>=1.0.0'
],
extras_require={
},
tests_require=[
'coverage>=7.4.4',
'pytest>=8.1.1',
'requests==2.32.3'
'coverage>=7.6.10',
'pytest>=8.3.4',
'requests==2.32.3'
],
setup_requires=[
'setuptools==75.8.0'
],
entry_points={
'console_scripts': [
Expand Down
2 changes: 1 addition & 1 deletion src/vlei/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# -*- encoding: utf-8 -*-

__version__ = '0.2.1' # also change in setup.py
__version__ = '0.2.2' # also change in setup.py

10 changes: 10 additions & 0 deletions src/vlei/app/serving.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import falcon
from hio.core import http
from keri import help
from keri.help import nowIso8601

from vlei.app import caching

Expand Down Expand Up @@ -78,6 +79,12 @@ def on_get(self, req, rep, alias):
url = p.open().read()
raise falcon.HTTPMovedPermanently(location=url)

class HealthEnd:
"""Health resource for determining that a container is live"""

def on_get(self, req, resp):
resp.status = falcon.HTTP_OK
resp.media = {"message": f"Health is okay. Time is {nowIso8601()}"}

def loadEnds(app, schemaDir, credDir, oobiDir):
sink = http.serving.StaticSink(staticDirPath="./static")
Expand All @@ -88,3 +95,6 @@ def loadEnds(app, schemaDir, credDir, oobiDir):

wellknownEnd = WellKnownEnd(oobiDir)
app.add_route("/.well-known/keri/oobi/{alias}", wellknownEnd)

healthEnd = HealthEnd()
app.add_route("/health", healthEnd)
1 change: 0 additions & 1 deletion src/vlei/app/shutdown.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ def enter(self):
def recur(self, tock=0.0):
"""Generator coroutine checking once per tock for shutdown flag"""
# Checks once per tock if the shutdown flag has been set and if so initiates the shutdown process
logger.info("Recurring graceful shutdown doer")
while not self.shutdown_received:
yield tock # will iterate forever in here until shutdown flag set

Expand Down
6 changes: 3 additions & 3 deletions src/vlei/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,11 @@ class VLEIConfig:
# HTTP port to listen on
http: int = 7723
# ACDC schema directory
schemaDir: str = None
schemaDir: str = "./schema/acdc/"
# ACDC material directory
credDir: str = None
credDir: str = "./samples/acdc/"
# Well known OOBI directory
oobiDir: str = None
oobiDir: str = "./samples/oobis/"
# TLS key material
keypath: str = None
certpath: str = None
Expand Down
46 changes: 46 additions & 0 deletions tests/test_server.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
import multiprocessing
import os
import signal
import time

import requests

from vlei import server


def wait_for_server(port, timeout=10):
"""Poll server until it responds or until timeout"""
url=f"http://127.0.0.1:{port}/health"
start_time=time.time()
while time.time() - start_time < timeout:
try:
response = requests.get(url)
if response.status_code == 200:
return True # Server is up
except requests.ConnectionError:
pass # Server not ready yet
time.sleep(0.25) # Retry every 1/4 second
return False # Timeout

def test_shutdown_signals():
config = server.VLEIConfig(http=9999)

# Test SIGTERM
vlei_process = multiprocessing.Process(target=server.launch, args=[config])
vlei_process.start()
assert wait_for_server(config.http), "vLEI-server did not start as expected."

os.kill(vlei_process.pid, signal.SIGTERM) # Send SigTerm to the process, signal 15
vlei_process.join(timeout=10)
assert not vlei_process.is_alive(), "SIGTERM: vLEI-server process did not shut down as expected."
assert vlei_process.exitcode == 0, f"SIGTERM: vLEI-server exited with non-zero exit code {vlei_process.exitcode}"

# Test SIGINT
vlei_process = multiprocessing.Process(target=server.launch, args=[config])
vlei_process.start()
assert wait_for_server(config.http), "Agency did not start as expected."

os.kill(vlei_process.pid, signal.SIGINT) # Sends SigInt to the process, signal 2
vlei_process.join(timeout=10)
assert not vlei_process.is_alive(), "SIGINT: vLEI-server process did not shut down as expected."
assert vlei_process.exitcode == 0, f"SIGINT: vLEI-server exited with non-zero exit code {vlei_process.exitcode}"

0 comments on commit 5b53bdc

Please sign in to comment.