Loading src/qkd_app/.gitlab-ci.yml +44 −0 Original line number Diff line number Diff line Loading @@ -58,6 +58,50 @@ unit_test app: - docker logs $IMAGE_NAME - docker exec -i $IMAGE_NAME bash -c "coverage run -m pytest --log-level=INFO --verbose $IMAGE_NAME/tests/test_unitary.py --junitxml=/opt/results/${IMAGE_NAME}_report.xml" - docker exec -i $IMAGE_NAME bash -c "coverage report --include='${IMAGE_NAME}/*' --show-missing" # Mock QKD Nodes Deployment - | echo "Starting stage: deploy_mock_nodes" - pip install flask # Install Flask to ensure it is available - | for port in 11111 22222 33333; do if lsof -i:$port >/dev/null 2>&1; then echo "Freeing up port $port..." fuser -k $port/tcp fi done MOCK_NODES_DIR="$PWD/src/tests/tools/mock_qkd_nodes" if [ -d "$MOCK_NODES_DIR" ]; then cd "$MOCK_NODES_DIR" || exit ./start.sh & MOCK_NODES_PID=$! else echo "Error: Mock QKD nodes directory '$MOCK_NODES_DIR' not found." exit 1 fi echo "Waiting for mock nodes to be up..." RETRY_COUNT=0 MAX_RETRIES=15 while [ $RETRY_COUNT -lt $MAX_RETRIES ]; do if curl -s http://127.0.0.1:11111 > /dev/null && \ curl -s http://127.0.0.1:22222 > /dev/null && \ curl -s http://127.0.0.1:33333 > /dev/null; then echo "Mock nodes are up!" break else echo "Mock nodes not ready, retrying in 5 seconds..." RETRY_COUNT=$((RETRY_COUNT + 1)) sleep 5 fi done if [ $RETRY_COUNT -ge $MAX_RETRIES ]; then echo "Error: Mock nodes failed to start after multiple attempts." exit 1 fi # Run additional QKD unit tests - docker exec -i $IMAGE_NAME bash -c "pytest --log-level=INFO --verbose $IMAGE_NAME/tests/test_create_apps.py" - docker exec -i $IMAGE_NAME bash -c "pytest --log-level=INFO --verbose $IMAGE_NAME/tests/test_Set_new_configuration.py" coverage: '/TOTAL\s+\d+\s+\d+\s+(\d+%)/' after_script: - docker rm -f $IMAGE_NAME Loading src/device/tests/qkd/unit/test_create_apps.py→src/qkd_app/tests/test_create_apps.py +1 −1 Original line number Diff line number Diff line Loading @@ -14,7 +14,7 @@ import requests QKD_ADDRESS = '10.0.2.10' QKD_ADDRESS = '127.0.0.1' QKD_URL = 'http://{:s}/qkd_app/create_qkd_app'.format(QKD_ADDRESS) QKD_REQUEST_1 = { Loading src/device/tests/qkd/unit/test_set_new_configuration.py→src/qkd_app/tests/test_set_new_configuration.py +1 −1 Original line number Diff line number Diff line Loading @@ -53,7 +53,7 @@ def create_qkd_app(driver, qkdn_id, backing_qkdl_id, client_app_id=None): print(f"Sending payload to {driver.address}: {app_payload}") # Send POST request to create the application response = requests.post(f'http://{driver.address}/app/create_qkd_app', json=app_payload) response = requests.post(f'http://{driver.address}/qkd_app/create_qkd_app', json=app_payload) # Check if the request was successful (HTTP 2xx) response.raise_for_status() Loading src/tests/tools/mock_qkd_nodes/wsgi.py +3 −0 Original line number Diff line number Diff line Loading @@ -183,6 +183,9 @@ def get_side_effect(url): module = header_splitted[0] assert(module == 'etsi-qkd-sdn-node') if ip_port.startswith('127.0.0.1'): ip_port = ip_port.replace('127.0.0.1', current_ip) tree = {'qkd_node': nodes[ip_port]['node'].copy()} if len(header_splitted) == 1 or not header_splitted[1]: Loading Loading
src/qkd_app/.gitlab-ci.yml +44 −0 Original line number Diff line number Diff line Loading @@ -58,6 +58,50 @@ unit_test app: - docker logs $IMAGE_NAME - docker exec -i $IMAGE_NAME bash -c "coverage run -m pytest --log-level=INFO --verbose $IMAGE_NAME/tests/test_unitary.py --junitxml=/opt/results/${IMAGE_NAME}_report.xml" - docker exec -i $IMAGE_NAME bash -c "coverage report --include='${IMAGE_NAME}/*' --show-missing" # Mock QKD Nodes Deployment - | echo "Starting stage: deploy_mock_nodes" - pip install flask # Install Flask to ensure it is available - | for port in 11111 22222 33333; do if lsof -i:$port >/dev/null 2>&1; then echo "Freeing up port $port..." fuser -k $port/tcp fi done MOCK_NODES_DIR="$PWD/src/tests/tools/mock_qkd_nodes" if [ -d "$MOCK_NODES_DIR" ]; then cd "$MOCK_NODES_DIR" || exit ./start.sh & MOCK_NODES_PID=$! else echo "Error: Mock QKD nodes directory '$MOCK_NODES_DIR' not found." exit 1 fi echo "Waiting for mock nodes to be up..." RETRY_COUNT=0 MAX_RETRIES=15 while [ $RETRY_COUNT -lt $MAX_RETRIES ]; do if curl -s http://127.0.0.1:11111 > /dev/null && \ curl -s http://127.0.0.1:22222 > /dev/null && \ curl -s http://127.0.0.1:33333 > /dev/null; then echo "Mock nodes are up!" break else echo "Mock nodes not ready, retrying in 5 seconds..." RETRY_COUNT=$((RETRY_COUNT + 1)) sleep 5 fi done if [ $RETRY_COUNT -ge $MAX_RETRIES ]; then echo "Error: Mock nodes failed to start after multiple attempts." exit 1 fi # Run additional QKD unit tests - docker exec -i $IMAGE_NAME bash -c "pytest --log-level=INFO --verbose $IMAGE_NAME/tests/test_create_apps.py" - docker exec -i $IMAGE_NAME bash -c "pytest --log-level=INFO --verbose $IMAGE_NAME/tests/test_Set_new_configuration.py" coverage: '/TOTAL\s+\d+\s+\d+\s+(\d+%)/' after_script: - docker rm -f $IMAGE_NAME Loading
src/device/tests/qkd/unit/test_create_apps.py→src/qkd_app/tests/test_create_apps.py +1 −1 Original line number Diff line number Diff line Loading @@ -14,7 +14,7 @@ import requests QKD_ADDRESS = '10.0.2.10' QKD_ADDRESS = '127.0.0.1' QKD_URL = 'http://{:s}/qkd_app/create_qkd_app'.format(QKD_ADDRESS) QKD_REQUEST_1 = { Loading
src/device/tests/qkd/unit/test_set_new_configuration.py→src/qkd_app/tests/test_set_new_configuration.py +1 −1 Original line number Diff line number Diff line Loading @@ -53,7 +53,7 @@ def create_qkd_app(driver, qkdn_id, backing_qkdl_id, client_app_id=None): print(f"Sending payload to {driver.address}: {app_payload}") # Send POST request to create the application response = requests.post(f'http://{driver.address}/app/create_qkd_app', json=app_payload) response = requests.post(f'http://{driver.address}/qkd_app/create_qkd_app', json=app_payload) # Check if the request was successful (HTTP 2xx) response.raise_for_status() Loading
src/tests/tools/mock_qkd_nodes/wsgi.py +3 −0 Original line number Diff line number Diff line Loading @@ -183,6 +183,9 @@ def get_side_effect(url): module = header_splitted[0] assert(module == 'etsi-qkd-sdn-node') if ip_port.startswith('127.0.0.1'): ip_port = ip_port.replace('127.0.0.1', current_ip) tree = {'qkd_node': nodes[ip_port]['node'].copy()} if len(header_splitted) == 1 or not header_splitted[1]: Loading