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

fix(test-tooling): substrate test ledger fails if WS_PORT not specified #2213

Closed
RafaelAPB opened this issue Nov 22, 2022 · 2 comments · Fixed by #2222
Closed

fix(test-tooling): substrate test ledger fails if WS_PORT not specified #2213

RafaelAPB opened this issue Nov 22, 2022 · 2 comments · Fixed by #2222
Assignees
Labels
bug Something isn't working Developer_Experience good-first-issue Good for newcomers good-first-issue-300-advanced Hacktoberfest Hacktoberfest participants are welcome to take a stab at issues marked with this label. P4 Priority 4: Low Polkadot Tasks related or relevant to the Polkadot connector

Comments

@RafaelAPB
Copy link
Contributor

RafaelAPB commented Nov 22, 2022

Describe the bug
As per our cactus-workshop examples branch, PR #2204, running examples/cactus-workshop-examples/src/main/typescript/test-ledger.ts yields an error. PR #1997 also depends on this issue.

To Reproduce

Run test case examples/cactus-workshop-examples/src/main/typescript/test-ledger.ts

Expected behavior

The test ledger should run without error

Logs/Stack traces


[2022-11-22T12:45:15.422Z] INFO (test-deploy-contract-via-web-service): Initialized logger
[2022-11-22T12:45:15.423Z] INFO (test-deploy-contract-via-web-service): Creating ledger
[2022-11-22T12:45:15.423Z] DEBUG (SubstrateTestLedger): Created instance of SubstrateTestLedger OK
[2022-11-22T12:45:15.424Z] DEBUG (SubstrateTestLedger): Pulling image ghcr.io/hyperledger/cactus-substrate-all-in-one:2022-03-29--1496...
[2022-11-22T12:45:15.948Z] DEBUG (SubstrateTestLedger): Pulled image ghcr.io/hyperledger/cactus-substrate-all-in-one:2022-03-29--1496 OK
[2022-11-22T12:45:15.948Z] DEBUG (SubstrateTestLedger): Starting ghcr.io/hyperledger/cactus-substrate-all-in-one:2022-03-29--1496 with options:  {
  Env: [
    'WORKING_DIR=/var/www/node-template',
    'CONTAINER_NAME=cacti-ledger',
    'PORT=9944',
    'DOCKER_PORT=9944',
    'CARGO_HOME=/var/www/node-template/.cargo'
  ],
  Healthcheck: {
    Test: [
      'CMD-SHELL',
      'rustup --version && rustc --version && cargo --version'
    ],
    Interval: 1000000000,
    Timeout: 3000000000,
    Retries: 10,
    StartPeriod: 1000000000
  },
  ExposedPorts: { '9944/tcp': {} },
  HostConfig: {
    AutoRemove: true,
    PublishAllPorts: false,
    Privileged: false,
    PortBindings: { '9944/tcp': [Array] }
  }
}
[2022-11-22T12:45:15.958Z] ERROR (SubstrateTestLedger): r [RuntimeError]: Failed to start container ghcr.io/hyperledger/cactus-substrate-all-in-one:2022-03-29--1496
    at /home/rbelchior/blockchain-integration-framework/packages/cactus-test-tooling/src/main/typescript/substrate-test-ledger/substrate-test-ledger.ts:148:31
    at handler (/home/rbelchior/blockchain-integration-framework/node_modules/dockerode/lib/docker.js:1455:21)
    at /home/rbelchior/blockchain-integration-framework/node_modules/dockerode/lib/docker.js:70:23
    at /home/rbelchior/blockchain-integration-framework/node_modules/docker-modem/lib/modem.js:332:7
    at getCause (/home/rbelchior/blockchain-integration-framework/node_modules/docker-modem/lib/modem.js:354:7)
    ... 5 lines matching cause stack trace ...
    at processTicksAndRejections (node:internal/process/task_queues:83:21) {
  cause: Error: (HTTP code 500) server error - json: cannot unmarshal number into Go struct field PortBinding.HostConfig.PortBindings.HostPort of type string 
      at /home/rbelchior/blockchain-integration-framework/node_modules/docker-modem/lib/modem.js:324:17
      at getCause (/home/rbelchior/blockchain-integration-framework/node_modules/docker-modem/lib/modem.js:354:7)
      at Modem.buildPayload (/home/rbelchior/blockchain-integration-framework/node_modules/docker-modem/lib/modem.js:323:5)
      at IncomingMessage.<anonymous> (/home/rbelchior/blockchain-integration-framework/node_modules/docker-modem/lib/modem.js:295:14)
      at IncomingMessage.emit (node:events:532:35)
      at IncomingMessage.emit (node:domain:475:12)
      at endReadableNT (node:internal/streams/readable:1346:12)
      at processTicksAndRejections (node:internal/process/task_queues:83:21) {
    reason: 'server error',
    statusCode: 500,
    json: {
      message: 'json: cannot unmarshal number into Go struct field PortBinding.HostConfig.PortBindings.HostPort of type string'
    }
  }
}
/home/rbelchior/blockchain-integration-framework/node_modules/dockerode/lib/docker.js:1455
    if (err) return callback(err, null, container);
                    ^
