stellar / system-test

Home of the stellar/stellar-system-test docker image for e2e system testing
1 stars 5 forks source link

Support captive core usage with Soroban RPC #21

Closed sreuland closed 1 year ago

sreuland commented 1 year ago

SystemTest uses stellar/quickstart:soroban-dev as a base image for running core, horizon, soroban rpc across various network configs. After soroban rpc was changed to use captive core at runtime, quickstart was changed to launch that new config - https://github.com/stellar/quickstart/pull/414

This PR is focused on hooking up the existing tests config to use the newer quickstart layout for rpc server. As part of this newer integration, refactored how system test image references quickstart as a base, rather then hardcoding a pinned hash version of quickstart:soroban-dev in Dockerfile. System test now provides a Makefile and clearer 2-step process to running tests:

Closes: #17

(1) build system test image locally with versions configurable as git references for each component(quickstart, core, horizon, rpc)

$ make CORE_GIT_REF=f1dc39f0f146815e5e3a94ed162e2f0639cb433f \
              CORE_COMPILE_CONFIGURE_FLAGS="--disable-tests --enable-next-protocol-version-unsafe-for-production" \
              SOROBAN_RPC_GIT_REF=main \
              RUST_TOOLCHAIN_VERSION=1.66.0 \
              SOROBAN_CLI_GIT_REF=main \
              QUICKSTART_GIT_REF=master \
              build
...
...
=> => writing image sha256:9213fed54a95d6d9508a318fe2ab021552eb54d84acfff666726bf5e1302cd89                                                                                                             0.0s
 => => naming to docker.io/stellar/system-test:dev  

(2) execute the tests from that locally built image. this has the advantage of making the system test image by default in the host platform arch, so it quietly resolves the amd64/arm64 decision, as you don't have to think about that anymore, and eliminates the docker qemu slowness for arm64 that was on prior versions that forced amd64 platform emu.

$ docker run --rm -it --name e2e_test stellar/system-test:dev --VerboseOutput false
Starting system test ...
starting target stack on standalone with following server versions:
  CORE VERSION=f1dc39f
rust version: rustc 1.66.1 (90743e729 2023-01-10)
soroban-env-host: 
    package version: 0.0.11
    git version: 258b86dfc3a64a7004e7cc5c0e5d0c3312e8c69e
    interface version: 27
    rs-stellar-xdr:
        package version: 0.0.11
        git version: dbf2abab7cfde069f89ec5846a1c0c75ce4764ef
        base XDR git version: next
  HORIZON VERSION=77cf2ca9d550e26091f6e5cca3ae60cb81863c87-(built-from-source)
go1.19.3
  SOROBAN RPC VERSION=soroban-rpc dev
waiting for horizon ingestion to be caught up to network current ledger...
horizon ingestion is caught up to network current ledger ...
waiting for soroban rpc to report ready state...
soroban rpc reported ready status, the service can be used by tools/cli now ...
  RUST_TOOLCHAIN_VERSION=rustc 1.66.0 (69f9c33d7 2022-12-12)
  SOROBAN_CLI_CRATE_VERSION=soroban 0.4.0 (9d23a4bd733f3b18cda275fd28a5a3e40ddf9437)
soroban-env 0.0.12 (993c527abce72748405d71467498bffd63e061c1)
soroban-env interface version 27
stellar-xdr 0.0.12 (154e07ebbb0ad307475fd665d5a0dcf169a9596f)
xdr next (026c9cd074bdb28ddde8ee52f2a4502d9e518a09)
  SOROBAN_EXAMPLES_GIT_HASH=main
  SOROBAN_EXAMPLES_REPO_URL=https://github.com/stellar/soroban-examples.git
  TARGET_NETWORK=standalone
  TARGET_NETWORK_PASSPHRASE=Standalone Network ; February 2017
  TARGET_NETWORK_SECRET_KEY=SC5O7VZUXDJ6JBDSZ74DSERXL7W3Y5LTOAMRF7RQRL3TAGAPS7LUVG3L
  TARGET_NETWORK_PUBLIC_KEY=GBZXN7PIRZGNMHGA7MUUUF4GWPY5AYPV6LY4UV2GL6VJGIQRXFDNMADI
  TARGET_NETWORK_RPC_URL=http://localhost:8000/soroban/rpc
  TEST_FILTER=
