From 312439de9dabe23d346e8081ffddb23a265a1327 Mon Sep 17 00:00:00 2001 From: Ian Costanzo Date: Mon, 22 Mar 2021 06:41:35 -0700 Subject: [PATCH 1/3] Add github action to run bdd tests Signed-off-by: Ian Costanzo --- .github/workflows/integrationtests.yml | 25 ++++++++++ actions/run-indy-tails-server/action.yml | 20 ++++++++ actions/run-integration-tests/action.yml | 21 ++++++++ actions/run-von-network/action.yml | 20 ++++++++ demo/features/0036-issue-credential.feature | 5 +- demo/features/0037-present-proof.feature | 55 ++++++++++++++++----- demo/features/0160-connection.feature | 2 +- demo/features/0586-sign-transaction.feature | 23 ++++++++- demo/run_bdd | 4 +- demo/runners/support/agent.py | 12 +++-- docker/Dockerfile.bdd | 3 +- 11 files changed, 165 insertions(+), 25 deletions(-) create mode 100644 .github/workflows/integrationtests.yml create mode 100644 actions/run-indy-tails-server/action.yml create mode 100644 actions/run-integration-tests/action.yml create mode 100644 actions/run-von-network/action.yml diff --git a/.github/workflows/integrationtests.yml b/.github/workflows/integrationtests.yml new file mode 100644 index 0000000000..84e3929a4f --- /dev/null +++ b/.github/workflows/integrationtests.yml @@ -0,0 +1,25 @@ +name: acapy-integration-tests +on: + workflow_dispatch: + #schedule: + # - cron: "0 0 * * *" +defaults: + run: + shell: bash +jobs: + test: + runs-on: ubuntu-latest + #if: (github.event_name == 'schedule' && github.repository == 'hyperledger/aries-cloudagent-python') || (github.event_name != 'schedule') + steps: + - name: checkout-acapy + uses: actions/checkout@v2 + with: + path: acapy + - name: run-von-network + uses: ./acapy/actions/run-von-network + - name: run-indy-tails-server + uses: ./acapy/actions/run-indy-tails-server + - name: run-integration-tests + uses: ./acapy/actions/run-integration-tests + # with: + # TEST_SCOPE: "-t @T001-RFC0037" diff --git a/actions/run-indy-tails-server/action.yml b/actions/run-indy-tails-server/action.yml new file mode 100644 index 0000000000..98b4be9eac --- /dev/null +++ b/actions/run-indy-tails-server/action.yml @@ -0,0 +1,20 @@ +name: "Run Tails Server" +description: "Build and Run Indy Tails Server" +author: "iancostanzo@gmail.com" +runs: + using: "composite" + steps: + - name: checkout-indy-tails-server + run: git clone https://github.com/bcgov/indy-tails-server.git + shell: bash + - name: build-indy-tails-server + run: ./manage build + shell: bash + working-directory: indy-tails-server/docker + - name: run-indy-tails-server + run: ./manage start + shell: bash + working-directory: indy-tails-server/docker +branding: + icon: "scissors" + color: "purple" diff --git a/actions/run-integration-tests/action.yml b/actions/run-integration-tests/action.yml new file mode 100644 index 0000000000..d03b49343e --- /dev/null +++ b/actions/run-integration-tests/action.yml @@ -0,0 +1,21 @@ +name: "Run Aca-Py Integration Tests" +description: "Run integration tests for Aca-Py" +author: "iancostanzo@gmail.com" +inputs: + TEST_SCOPE: + description: "Set of flags that defines the test scope" + required: false + default: "-t @GHA" +runs: + using: "composite" + steps: + - name: run-integration-tests-acapy + # run: LEDGER_URL=http://test.bcovrin.vonx.io PUBLIC_TAILS_URL=https://tails.vonx.io ./run_bdd ${{ inputs.TEST_SCOPE }} + run: ./run_bdd ${{ inputs.TEST_SCOPE }} + shell: bash + env: + NO_TTY: "1" + working-directory: acapy/demo +branding: + icon: "mic" + color: "purple" diff --git a/actions/run-von-network/action.yml b/actions/run-von-network/action.yml new file mode 100644 index 0000000000..dc945dcec4 --- /dev/null +++ b/actions/run-von-network/action.yml @@ -0,0 +1,20 @@ +name: "Run von-network" +description: "Build and run Indy network using von-network" +author: "iancostanzo@gmail.com" +runs: + using: "composite" + steps: + - name: checkout-von-network + run: git clone https://github.com/bcgov/von-network.git + shell: bash + - name: build-von-network + run: ./manage build + shell: bash + working-directory: von-network + - name: run-von-network + run: ./manage start + shell: bash + working-directory: von-network +branding: + icon: "cloud-lightning" + color: "blue" diff --git a/demo/features/0036-issue-credential.feature b/demo/features/0036-issue-credential.feature index d26f71d322..c22a9e0ded 100644 --- a/demo/features/0036-issue-credential.feature +++ b/demo/features/0036-issue-credential.feature @@ -1,6 +1,6 @@ Feature: RFC 0036 Aries agent issue credential - @T003-RFC0036 @AcceptanceTest @P1 @critical @Indy @RFC0036 + @T003-RFC0036 @GHA Scenario Outline: Issue a credential with the Issuer beginning with an offer Given we have "2" agents | name | role | capabilities | @@ -17,10 +17,9 @@ Feature: RFC 0036 Aries agent issue credential | --public-did --did-exchange | --did-exchange | driverslicense | Data_DL_NormalizedValues | | --public-did --mediation | --mediation | driverslicense | Data_DL_NormalizedValues | | --public-did --multitenant | --multitenant | driverslicense | Data_DL_NormalizedValues | - | --public-did --mediation --multitenant | --mediation --multitenant | driverslicense | Data_DL_NormalizedValues | - @T004-RFC0036 @AcceptanceTest @P1 @critical @Indy @RFC0036 + @T004-RFC0036 @GHA Scenario Outline: Issue a credential with revocation, with the Issuer beginning with an offer, and then revoking the credential Given we have "2" agents | name | role | capabilities | diff --git a/demo/features/0037-present-proof.feature b/demo/features/0037-present-proof.feature index 2787663ed0..32825a1ed5 100644 --- a/demo/features/0037-present-proof.feature +++ b/demo/features/0037-present-proof.feature @@ -1,8 +1,26 @@ Feature: RFC 0037 Aries agent present proof - @T001-AIP10-RFC0037 @P1 @critical @AcceptanceTest @Indy @RFC0037 + @T001-RFC0037 @GHA Scenario Outline: Present Proof where the prover does not propose a presentation of the proof and is acknowledged - Given "3" agents + Given we have "2" agents + | name | role | capabilities | + | Faber | verifier | | + | Bob | prover | | + And "" and "Bob" have an existing connection + And "Bob" has an issued credential from "" + And "Faber" and "Bob" have an existing connection + When "Faber" sends a request for proof presentation to "Bob" + Then "Faber" has the proof verified + + Examples: + | issuer | Acme_capabilities | Bob_capabilities | Schema_name | Credential_data | Proof_request | + | Faber | --public-did | | driverslicense | Data_DL_NormalizedValues | DL_age_over_19 | + | Faber | --public-did --did-exchange | --did-exchange | driverslicense | Data_DL_NormalizedValues | DL_age_over_19 | + + + @T001.1-RFC0037 + Scenario Outline: Present Proof where the prover does not propose a presentation of the proof and is acknowledged + Given we have "3" agents | name | role | capabilities | | Acme | issuer | | | Faber | verifier | | @@ -17,15 +35,31 @@ Feature: RFC 0037 Aries agent present proof | issuer | Acme_capabilities | Bob_capabilities | Schema_name | Credential_data | Proof_request | | Acme | --public-did | | driverslicense | Data_DL_NormalizedValues | DL_age_over_19 | | Faber | --public-did | | driverslicense | Data_DL_NormalizedValues | DL_age_over_19 | - | Acme | --public-did --did-exchange | --did-exchange | driverslicense | Data_DL_NormalizedValues | DL_age_over_19 | - | Acme | --public-did --mediation | --mediation | driverslicense | Data_DL_NormalizedValues | DL_age_over_19 | - | Acme | --public-did --multitenant | --multitenant | driverslicense | Data_DL_NormalizedValues | DL_age_over_19 | | Acme | --public-did --mediation --multitenant | --mediation --multitenant | driverslicense | Data_DL_NormalizedValues | DL_age_over_19 | - @T002-AIP10-RFC0037 @P1 @critical @AcceptanceTest @Indy @RFC0037 + @T002-RFC0037 @GHA + Scenario Outline: Present Proof where the issuer revokes the credential and the proof fails + Given we have "2" agents + | name | role | capabilities | + | Faber | verifier | | + | Bob | prover | | + And "" and "Bob" have an existing connection + And "Bob" has an issued credential from "" + And "" revokes the credential + And "Faber" and "Bob" have an existing connection + When "Faber" sends a request for proof presentation to "Bob" + Then "Faber" has the proof verification fail + + Examples: + | issuer | Acme_capabilities | Bob_capabilities | Schema_name | Credential_data | Proof_request | + | Faber | --revocation --public-did | | driverslicense | Data_DL_NormalizedValues | DL_age_over_19 | + | Faber | --revocation --public-did --did-exchange | --did-exchange | driverslicense | Data_DL_NormalizedValues | DL_age_over_19 | + + + @T002.1-RFC0037 Scenario Outline: Present Proof where the issuer revokes the credential and the proof fails - Given "3" agents + Given we have "3" agents | name | role | capabilities | | Acme | issuer | | | Faber | verifier | | @@ -40,7 +74,6 @@ Feature: RFC 0037 Aries agent present proof Examples: | issuer | Acme_capabilities | Bob_capabilities | Schema_name | Credential_data | Proof_request | | Acme | --revocation --public-did | | driverslicense | Data_DL_NormalizedValues | DL_age_over_19 | - | Faber | --revocation --public-did | | driverslicense | Data_DL_NormalizedValues | DL_age_over_19 | - | Acme | --revocation --public-did --did-exchange | --did-exchange | driverslicense | Data_DL_NormalizedValues | DL_age_over_19 | - | Acme | --revocation --public-did --mediation | --mediation | driverslicense | Data_DL_NormalizedValues | DL_age_over_19 | - | Acme | --revocation --public-did --multitenant | --multitenant | driverslicense | Data_DL_NormalizedValues | DL_age_over_19 | + | Faber | --revocation --public-did | | driverslicense | Data_DL_NormalizedValues | DL_age_over_19 | + | Acme | --revocation --public-did --mediation | | driverslicense | Data_DL_NormalizedValues | DL_age_over_19 | + | Acme | --revocation --public-did --multitenant | --multitenant | driverslicense | Data_DL_NormalizedValues | DL_age_over_19 | diff --git a/demo/features/0160-connection.feature b/demo/features/0160-connection.feature index e470f3de0f..beccc4df34 100644 --- a/demo/features/0160-connection.feature +++ b/demo/features/0160-connection.feature @@ -1,6 +1,6 @@ Feature: RFC 0160 Aries agent connection functions - @T001-AIP10-RFC0160 @P1 @critical @AcceptanceTest @RFC0160 + @T001-RFC0160 @GHA Scenario Outline: establish a connection between two agents Given we have "2" agents | name | role | capabilities | diff --git a/demo/features/0586-sign-transaction.feature b/demo/features/0586-sign-transaction.feature index 2f06edcdb6..b12e31c8ae 100644 --- a/demo/features/0586-sign-transaction.feature +++ b/demo/features/0586-sign-transaction.feature @@ -1,6 +1,6 @@ Feature: RFC 0586 Aries sign (endorse) transactions functions - @T001-RFC0586 @P1 @critical @AcceptanceTest @RFC0586 + @T001-RFC0586 @GHA Scenario Outline: endorse a transaction and write to the ledger Given we have "2" agents | name | role | capabilities | @@ -23,3 +23,24 @@ Feature: RFC 0586 Aries sign (endorse) transactions functions | --did-exchange | --did-exchange | driverslicense | | --mediation | --mediation | driverslicense | | --multitenant | --multitenant | driverslicense | + + @T001.1-RFC0586 + Scenario Outline: endorse a transaction and write to the ledger + Given we have "2" agents + | name | role | capabilities | + | Acme | endorser | | + | Bob | author | | + And "Acme" and "Bob" have an existing connection + When "Acme" has a DID with role "ENDORSER" + And "Bob" has a DID with role "AUTHOR" + And "Acme" connection has job role "TRANSACTION_ENDORSER" + And "Bob" connection has job role "TRANSACTION_AUTHOR" + And "Bob" authors a schema transaction with + And "Bob" requests endorsement for the transaction + And "Acme" endorses the transaction + Then "Bob" can write the transaction to the ledger + And "Bob" has written the schema to the ledger + + Examples: + | Acme_capabilities | Bob_capabilities | Schema_name | + | --mediation --multitenant | --mediation --multitenant | driverslicense | diff --git a/demo/run_bdd b/demo/run_bdd index 9bac002496..8ce5297ea5 100755 --- a/demo/run_bdd +++ b/demo/run_bdd @@ -123,7 +123,7 @@ done AGENT_MODULE="agent_container" AGENT_PORT=8020 -AGENT_PORT_RANGE=8020-8099 +AGENT_PORT_RANGE=8020-8079 echo "Preparing agent image..." docker build -q -t faber-alice-demo -f ../docker/Dockerfile.demo .. || exit 1 @@ -225,7 +225,7 @@ if [ "$OSTYPE" = "msys" ]; then fi DOCKER=${DOCKER:-docker} -$DOCKER run --name $AGENT --rm -it ${DOCKER_OPTS} \ +$DOCKER run --name $AGENT --rm ${DOCKER_OPTS} \ --network=${DOCKER_NET} \ -p 0.0.0.0:$AGENT_PORT_RANGE:$AGENT_PORT_RANGE \ -v "/$(pwd)/../logs:/home/indy/logs" \ diff --git a/demo/runners/support/agent.py b/demo/runners/support/agent.py index 2f0c49f303..e17a169071 100644 --- a/demo/runners/support/agent.py +++ b/demo/runners/support/agent.py @@ -223,6 +223,7 @@ async def register_schema_and_creddef( log_json(json.dumps(schema_response), label="Schema:") schema_id = schema_response["schema_id"] log_msg("Schema ID:", schema_id) + await asyncio.sleep(2.0) # Create a cred def for the schema cred_def_tag = ( @@ -493,6 +494,7 @@ def _process(self, args, env, loop): stderr=subprocess.PIPE, env=env, encoding="utf-8", + close_fds=True, ) loop.run_in_executor( None, @@ -526,9 +528,10 @@ async def start_process(self, python_path: str = None, wait: bool = True): # start agent sub-process loop = asyncio.get_event_loop() - self.proc = await loop.run_in_executor( + future = loop.run_in_executor( None, self._process, agent_args, my_env, loop ) + self.proc = await asyncio.wait_for(future, 20, loop=loop) if wait: await asyncio.sleep(1.0) await self.detect_process() @@ -546,18 +549,16 @@ def _terminate(self): async def terminate(self): # close session to admin api - self.log("Shutting down admin api session") await self.client_session.close() # shut down web hooks first - self.log("Shutting down web hooks site") if self.webhook_site: await self.webhook_site.stop() await asyncio.sleep(0.5) # now shut down the agent - self.log("Shutting down agent") loop = asyncio.get_event_loop() if self.proc: - await loop.run_in_executor(None, self._terminate) + future = loop.run_in_executor(None, self._terminate) + result = await asyncio.wait_for(future, 10, loop=loop) async def listen_webhooks(self, webhook_port): self.webhook_port = webhook_port @@ -790,6 +791,7 @@ async def fetch_status(url: str, timeout: float, headers=None): status_code, status_text = await fetch_status( status_url, START_TIMEOUT, headers=headers ) + self.log(status_code, status_text) if not status_text: raise Exception( diff --git a/docker/Dockerfile.bdd b/docker/Dockerfile.bdd index eb4db18a53..0f101c06f0 100644 --- a/docker/Dockerfile.bdd +++ b/docker/Dockerfile.bdd @@ -2,8 +2,7 @@ FROM faber-alice-demo # Install bdd dependencies RUN pip3 install --no-cache-dir -r demo/requirements.behave.txt - -# ENTRYPOINT ["bash", "-c", "demo/ngrok-wait.sh \"$@\"", "--"] +# ENV PYTHONMALLOC debug WORKDIR ./demo RUN chmod a+w . ENTRYPOINT ["behave"] From 48112c337efeacd0045fa023a476be3f279cd307 Mon Sep 17 00:00:00 2001 From: Ian Costanzo Date: Mon, 22 Mar 2021 07:34:23 -0700 Subject: [PATCH 2/3] Code cleanup Signed-off-by: Ian Costanzo --- .github/workflows/integrationtests.yml | 8 +++++--- actions/run-integration-tests/action.yml | 1 + demo/features/0586-sign-transaction.feature | 1 + demo/runners/support/agent.py | 1 - docker/Dockerfile.bdd | 2 +- 5 files changed, 8 insertions(+), 5 deletions(-) diff --git a/.github/workflows/integrationtests.yml b/.github/workflows/integrationtests.yml index 84e3929a4f..b1d499a846 100644 --- a/.github/workflows/integrationtests.yml +++ b/.github/workflows/integrationtests.yml @@ -1,15 +1,16 @@ name: acapy-integration-tests on: workflow_dispatch: - #schedule: - # - cron: "0 0 * * *" + pull_request: + branches: + - main defaults: run: shell: bash jobs: test: runs-on: ubuntu-latest - #if: (github.event_name == 'schedule' && github.repository == 'hyperledger/aries-cloudagent-python') || (github.event_name != 'schedule') + if: (github.event_name == 'pull_request' && github.repository == 'hyperledger/aries-cloudagent-python') || (github.event_name != 'pull_request') steps: - name: checkout-acapy uses: actions/checkout@v2 @@ -21,5 +22,6 @@ jobs: uses: ./acapy/actions/run-indy-tails-server - name: run-integration-tests uses: ./acapy/actions/run-integration-tests + # to run with a specific set of tests include the following parameter: # with: # TEST_SCOPE: "-t @T001-RFC0037" diff --git a/actions/run-integration-tests/action.yml b/actions/run-integration-tests/action.yml index d03b49343e..bcf49d8382 100644 --- a/actions/run-integration-tests/action.yml +++ b/actions/run-integration-tests/action.yml @@ -10,6 +10,7 @@ runs: using: "composite" steps: - name: run-integration-tests-acapy + # to run with external ledger and tails server run as follows (and remove the ledger and tails actions from the workflow): # run: LEDGER_URL=http://test.bcovrin.vonx.io PUBLIC_TAILS_URL=https://tails.vonx.io ./run_bdd ${{ inputs.TEST_SCOPE }} run: ./run_bdd ${{ inputs.TEST_SCOPE }} shell: bash diff --git a/demo/features/0586-sign-transaction.feature b/demo/features/0586-sign-transaction.feature index b12e31c8ae..a937c1a446 100644 --- a/demo/features/0586-sign-transaction.feature +++ b/demo/features/0586-sign-transaction.feature @@ -24,6 +24,7 @@ Feature: RFC 0586 Aries sign (endorse) transactions functions | --mediation | --mediation | driverslicense | | --multitenant | --multitenant | driverslicense | + @T001.1-RFC0586 Scenario Outline: endorse a transaction and write to the ledger Given we have "2" agents diff --git a/demo/runners/support/agent.py b/demo/runners/support/agent.py index e17a169071..8fbc653ae2 100644 --- a/demo/runners/support/agent.py +++ b/demo/runners/support/agent.py @@ -791,7 +791,6 @@ async def fetch_status(url: str, timeout: float, headers=None): status_code, status_text = await fetch_status( status_url, START_TIMEOUT, headers=headers ) - self.log(status_code, status_text) if not status_text: raise Exception( diff --git a/docker/Dockerfile.bdd b/docker/Dockerfile.bdd index 0f101c06f0..cacf38b6aa 100644 --- a/docker/Dockerfile.bdd +++ b/docker/Dockerfile.bdd @@ -2,7 +2,7 @@ FROM faber-alice-demo # Install bdd dependencies RUN pip3 install --no-cache-dir -r demo/requirements.behave.txt -# ENV PYTHONMALLOC debug + WORKDIR ./demo RUN chmod a+w . ENTRYPOINT ["behave"] From 1a20002de5c9d8b852f5bcda40e96eabb1a053fc Mon Sep 17 00:00:00 2001 From: Ian Costanzo Date: Mon, 22 Mar 2021 08:14:03 -0700 Subject: [PATCH 3/3] Fix black formatting Signed-off-by: Ian Costanzo --- demo/runners/support/agent.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/demo/runners/support/agent.py b/demo/runners/support/agent.py index 8fbc653ae2..246f0bb04e 100644 --- a/demo/runners/support/agent.py +++ b/demo/runners/support/agent.py @@ -528,9 +528,7 @@ async def start_process(self, python_path: str = None, wait: bool = True): # start agent sub-process loop = asyncio.get_event_loop() - future = loop.run_in_executor( - None, self._process, agent_args, my_env, loop - ) + future = loop.run_in_executor(None, self._process, agent_args, my_env, loop) self.proc = await asyncio.wait_for(future, 20, loop=loop) if wait: await asyncio.sleep(1.0)