r [RuntimeError]: Failed to start container ghcr.io/hyperledger/cactus-substrate-all-in-one:2022-03-29--1496
    at /home/rbelchior/blockchain-integration-framework/packages/cactus-test-tooling/src/main/typescript/substrate-test-ledger/substrate-test-ledger.ts:148:31
    at handler (/home/rbelchior/blockchain-integration-framework/node_modules/dockerode/lib/docker.js:1455:21)
    at /home/rbelchior/blockchain-integration-framework/node_modules/dockerode/lib/docker.js:70:23
    at /home/rbelchior/blockchain-integration-framework/node_modules/docker-modem/lib/modem.js:332:7
    at getCause (/home/rbelchior/blockchain-integration-framework/node_modules/docker-modem/lib/modem.js:354:7)
    ... 5 lines matching cause stack trace ...
    at processTicksAndRejections (node:internal/process/task_queues:83:21) {
  cause: Error: (HTTP code 500) server error - json: cannot unmarshal number into Go struct field PortBinding.HostConfig.PortBindings.HostPort of type string 
      at /home/rbelchior/blockchain-integration-framework/node_modules/docker-modem/lib/modem.js:324:17
      at getCause (/home/rbelchior/blockchain-integration-framework/node_modules/docker-modem/lib/modem.js:354:7)
      at Modem.buildPayload (/home/rbelchior/blockchain-integration-framework/node_modules/docker-modem/lib/modem.js:323:5)
      at IncomingMessage.<anonymous> (/home/rbelchior/blockchain-integration-framework/node_modules/docker-modem/lib/modem.js:295:14)
      at IncomingMessage.emit (node:events:532:35)
      at IncomingMessage.emit (node:domain:475:12)
      at endReadableNT (node:internal/streams/readable:1346:12)
      at processTicksAndRejections (node:internal/process/task_queues:83:21) {
    reason: 'server error',
    statusCode: 500,
    json: {
      message: 'json: cannot unmarshal number into Go struct field PortBinding.HostConfig.PortBindings.HostPort of type string'
    }
  }
}

Cloud provider or hardware configuration:
Are you running the software on a dev machine or somewhere in the cloud?

Operating system name, version, build:
Linux 5.15.0-1018-gcp x86_64
NAME="Ubuntu"
VERSION="20.04.3 LTS (Focal Fossa)"
ID=ubuntu
ID_LIKE=debian
PRETTY_NAME="Ubuntu 20.04.3 LTS"
VERSION_ID="20.04"
HOME_URL="https://www.ubuntu.com/"
SUPPORT_URL="https://help.ubuntu.com/"
BUG_REPORT_URL="https://bugs.launchpad.net/ubuntu/"
PRIVACY_POLICY_URL="https://www.ubuntu.com/legal/terms-and-policies/privacy-policy"
VERSION_CODENAME=focal
UBUNTU_CODENAME=focal