Tests can now begin ...
Running test binary ./dapp_develop_test ... 
=== RUN   TestDappDevelop
Feature: DApp Contract Development
=== RUN   TestDappDevelop/DApp_developer_compiles,_installs,_deploys_and_invokes_a_contract

  Scenario Outline: DApp developer compiles, installs, deploys and invokes a contract                          # dapp_develop.feature:3
    Given I used cli to compile example contract <ContractExampleSubPath>                                      # dapp_develop_test.go:79 -> github.com/stellar/system-test/features/dapp_develop.compileContract
    And I used rpc to verify my account is on the network                                                      # dapp_develop_test.go:244 -> github.com/stellar/system-test/features/dapp_develop.queryAccount
    And I used cli to install contract <ContractCompiledFileName> on ledger using my account to network        # dapp_develop_test.go:152 -> github.com/stellar/system-test/features/dapp_develop.installContract
    And I used cli to deploy contract <ContractCompiledFileName> by installed hash using my account to network # dapp_develop_test.go:113 -> github.com/stellar/system-test/features/dapp_develop.deployContract
    When I invoke function <FunctionName> on <ContractName> with request parameter <Param1> from <Tool>        # dapp_develop_test.go:179 -> github.com/stellar/system-test/features/dapp_develop.invokeContract
    Then the result should be <Result>                                                                         # dapp_develop_test.go:236 -> github.com/stellar/system-test/features/dapp_develop.theResultShouldBe

    Examples:
      | Tool | ContractExampleSubPath | ContractName                 | ContractCompiledFileName          | FunctionName | Param1     | Result            |
      | CLI  | hello_world            | soroban-hello-world-contract | soroban_hello_world_contract.wasm | hello        | --to=Aloha | ["Hello","Aloha"] |
=== RUN   TestDappDevelop/DApp_developer_compiles,_installs,_deploys_and_invokes_a_contract#01
      | CLI  | increment              | soroban-increment-contract   | soroban_increment_contract.wasm   | increment    |            | 1                 |
=== RUN   TestDappDevelop/DApp_developer_compiles,_deploys_and_invokes_a_contract

  Scenario Outline: DApp developer compiles, deploys and invokes a contract                             # dapp_develop.feature:19
    Given I used cli to compile example contract <ContractExampleSubPath>                               # dapp_develop_test.go:79 -> github.com/stellar/system-test/features/dapp_develop.compileContract
    And I used rpc to verify my account is on the network                                               # dapp_develop_test.go:244 -> github.com/stellar/system-test/features/dapp_develop.queryAccount
    And I used cli to deploy contract <ContractCompiledFileName> using my account to network            # dapp_develop_test.go:113 -> github.com/stellar/system-test/features/dapp_develop.deployContract
    When I invoke function <FunctionName> on <ContractName> with request parameter <Param1> from <Tool> # dapp_develop_test.go:179 -> github.com/stellar/system-test/features/dapp_develop.invokeContract
    Then the result should be <Result>                                                                  # dapp_develop_test.go:236 -> github.com/stellar/system-test/features/dapp_develop.theResultShouldBe

    Examples:
      | Tool | ContractExampleSubPath | ContractName                 | ContractCompiledFileName          | FunctionName | Param1     | Result            |
      | CLI  | hello_world            | soroban-hello-world-contract | soroban_hello_world_contract.wasm | hello        | --to=Aloha | ["Hello","Aloha"] |
=== RUN   TestDappDevelop/DApp_developer_compiles,_deploys_and_invokes_a_contract#01
      | CLI  | increment              | soroban-increment-contract   | soroban_increment_contract.wasm   | increment    |            | 1                 |

4 scenarios (4 passed)
22 steps (22 passed)
2m26.261932399s
--- PASS: TestDappDevelop (146.26s)
    --- PASS: TestDappDevelop/DApp_developer_compiles,_installs,_deploys_and_invokes_a_contract (55.64s)
    --- PASS: TestDappDevelop/DApp_developer_compiles,_installs,_deploys_and_invokes_a_contract#01 (28.64s)
    --- PASS: TestDappDevelop/DApp_developer_compiles,_deploys_and_invokes_a_contract (33.23s)
    --- PASS: TestDappDevelop/DApp_developer_compiles,_deploys_and_invokes_a_contract#01 (28.75s)
PASS
sreuland commented 1 year ago

this is pending on a fix for soroban-rpc build in tools - https://github.com/stellar/soroban-tools/pull/371