Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Change testing #112

Closed
wants to merge 11 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
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
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: acapy-integration-tests
name: acapy-bdd-integration-tests

on:
schedule:
Expand All @@ -20,7 +20,7 @@ defaults:
jobs:
test:
runs-on: ubuntu-latest
if: (github.event_name == 'pull_request' && github.event.pull_request.draft == false && github.repository == 'hyperledger/aries-cloudagent-python') || (github.event_name != 'pull_request')
if: (github.event_name == 'pull_request' && github.event.pull_request.draft == false && github.repository == 'jamshale/aries-cloudagent-python') || (github.event_name != 'pull_request')
outputs:
is_release: ${{ steps.check_if_release.outputs.is_release }}
steps:
Expand Down
47 changes: 47 additions & 0 deletions .github/workflows/bdd-interop-tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
name: acapy-bdd-interop-tests

on:
pull_request:
branches:
- main
types: [opened, synchronize, reopened, ready_for_review]

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

defaults:
run:
shell: bash

jobs:
test:
runs-on: ubuntu-latest
if: (github.event_name == 'pull_request' && github.event.pull_request.draft == false && github.repository == 'jamshale/aries-cloudagent-python') || (github.event_name != 'pull_request')
outputs:
is_release: ${{ steps.check_if_release.outputs.is_release }}
steps:
- name: checkout-acapy
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Request GitHub API for PR data
uses: octokit/[email protected]
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
id: get_pr_data
with:
route: GET /repos/${{ github.event.repository.full_name }}/pulls/${{ github.event.number }}
- name: Run BDD Interop Tests
run: |
# Get AATH
git clone https://github.com/hyperledger/aries-agent-test-harness.git
echo ${{ fromJson(steps.get_pr_data.outputs.data).head.repo.html_url }}
echo ${{ fromJson(steps.get_pr_data.outputs.data).head.ref }}
ls -a
sed -i 's|@git+https://github.com/hyperledger/aries-cloudagent-python@main|@git+${{ fromJson(steps.get_pr_data.outputs.data).head.repo.html_url }}@${{ fromJson(steps.get_pr_data.outputs.data).head.ref }}|g' ./aries-agent-test-harness/aries-backchannels/acapy/requirements-main.txt
cat aries-agent-test-harness/aries-backchannels/acapy/requirements-main.txt
cd aries-agent-test-harness
./manage build -a acapy-main
NO_TTY=1 LEDGER_URL_CONFIG=http://test.bcovrin.vonx.io TAILS_SERVER_URL_CONFIG=https://tails.vonx.io ./manage run -d acapy-main -t @AcceptanceTest -t ~@wip -t ~@T004-RFC0211 -t ~@DidMethod_orb -t ~@Transport_NoHttpOutbound

39 changes: 39 additions & 0 deletions .github/workflows/integration-tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
name: acapy-integration-tests

on:
pull_request:
branches:
- main
types: [opened, synchronize, reopened, ready_for_review]

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

defaults:
run:
shell: bash

jobs:
test:
runs-on: ubuntu-latest
if: (github.event_name == 'pull_request' && github.event.pull_request.draft == false && github.repository == 'jamshale/aries-cloudagent-python') || (github.event_name != 'pull_request')
steps:
- name: checkout-acapy
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Install poetry
run: pipx install poetry
id: setup-poetry
- uses: actions/setup-python@v5
with:
python-version: "3.12"
cache: "poetry"
- name: Run Integration tests
run: |
# Build the docker image for testing
docker build -t acapy-test -f docker/Dockerfile.run .
cd integration-tests
poetry install --no-root
poetry run pytest -m examples
14 changes: 7 additions & 7 deletions aries_cloudagent/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,16 @@ def init_debug(args):

# --debug to use microsoft's visual studio remote debugger
if ENABLE_PTVSD or "--debug" in args:
DAP_HOST = os.getenv("PTVSD_HOST", None) or os.getenv("DAP_HOST", "localhost")
DAP_PORT = os.getenv("PTVSD_PORT", None) or os.getenv("DAP_PORT", 5678)
try:
import ptvsd
import debugpy

ptvsd.enable_attach()
print("ptvsd is running")
print("=== Waiting for debugger to attach ===")
# To pause execution until the debugger is attached:
ptvsd.wait_for_attach()
debugpy.listen((DAP_HOST, DAP_PORT))
print(f"=== Waiting for debugger to attach to {DAP_HOST}:{DAP_PORT} ===")
debugpy.wait_for_client()
except ImportError:
print("ptvsd library was not found")
print("debugpy library was not found")