Hyperledger Cactus release version or commit (git rev-parse --short HEAD):
3ba2ff4

Test tooling version 1.1.2. Bug does not exist in version 1.0.0

@RafaelAPB RafaelAPB added the bug Something isn't working label Nov 22, 2022
@petermetz petermetz added good-first-issue Good for newcomers Developer_Experience Hacktoberfest Hacktoberfest participants are welcome to take a stab at issues marked with this label. Polkadot Tasks related or relevant to the Polkadot connector good-first-issue-300-advanced P4 Priority 4: Low labels Nov 22, 2022
@petermetz
Copy link
Contributor

petermetz commented Nov 22, 2022

Thanks for tracking this problem @RafaelAPB I added some more labels. It seems like one of those issues that I would know how to fix quickly because I've seen similar crashes from docker before, so, if you struggle to debug what the problem is just let me know and I can take a stab at it myself.

@RafaelAPB
Copy link
Contributor Author

Thanks for tracking this problem @RafaelAPB I added some more labels. It seems like one of those issues that I would know how to fix quickly because I've seen similar crashes from docker before, so, if you struggle to debug what the problem is just let me know and I can take a stab at it myself.

Thanks a lot, Peter. I'm not resolving this in the near future.

@petermetz petermetz self-assigned this Nov 29, 2022
petermetz added a commit to petermetz/cacti that referenced this issue Nov 29, 2022
Docker expects environment variables passed to the container
to be strings.
The null coalescing code was making it so that if the test case
did not pass in a custom WS_PORT  env var, then it would default
to using a value for the port that was a number not a string.
This would crash the serialization logic within docker that was
trying to apply the environment variables to the container when
starting it.

Switching the type of 9944 default WS port to "9944" (string) fixes it.
Also specifying explicitly the `wsPort` variable's type to be
string so that the next time someone tries to make this mistake
the compiler will slap their hands right away.

Fixes hyperledger-cacti#2213

Signed-off-by: Peter Somogyvari <peter.somogyvari@accenture.com>
@petermetz petermetz changed the title substrate test ledger fails on v1.1.2 fix(test-tooling): substrate test ledger fails if WS_PORT not specified Nov 29, 2022
petermetz pushed a commit to RafaelAPB/blockchain-integration-framework that referenced this issue Nov 29, 2022
Simple examples using Cacti tailored for the workshop 2022-11-14.

Thanks to @AndreAugusto11 and
Monica Gomez monicasrgomez@gmail.com @msrgomez for the amazing work.

Works with version 1.0.0 of cactus-tooling.

Depends on hyperledger-cacti#2213

Co-Authored-By: Monica Gomez <monicasrgomez@gmail.com>
Co-Authored-By: André Augusto <andre.augusto@tecnico.ulisboa.pt>
Co-Authored-By: Peter Somogyvari <peter.somogyvari@accenture.com>

Signed-off-by: André Augusto <andre.augusto@tecnico.ulisboa.pt>
Signed-off-by: Rafael Belchior <rafael.belchior@tecnico.ulisboa.pt>
Signed-off-by: Peter Somogyvari <peter.somogyvari@accenture.com>
petermetz added a commit to RafaelAPB/blockchain-integration-framework that referenced this issue Nov 29, 2022
Simple examples using Cacti tailored for the workshop 2022-11-14.

Thanks to @AndreAugusto11 and
Monica Gomez monicasrgomez@gmail.com @msrgomez for the amazing work.

Works with version 1.0.0 of cactus-tooling.

Depends on hyperledger-cacti#2213

Signed-off-by: André Augusto <andre.augusto@tecnico.ulisboa.pt>
Signed-off-by: Rafael Belchior <rafael.belchior@tecnico.ulisboa.pt>
Signed-off-by: Peter Somogyvari <peter.somogyvari@accenture.com>

Co-Authored-By: Monica Gomez <monicasrgomez@gmail.com>
Co-Authored-By: André Augusto <andre.augusto@tecnico.ulisboa.pt>
Co-Authored-By: Peter Somogyvari <peter.somogyvari@accenture.com>
RafaelAPB referenced this issue in RafaelAPB/blockchain-integration-framework Nov 29, 2022
Simple examples using Cacti tailored for the workshop 2022-11-14.

Thanks to @AndreAugusto11 and
Monica Gomez monicasrgomez@gmail.com @msrgomez for the amazing work.

Works with version 1.0.0 of cactus-tooling.

Depends on hyperledger#2213

Signed-off-by: André Augusto <andre.augusto@tecnico.ulisboa.pt>
Signed-off-by: Rafael Belchior <rafael.belchior@tecnico.ulisboa.pt>
Signed-off-by: Peter Somogyvari <peter.somogyvari@accenture.com>

Co-Authored-By: Monica Gomez <monicasrgomez@gmail.com>
Co-Authored-By: André Augusto <andre.augusto@tecnico.ulisboa.pt>
Co-Authored-By: Peter Somogyvari <peter.somogyvari@accenture.com>
RafaelAPB added a commit to RafaelAPB/blockchain-integration-framework that referenced this issue Nov 29, 2022
Simple examples using Cacti tailored for the workshop 2022-11-14.

Thanks to @AndreAugusto11 and
Monica Gomez monicasrgomez@gmail.com @msrgomez for the amazing work.

Works with version 1.0.0 of cactus-tooling.

Depends on hyperledger-cacti#2213

Signed-off-by: André Augusto <andre.augusto@tecnico.ulisboa.pt>
Signed-off-by: Rafael Belchior <rafael.belchior@tecnico.ulisboa.pt>
Signed-off-by: Peter Somogyvari <peter.somogyvari@accenture.com>

Co-Authored-By: Monica Gomez <monicasrgomez@gmail.com>
Co-Authored-By: André Augusto <andre.augusto@tecnico.ulisboa.pt>
Co-Authored-By: Peter Somogyvari <peter.somogyvari@accenture.com>
takeutak pushed a commit that referenced this issue Nov 30, 2022
Docker expects environment variables passed to the container
to be strings.
The null coalescing code was making it so that if the test case
did not pass in a custom WS_PORT  env var, then it would default
to using a value for the port that was a number not a string.
This would crash the serialization logic within docker that was
trying to apply the environment variables to the container when
starting it.

Switching the type of 9944 default WS port to "9944" (string) fixes it.
Also specifying explicitly the `wsPort` variable's type to be
string so that the next time someone tries to make this mistake
the compiler will slap their hands right away.

Fixes #2213

Signed-off-by: Peter Somogyvari <peter.somogyvari@accenture.com>
RafaelAPB added a commit to RafaelAPB/blockchain-integration-framework that referenced this issue Dec 29, 2022
Simple examples using Cacti tailored for the workshop 2022-11-14.

Thanks to @AndreAugusto11 and
Monica Gomez monicasrgomez@gmail.com @msrgomez for the amazing work.

Works with version 1.0.0 of cactus-tooling.

Depends on hyperledger-cacti#2213

Signed-off-by: André Augusto <andre.augusto@tecnico.ulisboa.pt>
Signed-off-by: Rafael Belchior <rafael.belchior@tecnico.ulisboa.pt>
Signed-off-by: Peter Somogyvari <peter.somogyvari@accenture.com>

Co-Authored-By: Monica Gomez <monicasrgomez@gmail.com>
Co-Authored-By: André Augusto <andre.augusto@tecnico.ulisboa.pt>
Co-Authored-By: Peter Somogyvari <peter.somogyvari@accenture.com>
RafaelAPB added a commit to RafaelAPB/blockchain-integration-framework that referenced this issue Jan 18, 2023
Simple examples using Cacti tailored for the workshop 2022-11-14.

Thanks to @AndreAugusto11 and
Monica Gomez monicasrgomez@gmail.com @msrgomez for the amazing work.