if ENABLE_PYDEVD_PYCHARM or "--debug-pycharm" in args:
try:
Expand Down
32 changes: 24 additions & 8 deletions aries_cloudagent/config/argparse.py
Original file line number Diff line number Diff line change
Expand Up @@ -214,11 +214,11 @@ def get_settings(self, args: Namespace):
return settings


@group(CAT_START)
class DebugGroup(ArgumentGroup):
"""Debug settings."""
@group(CAT_PROVISION, CAT_START, CAT_UPGRADE)
class DebuggerGroup(ArgumentGroup):
"""Debugger settings."""

GROUP_NAME = "Debug"
GROUP_NAME = "Debugger"

def add_arguments(self, parser: ArgumentParser):
"""Add debug command line arguments to the parser."""
Expand All @@ -228,10 +228,28 @@ def add_arguments(self, parser: ArgumentParser):
env_var="ACAPY_DEBUG",
help=(
"Enables a remote debugging service that can be accessed "
"using ptvsd for Visual Studio Code. The framework will wait "
"for the debugger to connect at start-up. Default: false."
"using the Debug Adapter Protocol (supported by Visual Studio Code). "
"The framework will wait for the debugger to connect at start-up. "
"Default: false."
),
)

def get_settings(self, args: Namespace) -> dict:
"""Extract debug settings."""
settings = {}
if args.debug:
settings["debug.enabled"] = True
return settings


@group(CAT_START)
class DebugGroup(ArgumentGroup):
"""Debug settings."""

GROUP_NAME = "Debug"

def add_arguments(self, parser: ArgumentParser):
"""Add debug command line arguments to the parser."""
parser.add_argument(
"--debug-seed",
dest="debug_seed",
Expand Down Expand Up @@ -415,8 +433,6 @@ def add_arguments(self, parser: ArgumentParser):
def get_settings(self, args: Namespace) -> dict:
"""Extract debug settings."""
settings = {}
if args.debug:
settings["debug.enabled"] = True
if args.debug_connections:
settings["debug.connections"] = True
if args.debug_credentials:
Expand Down
2 changes: 1 addition & 1 deletion aries_cloudagent/config/logging.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ def fileConfig(
except configparser.ParsingError as e:
raise RuntimeError(f"{fname} is invalid: {e}")

if new_file_path:
if new_file_path and cp.has_section("handler_timed_file_handler"):
cp.set(
"handler_timed_file_handler",
"args",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ async def emit_event(self, session: ProfileSession, payload: Any = None):
# serialize payload before checking for webhook contents
if not payload:
payload = self.serialize()
else:
if not session.profile.settings.get("debug.webhooks"):
payload = V20CredExRecordWebhook(**payload)
payload = payload.__dict__

Expand Down
6 changes: 3 additions & 3 deletions aries_cloudagent/tests/test_main.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,9 @@ def test_ptvsd(self):
test_module.init_debug(["aca-py", "--debug"])

mock_import.assert_called_once()
self.assertEqual(mock_import.call_args[0][0], "ptvsd")
mock_import.return_value.enable_attach.assert_called_once()
mock_import.return_value.wait_for_attach.assert_called_once()
self.assertEqual(mock_import.call_args[0][0], "debugpy")
mock_import.return_value.listen.assert_called_once()
mock_import.return_value.wait_for_client.assert_called_once()

def test_ptvsd_import_x(self):
with mock.patch("builtins.__import__") as mock_import:
Expand Down
51 changes: 27 additions & 24 deletions aries_cloudagent/transport/outbound/manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -470,40 +470,43 @@ def deliver_queued_message(self, queued: QueuedOutboundMessage) -> asyncio.Task:
)
return queued.task

def _finished_deliver_error_handler(self, queued: QueuedOutboundMessage, retry: bool):
if retry:
LOGGER.debug(
(
">>> Error when posting to: %s; "
"Error: %s; "
"Payload: %s; Re-queue failed message ..."
),
queued.endpoint,
queued.error,
queued.payload,
)
else:
err_msg = ">>> Outbound message failed to deliver, NOT Re-queued."
if "/webhook/topic" in queued.endpoint:
LOGGER.warning(
err_msg,
exc_info=queued.error,
)
else:
LOGGER.exception(
err_msg,
exc_info=queued.error,
)

def finished_deliver(self, queued: QueuedOutboundMessage, completed: CompletedTask):
"""Handle completion of queued message delivery."""
if completed.exc_info:
queued.error = completed.exc_info

if queued.retries:
if LOGGER.isEnabledFor(logging.DEBUG):
LOGGER.error(
(
">>> Error when posting to: %s; "
"Error: %s; "
"Payload: %s; Re-queue failed message ..."
),
queued.endpoint,
queued.error,
queued.payload,
)
else:
LOGGER.error(
(
">>> Error when posting to: %s; "
"Error: %s; Re-queue failed message ..."
),
queued.endpoint,
queued.error,
)
self._finished_deliver_error_handler(queued, retry=True)
queued.retries -= 1
queued.state = QueuedOutboundMessage.STATE_RETRY
queued.retry_at = time.perf_counter() + 10
else:
LOGGER.exception(
">>> Outbound message failed to deliver, NOT Re-queued.",
exc_info=queued.error,
)
self._finished_deliver_error_handler(queued, retry=False)
queued.state = QueuedOutboundMessage.STATE_DONE
else:
queued.error = None
Expand Down
25 changes: 15 additions & 10 deletions conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,19 +146,24 @@ def stub_ursa_bbs_signatures() -> Stub:

def pytest_sessionstart(session):
global STUBS, POSTGRES_URL, ENABLE_PTVSD
ENABLE_PTVSD = os.getenv("ENABLE_PTVSD", False)
# --debug-vs to use microsoft's visual studio remote debugger
if ENABLE_PTVSD or "--debug" in sys.argv:
args = sys.argv

# copied from __main__.py:init_debug
ENABLE_PTVSD = os.getenv("ENABLE_PTVSD", "").lower()
ENABLE_PTVSD = ENABLE_PTVSD and ENABLE_PTVSD not in ("false", "0")

# --debug to use microsoft's visual studio remote debugger
if ENABLE_PTVSD or "--debug" in args:
DAP_HOST = os.getenv("PTVSD_HOST", None) or os.getenv("DAP_HOST", "localhost")
DAP_PORT = os.getenv("PTVSD_PORT", None) or os.getenv("DAP_PORT", 5678)
try:
import ptvsd
import debugpy

ptvsd.enable_attach(address=("0.0.0.0", 5678))
print("ptvsd is running")
print("=== Waiting for debugger to attach ===")
# To pause execution until the debugger is attached:
ptvsd.wait_for_attach()
debugpy.listen((DAP_HOST, DAP_PORT))
print(f"=== Waiting for debugger to attach to {DAP_HOST}:{DAP_PORT} ===")
debugpy.wait_for_client()
except ImportError:
print("ptvsd library was not found")
print("debugpy library was not found")

POSTGRES_URL = os.getenv("POSTGRES_URL")

Expand Down
6 changes: 3 additions & 3 deletions demo/features/0160-connection.feature
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ Feature: RFC 0160 Aries agent connection functions
Then "Acme" has an active connection
And "Bob" has an active connection

@PR @Release @UnqualifiedDids
@UnqualifiedDids
Examples:
| Acme_capabilities | Acme_extra | Bob_capabilities | Bob_extra |
| --public-did --did-exchange --emit-did-peer-2 | | --did-exchange --emit-did-peer-2 | |
Expand Down Expand Up @@ -40,7 +40,7 @@ Feature: RFC 0160 Aries agent connection functions
| --did-exchange --emit-did-peer-4 | | --emit-did-peer-4 | |
| --did-exchange --reuse-connections --emit-did-peer-4 | | --reuse-connections --emit-did-peer-4 | |

@PR @Release @MultiUseConnectionReuse
@MultiUseConnectionReuse
Examples:
| Acme_capabilities | Acme_extra | Bob_capabilities | Bob_extra |
| --did-exchange --multi-use-invitations --emit-did-peer-2 | | --emit-did-peer-2 | |
Expand All @@ -56,7 +56,7 @@ Feature: RFC 0160 Aries agent connection functions
| --public-did --did-exchange --multi-use-invitations --emit-did-peer-4 | | --did-exchange --emit-did-peer-2 | |
| --public-did --did-exchange --multi-use-invitations --reuse-connections --emit-did-peer-2 | | --did-exchange --reuse-connections --emit-did-peer-4 | |

@PR @Release @WalletType_Askar_AnonCreds
@WalletType_Askar_AnonCreds
Examples:
| Acme_capabilities | Acme_extra | Bob_capabilities | Bob_extra |
| --public-did --did-exchange --wallet-type askar-anoncreds --emit-did-peer-2 | | --did-exchange --wallet-type askar-anoncreds --emit-did-peer-2 | |
Expand Down
Loading
Loading