Works with version 1.0.0 of cactus-tooling.

Depends on hyperledger-cacti#2213

Signed-off-by: André Augusto <andre.augusto@tecnico.ulisboa.pt>
Signed-off-by: Rafael Belchior <rafael.belchior@tecnico.ulisboa.pt>
Signed-off-by: Peter Somogyvari <peter.somogyvari@accenture.com>

Co-Authored-By: Monica Gomez <monicasrgomez@gmail.com>
Co-Authored-By: André Augusto <andre.augusto@tecnico.ulisboa.pt>
Co-Authored-By: Peter Somogyvari <peter.somogyvari@accenture.com>
RafaelAPB added a commit to RafaelAPB/blockchain-integration-framework that referenced this issue Jan 18, 2023
Simple examples using Cacti tailored for the workshop 2022-11-14.

Thanks to @AndreAugusto11 and
Monica Gomez monicasrgomez@gmail.com @msrgomez for the amazing work.

Works with version 1.0.0 of cactus-tooling.

Depends on hyperledger-cacti#2213

Signed-off-by: André Augusto <andre.augusto@tecnico.ulisboa.pt>
Signed-off-by: Rafael Belchior <rafael.belchior@tecnico.ulisboa.pt>
Signed-off-by: Peter Somogyvari <peter.somogyvari@accenture.com>

Co-Authored-By: Monica Gomez <monicasrgomez@gmail.com>
Co-Authored-By: André Augusto <andre.augusto@tecnico.ulisboa.pt>
Co-Authored-By: Peter Somogyvari <peter.somogyvari@accenture.com>
Signed-off-by: Rafael Belchior <rafael.belchior@tecnico.ulisboa.pt>
petermetz added a commit to RafaelAPB/blockchain-integration-framework that referenced this issue Jan 27, 2023
Simple examples using Cacti tailored for the workshop 2022-11-14.

Thanks to @AndreAugusto11 and
Monica Gomez monicasrgomez@gmail.com @msrgomez for the amazing work.

Works with version 1.0.0 of cactus-tooling.

Depends on hyperledger-cacti#2213

Signed-off-by: André Augusto <andre.augusto@tecnico.ulisboa.pt>
Signed-off-by: Rafael Belchior <rafael.belchior@tecnico.ulisboa.pt>
Signed-off-by: Peter Somogyvari <peter.somogyvari@accenture.com>

Co-Authored-By: Monica Gomez <monicasrgomez@gmail.com>
Co-Authored-By: André Augusto <andre.augusto@tecnico.ulisboa.pt>
Co-Authored-By: Peter Somogyvari <peter.somogyvari@accenture.com>
Signed-off-by: Rafael Belchior <rafael.belchior@tecnico.ulisboa.pt>
petermetz added a commit that referenced this issue Jan 27, 2023
Simple examples using Cacti tailored for the workshop 2022-11-14.

Thanks to @AndreAugusto11 and
Monica Gomez monicasrgomez@gmail.com @msrgomez for the amazing work.

Works with version 1.0.0 of cactus-tooling.

Depends on #2213

Signed-off-by: André Augusto <andre.augusto@tecnico.ulisboa.pt>
Signed-off-by: Rafael Belchior <rafael.belchior@tecnico.ulisboa.pt>
Signed-off-by: Peter Somogyvari <peter.somogyvari@accenture.com>

Co-Authored-By: Monica Gomez <monicasrgomez@gmail.com>
Co-Authored-By: André Augusto <andre.augusto@tecnico.ulisboa.pt>
Co-Authored-By: Peter Somogyvari <peter.somogyvari@accenture.com>
Signed-off-by: Rafael Belchior <rafael.belchior@tecnico.ulisboa.pt>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working Developer_Experience good-first-issue Good for newcomers good-first-issue-300-advanced Hacktoberfest Hacktoberfest participants are welcome to take a stab at issues marked with this label. P4 Priority 4: Low Polkadot Tasks related or relevant to the Polkadot connector
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants