From 82f8482708c69b2c65c3cfbc7c217fe944f0d409 Mon Sep 17 00:00:00 2001 From: Mohsin Zaidi <2236875+smrz2001@users.noreply.github.com> Date: Fri, 8 Sep 2023 17:01:58 -0400 Subject: [PATCH] feat: add workflows for property-based testing (#11) --- .github/workflows/prop.yml | 86 ++++++ .github/workflows/smoke.yml | 68 +++++ Cargo.lock | 407 ++++++++++++++++++----------- Cargo.toml | 5 +- Dockerfile | 12 +- ci-scripts/publish.sh | 6 +- k8s/networks/basic-go-rust.yaml | 12 + k8s/networks/basic-go.yaml | 10 + k8s/networks/basic-rust.yaml | 10 + k8s/tests/manifests/prop.yaml | 64 +++++ k8s/tests/manifests/setup.yaml | 31 +++ k8s/tests/manifests/smoke.yaml | 146 +++++++++++ k8s/tests/scripts/check-network.sh | 33 +++ k8s/tests/scripts/delete-tests.sh | 31 +++ k8s/tests/scripts/process-peers.sh | 30 +++ k8s/tests/scripts/run-tests.sh | 62 +++++ tests/api.rs | 25 +- 17 files changed, 859 insertions(+), 179 deletions(-) create mode 100644 .github/workflows/prop.yml create mode 100644 .github/workflows/smoke.yml create mode 100644 k8s/networks/basic-go-rust.yaml create mode 100644 k8s/networks/basic-go.yaml create mode 100644 k8s/networks/basic-rust.yaml create mode 100644 k8s/tests/manifests/prop.yaml create mode 100644 k8s/tests/manifests/setup.yaml create mode 100644 k8s/tests/manifests/smoke.yaml create mode 100755 k8s/tests/scripts/check-network.sh create mode 100755 k8s/tests/scripts/delete-tests.sh create mode 100644 k8s/tests/scripts/process-peers.sh create mode 100755 k8s/tests/scripts/run-tests.sh diff --git a/.github/workflows/prop.yml b/.github/workflows/prop.yml new file mode 100644 index 00000000..bb111a0a --- /dev/null +++ b/.github/workflows/prop.yml @@ -0,0 +1,86 @@ +name: Run property-based tests + +on: + pull_request: + merge_group: + types: [checks_requested] + schedule: + # Run every midnight UTC + - cron: "0 0 * * *" + workflow_dispatch: # manually triggered + +jobs: + generate-matrix: + name: Generate Matrix + runs-on: ubuntu-latest + outputs: + networks: ${{ steps.generate-matrix.outputs.networks }} + steps: + - + name: Checkout + uses: actions/checkout@v3 + - + name: Generate network matrix + id: generate-matrix + run: | + NETWORKS=$(ls k8s/networks | jq -R -s -c '. | gsub(".yaml"; "") | split("\n")[:-1]') + echo ${NETWORKS} + echo ::set-output name=networks::${NETWORKS} + + run-tests: + name: Test + runs-on: ubuntu-latest + needs: generate-matrix + strategy: + fail-fast: false + matrix: + networks: ${{ fromJSON(needs.generate-matrix.outputs.networks) }} + steps: + - + name: Checkout + uses: actions/checkout@v3 + - + name: Setup GKE auth + uses: 'google-github-actions/auth@v1' + with: + credentials_json: ${{ secrets.GKE_SA_KEY }} + - + name: Get GKE credentials + uses: 'google-github-actions/get-gke-credentials@v1' + with: + cluster_name: ${{ secrets.GKE_CLUSTER }} + location: ${{ secrets.GKE_ZONE }} + - + # Add a "_sha_runId" suffix to differentiate PR test runs + name: Setup test env + if: ${{ github.event_name == 'pull_request' }} + run: | + TEST_SUFFIX="-$(echo ${{ github.sha }} | head -c 8)-${{ github.run_id }}" + echo "TEST_SUFFIX=$TEST_SUFFIX" >> $GITHUB_ENV + - + name: Test ${{ matrix.networks }} + working-directory: k8s/tests/scripts + run: ./run-tests.sh ${{ matrix.networks }} + - + # Always cleanup resources at the end of PR test runs, whether the tests pass or fail. + name: Delete ${{ matrix.networks }} + if: always() + working-directory: k8s/tests/scripts + run: | + if [[ ${{ github.event_name }} == "pull_request" ]]; then + ./delete-tests.sh ${{ matrix.networks }} + fi + + collect-results: + name: Results + if: ${{ always() }} + runs-on: ubuntu-latest + needs: [run-tests] + steps: + - run: exit 1 + # see https://stackoverflow.com/a/67532120/4907315 + if: >- + ${{ + contains(needs.*.result, 'failure') + || contains(needs.*.result, 'cancelled') + }} diff --git a/.github/workflows/smoke.yml b/.github/workflows/smoke.yml new file mode 100644 index 00000000..c272c577 --- /dev/null +++ b/.github/workflows/smoke.yml @@ -0,0 +1,68 @@ +name: Run smoke tests + +on: + schedule: + # Run every midnight UTC + - cron: "0 0 * * *" + workflow_dispatch: # manually triggered + +jobs: + generate-matrix: + name: Generate Matrix + runs-on: ubuntu-latest + outputs: + networks: ${{ steps.generate-matrix.outputs.networks }} + steps: + - + name: Checkout + uses: actions/checkout@v3 + - + name: Generate network matrix + id: generate-matrix + run: | + NETWORKS=$(ls k8s/networks | jq -R -s -c '. | gsub(".yaml"; "") | split("\n")[:-1]') + echo ${NETWORKS} + echo ::set-output name=networks::${NETWORKS} + + run-tests: + name: Test + runs-on: ubuntu-latest + needs: generate-matrix + strategy: + fail-fast: false + matrix: + networks: ${{ fromJSON(needs.generate-matrix.outputs.networks) }} + steps: + - + name: Checkout + uses: actions/checkout@v3 + - + name: Setup GKE auth + uses: 'google-github-actions/auth@v1' + with: + credentials_json: ${{ secrets.GKE_SA_KEY }} + - + name: Get GKE credentials + uses: 'google-github-actions/get-gke-credentials@v1' + with: + cluster_name: ${{ secrets.GKE_CLUSTER }} + location: ${{ secrets.GKE_ZONE }} + - + # Don't clean up networks afterward so that these tests can run longer term + name: Test ${{ matrix.networks }} + working-directory: k8s/tests/scripts + run: ./run-tests.sh ${{ matrix.networks }} smoke + + collect-results: + name: Results + if: ${{ always() }} + runs-on: ubuntu-latest + needs: [run-tests] + steps: + - run: exit 1 + # see https://stackoverflow.com/a/67532120/4907315 + if: >- + ${{ + contains(needs.*.result, 'failure') + || contains(needs.*.result, 'cancelled') + }} diff --git a/Cargo.lock b/Cargo.lock index c48cf5a7..5fa9b428 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4,9 +4,9 @@ version = 3 [[package]] name = "addr2line" -version = "0.20.0" +version = "0.21.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f4fa78e18c64fce05e902adecd7a5eed15a5e0a3439f7b0e169f0252214865e3" +checksum = "8a30b2e23b9e17a9f90641c7ab1549cd9b44f296d3ccbf309d2863cfe398a0cb" dependencies = [ "gimli", ] @@ -41,9 +41,9 @@ dependencies = [ [[package]] name = "aho-corasick" -version = "1.0.4" +version = "1.0.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6748e8def348ed4d14996fa801f4122cd763fff530258cdc03f64b25f89d3a5a" +checksum = "0c378d78423fdad8089616f827526ee33c19f2fddbd5de1629152c9593ba4783" dependencies = [ "memchr", ] @@ -207,7 +207,7 @@ checksum = "bc00ceb34980c03614e35a3a4e218276a0a824e911d07651cd0d858a51e8c0f0" dependencies = [ "proc-macro2", "quote", - "syn 2.0.29", + "syn 2.0.31", ] [[package]] @@ -233,9 +233,9 @@ checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" [[package]] name = "backtrace" -version = "0.3.68" +version = "0.3.69" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4319208da049c43661739c5fade2ba182f09d1dc2299b32298d3a31692b17e12" +checksum = "2089b7e3f35b9dd2d0ed921ead4f6d318c27680d4a5bd167b3ee120edb105837" dependencies = [ "addr2line", "cc", @@ -282,9 +282,9 @@ checksum = "9e1b586273c5702936fe7b7d6896644d8be71e6314cfe09d3167c95f712589e8" [[package]] name = "base64" -version = "0.21.2" +version = "0.21.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "604178f6c5c21f02dc555784810edfb88d34ac2c73b2eae109655649ee73ce3d" +checksum = "414dcefbc63d77c526a76b3afcf6fbb9b5e2791c19c3aa2297733208750c6e53" [[package]] name = "base64ct" @@ -499,7 +499,7 @@ dependencies = [ "serde_with 2.3.3", "siwe", "thiserror", - "time 0.3.26", + "time 0.3.28", "url", ] @@ -534,7 +534,7 @@ dependencies = [ [[package]] name = "ceramic-api-server" version = "0.1.0" -source = "git+https://github.com/3box/rust-ceramic?branch=main#5900e6fb2e4bdbbbe065b9df94185b62b0e638ab" +source = "git+https://github.com/3box/rust-ceramic?branch=main#98eba07600f1fb3d2831d1c8849ba714915ad2b6" dependencies = [ "async-trait", "chrono", @@ -559,11 +559,11 @@ dependencies = [ [[package]] name = "ceramic-core" version = "0.1.0" -source = "git+https://github.com/3box/rust-ceramic?branch=main#5900e6fb2e4bdbbbe065b9df94185b62b0e638ab" +source = "git+https://github.com/3box/rust-ceramic?branch=main#98eba07600f1fb3d2831d1c8849ba714915ad2b6" dependencies = [ "anyhow", "async-trait", - "base64 0.21.2", + "base64 0.21.3", "cid 0.9.0", "did-method-key", "did-pkh", @@ -585,7 +585,7 @@ dependencies = [ [[package]] name = "ceramic-event" version = "0.1.0" -source = "git+https://github.com/3box/rust-ceramic?branch=main#5900e6fb2e4bdbbbe065b9df94185b62b0e638ab" +source = "git+https://github.com/3box/rust-ceramic?branch=main#98eba07600f1fb3d2831d1c8849ba714915ad2b6" dependencies = [ "anyhow", "ceramic-core", @@ -600,7 +600,7 @@ dependencies = [ [[package]] name = "ceramic-http-client" version = "0.1.0" -source = "git+https://github.com/3box/ceramic-http-client-rs.git?branch=main#991d5acf20ac8218b738dbbaa9418059f9be671f" +source = "git+https://github.com/3box/ceramic-http-client-rs.git?branch=main#be4b848c2a178e860eb17941ddc430b5e91c4f9f" dependencies = [ "anyhow", "ceramic-event", @@ -616,7 +616,7 @@ dependencies = [ [[package]] name = "ceramic-kubo-rpc-server" version = "0.1.0" -source = "git+https://github.com/3box/rust-ceramic?branch=main#5900e6fb2e4bdbbbe065b9df94185b62b0e638ab" +source = "git+https://github.com/3box/rust-ceramic?branch=main#98eba07600f1fb3d2831d1c8849ba714915ad2b6" dependencies = [ "async-trait", "chrono", @@ -640,6 +640,22 @@ dependencies = [ "url", ] +[[package]] +name = "ceramic-tests" +version = "0.1.0" +dependencies = [ + "ceramic-api-server", + "ceramic-http-client", + "ceramic-kubo-rpc-server", + "dotenvy", + "hyper", + "swagger", + "tokio", + "tracing", + "tracing-test", + "url", +] + [[package]] name = "cfg-if" version = "1.0.0" @@ -648,9 +664,9 @@ checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" [[package]] name = "chrono" -version = "0.4.26" +version = "0.4.29" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ec837a71355b28f6556dbd569b37b3f363091c0bd4b2e735674521b4c5fd9bc5" +checksum = "d87d9d13be47a5b7c3907137f1290b0459a7f80efb26be8c52afb11963bccb02" dependencies = [ "android-tzdata", "iana-time-zone", @@ -659,7 +675,7 @@ dependencies = [ "serde", "time 0.1.45", "wasm-bindgen", - "winapi", + "windows-targets", ] [[package]] @@ -862,6 +878,34 @@ dependencies = [ "zeroize", ] +[[package]] +name = "curve25519-dalek" +version = "4.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "622178105f911d937a42cdb140730ba4a3ed2becd8ae6ce39c7d28b5d75d4588" +dependencies = [ + "cfg-if", + "cpufeatures", + "curve25519-dalek-derive", + "digest 0.10.7", + "fiat-crypto", + "platforms", + "rustc_version", + "subtle", + "zeroize", +] + +[[package]] +name = "curve25519-dalek-derive" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "83fdaf97f4804dcebfa5862639bc9ce4121e82140bec2a987ac5140294865b5b" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.31", +] + [[package]] name = "darling" version = "0.10.2" @@ -931,7 +975,7 @@ dependencies = [ "proc-macro2", "quote", "strsim 0.10.0", - "syn 2.0.29", + "syn 2.0.31", ] [[package]] @@ -964,7 +1008,7 @@ checksum = "836a9bbc7ad63342d6d6e7b815ccab164bc77a2d95d84bc3117a8c0d5c98e2d5" dependencies = [ "darling_core 0.20.3", "quote", - "syn 2.0.29", + "syn 2.0.31", ] [[package]] @@ -1020,6 +1064,16 @@ dependencies = [ "zeroize", ] +[[package]] +name = "der" +version = "0.7.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fffa369a668c8af7dbf8b5e56c9f744fbd399949ed171606040001947de40b1c" +dependencies = [ + "const-oid 0.9.5", + "zeroize", +] + [[package]] name = "deranged" version = "0.3.8" @@ -1153,7 +1207,7 @@ dependencies = [ "der 0.6.1", "elliptic-curve", "rfc6979", - "signature", + "signature 1.6.4", ] [[package]] @@ -1162,7 +1216,17 @@ version = "1.5.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "91cff35c70bba8a626e3185d8cd48cc11b5437e1a5bcd15b9b5fa3c64b6dfee7" dependencies = [ - "signature", + "signature 1.6.4", +] + +[[package]] +name = "ed25519" +version = "2.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "60f6d271ca33075c88028be6f04d502853d63a5ece419d269c15315d4fc1cf1d" +dependencies = [ + "pkcs8 0.10.2", + "signature 2.1.0", ] [[package]] @@ -1171,14 +1235,28 @@ version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c762bae6dcaf24c4c84667b8579785430908723d5c889f469d76a41d59cc7a9d" dependencies = [ - "curve25519-dalek", - "ed25519", + "curve25519-dalek 3.2.0", + "ed25519 1.5.3", "rand 0.7.3", "serde", "sha2 0.9.9", "zeroize", ] +[[package]] +name = "ed25519-dalek" +version = "2.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7277392b266383ef8396db7fdeb1e77b6c52fed775f5df15bb24f35b72156980" +dependencies = [ + "curve25519-dalek 4.1.0", + "ed25519 2.2.2", + "rand_core 0.6.4", + "serde", + "sha2 0.10.7", + "zeroize", +] + [[package]] name = "elliptic-curve" version = "0.12.3" @@ -1201,9 +1279,9 @@ dependencies = [ [[package]] name = "encoding_rs" -version = "0.8.32" +version = "0.8.33" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "071a31f4ee85403370b58aca746f01041ede6f0da2730960ad001edc2b71b394" +checksum = "7268b386296a025e474d5140678f75d6de9493ae55a5d709eeb9dd08149945e1" dependencies = [ "cfg-if", ] @@ -1216,9 +1294,9 @@ checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5" [[package]] name = "errno" -version = "0.3.2" +version = "0.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6b30f669a7961ef1631673d2766cc92f52d64f7ef354d4fe0ddfd30ed52f0f4f" +checksum = "136526188508e25c6fef639d7927dfb3e0e3084488bf202267829cf7fc23dbdd" dependencies = [ "errno-dragonfly", "libc", @@ -1272,6 +1350,12 @@ dependencies = [ "subtle", ] +[[package]] +name = "fiat-crypto" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d0870c84016d4b481be5c9f323c24f65e31e901ae618f0e80f4308fb00de1d2d" + [[package]] name = "fixed-hash" version = "0.7.0" @@ -1404,7 +1488,7 @@ checksum = "89ca545a94061b6365f2c7355b4b32bd20df3ff95f02da9329b34ccc3bd6ee72" dependencies = [ "proc-macro2", "quote", - "syn 2.0.29", + "syn 2.0.31", ] [[package]] @@ -1482,9 +1566,9 @@ dependencies = [ [[package]] name = "gimli" -version = "0.27.3" +version = "0.28.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b6c80984affa11d98d1b88b66ac8853f143217b399d3c74116778ff8fdb4ed2e" +checksum = "6fb8d784f27acf97159b40fc4db5ecd8aa23b9ad5ef69cdd136d3bc80665f0c0" [[package]] name = "gloo-timers" @@ -1523,9 +1607,9 @@ dependencies = [ [[package]] name = "h2" -version = "0.3.20" +version = "0.3.21" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "97ec8491ebaf99c8eaa73058b045fe58073cd6be7f596ac993ced0b0a0c01049" +checksum = "91fc23aa11be92976ef4729127f1a74adf36d8436f7816b185d18df956790833" dependencies = [ "bytes 1.4.0", "fnv", @@ -1995,9 +2079,9 @@ dependencies = [ [[package]] name = "json-number" -version = "0.4.5" +version = "0.4.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c724484d970b5aabe46934b9571980e255fd50a9ef1b13f23ed2b5c2a19bbb69" +checksum = "280f53da10842ffc42737ac8a6f2c14ced71f950de1cdb6765264a2eb1100cc5" dependencies = [ "lexical", "ryu-js", @@ -2019,9 +2103,9 @@ dependencies = [ [[package]] name = "json-syntax" -version = "0.9.4" +version = "0.9.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b9043ed89d8285e64843df5e12696d5d14f1efc0642bdde62852239917fa7e1f" +checksum = "9f2f4557e0fe320cc102bdebf9fa9471b8513e13bb34b5fc23d7e270c5f9b1cc" dependencies = [ "contextual", "decoded-char", @@ -2265,12 +2349,12 @@ checksum = "f7012b1bbb0719e1097c47611d3898568c546d597c2e74d66f6087edd5233ff4" [[package]] name = "libp2p-identity" -version = "0.1.2" +version = "0.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9e2d584751cecb2aabaa56106be6be91338a60a0f4e420cf2af639204f596fc1" +checksum = "276bb57e7af15d8f100d3c11cbdd32c6752b7eef4ba7a18ecf464972c07abcce" dependencies = [ "bs58", - "ed25519-dalek", + "ed25519-dalek 2.0.0", "log 0.4.20", "multiaddr", "multihash 0.17.0", @@ -2320,9 +2404,9 @@ dependencies = [ [[package]] name = "locspan" -version = "0.7.13" +version = "0.7.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "685e26b5a3e4266c351baf3c00793a097e40f4293270ac508b3f4cbc41e72e54" +checksum = "6eb541fabac50f90782ec4fafa7b0b3961adc0d1862c7c7a863dc94ed5541d73" dependencies = [ "contextual", "hashbrown 0.13.2", @@ -2369,9 +2453,9 @@ dependencies = [ [[package]] name = "memchr" -version = "2.5.0" +version = "2.6.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2dffe52ecf27772e601905b7522cb4ef790d2cc203488bbd0e2fe85fcb74566d" +checksum = "8f232d6ef707e1956a43342693d2a31e72989554d58299d7a88738cc95b0d35c" [[package]] name = "mime" @@ -2587,9 +2671,9 @@ dependencies = [ [[package]] name = "num-bigint" -version = "0.4.3" +version = "0.4.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f93ab6289c7b344a8a9f60f88d80aa20032336fe78da341afc91c8a2341fc75f" +checksum = "608e7659b5c3d7cba262d894801b9ec9d00de989e8a82bd4bef91d08da45cdc0" dependencies = [ "autocfg 1.1.0", "num-integer", @@ -2667,9 +2751,9 @@ dependencies = [ [[package]] name = "object" -version = "0.31.1" +version = "0.32.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8bda667d9f2b5051b8833f59f3bf748b28ef54f850f4fcb389a252aa383866d1" +checksum = "9cf5f9dd3933bd50a9e1f149ec995f39ae2c496d31fd772c1fd45ebc27e902b0" dependencies = [ "memchr", ] @@ -2694,11 +2778,11 @@ checksum = "624a8340c38c1b80fd549087862da4ba43e08858af025b236e509b6649fc13d5" [[package]] name = "openssl" -version = "0.10.56" +version = "0.10.57" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "729b745ad4a5575dd06a3e1af1414bd330ee561c01b3899eb584baeaa8def17e" +checksum = "bac25ee399abb46215765b1cb35bc0212377e58a061560d8b29b024fd0430e7c" dependencies = [ - "bitflags 1.3.2", + "bitflags 2.4.0", "cfg-if", "foreign-types", "libc", @@ -2715,7 +2799,7 @@ checksum = "a948666b637a0f465e8564c73e89d4dde00d72d4d473cc972f390fc3dcee7d9c" dependencies = [ "proc-macro2", "quote", - "syn 2.0.29", + "syn 2.0.31", ] [[package]] @@ -2726,9 +2810,9 @@ checksum = "ff011a302c396a5197692431fc1948019154afc178baf7d8e37367442a4601cf" [[package]] name = "openssl-sys" -version = "0.9.91" +version = "0.9.93" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "866b5f16f90776b9bb8dc1e1802ac6f0513de3a7a7465867bfbc563dc737faac" +checksum = "db4d56a4c0478783083cfafcc42493dd4a981d41669da64b4572a2a089b51b1d" dependencies = [ "cc", "libc", @@ -2859,9 +2943,9 @@ dependencies = [ [[package]] name = "pin-project-lite" -version = "0.2.12" +version = "0.2.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "12cc1b0bf1727a77a54b6654e7b5f1af8604923edc8b81885f8ec92f9e3f0a05" +checksum = "8afb450f006bf6385ca15ef45d71d2288452bc3683ce2e2cacc0d18e4be60b58" [[package]] name = "pin-utils" @@ -2901,12 +2985,28 @@ dependencies = [ "spki 0.6.0", ] +[[package]] +name = "pkcs8" +version = "0.10.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f950b2377845cebe5cf8b5165cb3cc1a5e0fa5cfa3e1f7f55707d8fd82e0a7b7" +dependencies = [ + "der 0.7.8", + "spki 0.7.2", +] + [[package]] name = "pkg-config" version = "0.3.27" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "26072860ba924cbfa98ea39c8c19b4dd6a4a25423dbdf219c1eca91aa0cf6964" +[[package]] +name = "platforms" +version = "3.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4503fa043bf02cee09a9582e9554b4c6403b2ef55e4612e96561d294419429f8" + [[package]] name = "polling" version = "2.8.0" @@ -3231,14 +3331,14 @@ dependencies = [ [[package]] name = "regex" -version = "1.9.3" +version = "1.9.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "81bc1d4caf89fac26a70747fe603c130093b53c773888797a6329091246d651a" +checksum = "697061221ea1b4a94a624f67d0ae2bfe4e22b8a17b6a192afb11046542cc8c47" dependencies = [ "aho-corasick", "memchr", - "regex-automata 0.3.6", - "regex-syntax 0.7.4", + "regex-automata 0.3.8", + "regex-syntax 0.7.5", ] [[package]] @@ -3252,13 +3352,13 @@ dependencies = [ [[package]] name = "regex-automata" -version = "0.3.6" +version = "0.3.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fed1ceff11a1dddaee50c9dc8e4938bd106e9d89ae372f192311e7da498e3b69" +checksum = "c2f401f4955220693b56f8ec66ee9c78abffd8d1c4f23dc41a23839eb88f0795" dependencies = [ "aho-corasick", "memchr", - "regex-syntax 0.7.4", + "regex-syntax 0.7.5", ] [[package]] @@ -3269,17 +3369,17 @@ checksum = "f162c6dd7b008981e4d40210aca20b4bd0f9b60ca9271061b07f78537722f2e1" [[package]] name = "regex-syntax" -version = "0.7.4" +version = "0.7.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e5ea92a5b6195c6ef2a0295ea818b312502c6fc94dde986c5553242e18fd4ce2" +checksum = "dbb5fb1acd8a1a18b3dd5be62d25485eb770e05afb408a9627d14d451bae12da" [[package]] name = "reqwest" -version = "0.11.18" +version = "0.11.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cde824a14b7c14f85caff81225f411faacc04a2013f41670f41443742b1c1c55" +checksum = "3e9ad3fe7488d7e34558a2033d45a0c90b72d97b4f80705666fea71472e2e6a1" dependencies = [ - "base64 0.21.2", + "base64 0.21.3", "bytes 1.4.0", "encoding_rs", "futures-core", @@ -3372,28 +3472,21 @@ dependencies = [ "zeroize", ] -[[package]] -name = "rust-ceramic-migration-tests" -version = "0.1.0" -dependencies = [ - "ceramic-api-server", - "ceramic-http-client", - "ceramic-kubo-rpc-server", - "dotenvy", - "hyper", - "swagger", - "tokio", - "tracing", - "tracing-test", - "url", -] - [[package]] name = "rustc-demangle" version = "0.1.23" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d626bb9dae77e28219937af045c257c28bfd3f69333c512553507f5f9798cb76" +[[package]] +name = "rustc_version" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bfa0f585226d2e68097d4f95d113b15b83a82e819ab25717ec0590d9584ef366" +dependencies = [ + "semver", +] + [[package]] name = "rustix" version = "0.37.23" @@ -3410,9 +3503,9 @@ dependencies = [ [[package]] name = "rustix" -version = "0.38.8" +version = "0.38.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "19ed4fa021d81c8392ce04db050a3da9a60299050b7ae1cf482d862b54a7218f" +checksum = "c0c3dde1fc030af041adc40e79c0e7fbcf431dd24870053d187d7c66e4b87453" dependencies = [ "bitflags 2.4.0", "errno", @@ -3423,9 +3516,9 @@ dependencies = [ [[package]] name = "rustls" -version = "0.21.6" +version = "0.21.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1d1feddffcfcc0b33f5c6ce9a29e341e4cd59c3f78e7ee45f4a40c038b1d6cbb" +checksum = "cd8d6c9f025a446bc4d18ad9632e69aec8f287aa84499ee335599fabd20c3fd8" dependencies = [ "log 0.4.20", "ring", @@ -3439,14 +3532,14 @@ version = "1.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2d3987094b1d07b653b7dfdc3f70ce9a1da9c51ac18c1b06b662e4f9a0e9f4b2" dependencies = [ - "base64 0.21.2", + "base64 0.21.3", ] [[package]] name = "rustls-webpki" -version = "0.101.3" +version = "0.101.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "261e9e0888cba427c3316e6322805653c9425240b6fd96cee7cb671ab70ab8d0" +checksum = "7d93931baf2d282fff8d3a532bbfd7653f734643161b87e3e01e59a04439bf0d" dependencies = [ "ring", "untrusted", @@ -3487,9 +3580,9 @@ dependencies = [ [[package]] name = "schemars" -version = "0.8.12" +version = "0.8.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "02c613288622e5f0c3fdc5dbd4db1c5fbe752746b1d1a56a0630b78fd00de44f" +checksum = "763f8cd0d4c71ed8389c90cb8100cba87e763bd01a8e614d4f0af97bcd50a161" dependencies = [ "dyn-clone", "schemars_derive", @@ -3499,9 +3592,9 @@ dependencies = [ [[package]] name = "schemars_derive" -version = "0.8.12" +version = "0.8.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "109da1e6b197438deb6db99952990c7f959572794b80ff93707d55a232545e7c" +checksum = "ec0f696e21e10fa546b7ffb1c9672c6de8fbc7a81acf59524386d8639bf12737" dependencies = [ "proc-macro2", "quote", @@ -3562,11 +3655,17 @@ dependencies = [ "libc", ] +[[package]] +name = "semver" +version = "1.0.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b0293b4b29daaf487284529cc2f5675b8e57c61f70167ba415a463651fd6a918" + [[package]] name = "serde" -version = "1.0.171" +version = "1.0.188" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "30e27d1e4fd7659406c492fd6cfaf2066ba8773de45ca75e855590f856dc34a9" +checksum = "cf9e0fcba69a370eed61bcf2b728575f726b50b55cba78064753d708ddc7549e" dependencies = [ "serde_derive", ] @@ -3591,13 +3690,13 @@ dependencies = [ [[package]] name = "serde_derive" -version = "1.0.171" +version = "1.0.188" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "389894603bd18c46fa56231694f8d827779c0951a667087194cf9de94ed24682" +checksum = "4eca7ac642d82aa35b60049a6eccb4be6be75e599bd2e9adb5f875a737654af2" dependencies = [ "proc-macro2", "quote", - "syn 2.0.29", + "syn 2.0.31", ] [[package]] @@ -3690,7 +3789,7 @@ dependencies = [ "serde", "serde_json", "serde_with_macros 2.3.3", - "time 0.3.26", + "time 0.3.28", ] [[package]] @@ -3714,7 +3813,7 @@ dependencies = [ "darling 0.20.3", "proc-macro2", "quote", - "syn 2.0.29", + "syn 2.0.31", ] [[package]] @@ -3782,6 +3881,12 @@ dependencies = [ "rand_core 0.6.4", ] +[[package]] +name = "signature" +version = "2.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5e1788eed21689f9cf370582dfc467ef36ed9c707f073528ddafa8d83e3b8500" + [[package]] name = "simple_asn1" version = "0.5.4" @@ -3813,7 +3918,7 @@ dependencies = [ "rand 0.8.5", "sha3", "thiserror", - "time 0.3.26", + "time 0.3.28", ] [[package]] @@ -3832,9 +3937,9 @@ dependencies = [ [[package]] name = "slab" -version = "0.4.8" +version = "0.4.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6528351c9bc8ab22353f9d776db39a20288e8d6c37ef8cfe3317cf875eecfc2d" +checksum = "8f92a496fb766b417c996b9c5e57daf2f7ad3b0bebe1ccfca4856390e3d3bb67" dependencies = [ "autocfg 1.1.0", ] @@ -3906,6 +4011,16 @@ dependencies = [ "der 0.6.1", ] +[[package]] +name = "spki" +version = "0.7.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9d1e996ef02c474957d681f1b05213dfb0abab947b446a62d37770b23500184a" +dependencies = [ + "base64ct", + "der 0.7.8", +] + [[package]] name = "sshkeys" version = "0.3.2" @@ -4061,7 +4176,7 @@ dependencies = [ "base64 0.12.3", "blake2b_simd 0.5.11", "bs58", - "ed25519-dalek", + "ed25519-dalek 1.0.1", "getrandom 0.2.10", "k256", "lazy_static", @@ -4090,7 +4205,7 @@ dependencies = [ "base64 0.12.3", "blake2", "clear_on_drop", - "ed25519-dalek", + "ed25519-dalek 1.0.1", "k256", "p256", "rand 0.8.5", @@ -4209,7 +4324,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c1b57d919e20d214253a9a8dbc5f3b08ff555364934d99a09c828becab27a823" dependencies = [ "bs58", - "ed25519-dalek", + "ed25519-dalek 1.0.1", "ssi-jwk", "ssi-jws", "thiserror", @@ -4347,9 +4462,9 @@ checksum = "81cdd64d312baedb58e21336b31bc043b77e01cc99033ce76ef539f78e965ebc" [[package]] name = "swagger" -version = "6.3.0" +version = "6.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6fbc05d7c4952357d7a0e69884942c84df3d0990c56768cc019869e9af6a4019" +checksum = "6f5c24057cf0e1c1a88fb2a12d19fe6e7ea6a24b74775352224a9718a8e9eb43" dependencies = [ "base64 0.13.1", "futures", @@ -4379,9 +4494,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.29" +version = "2.0.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c324c494eba9d92503e6f1ef2e6df781e78f6a7705a0202d9801b198807d518a" +checksum = "718fa2415bcb8d8bd775917a1bf12a7931b6dfa890753378538118181e0cb398" dependencies = [ "proc-macro2", "quote", @@ -4415,28 +4530,28 @@ dependencies = [ "cfg-if", "fastrand 2.0.0", "redox_syscall", - "rustix 0.38.8", + "rustix 0.38.11", "windows-sys", ] [[package]] name = "thiserror" -version = "1.0.47" +version = "1.0.48" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "97a802ec30afc17eee47b2855fc72e0c4cd62be9b4efe6591edde0ec5bd68d8f" +checksum = "9d6d7a740b8a666a7e828dd00da9c0dc290dff53154ea77ac109281de90589b7" dependencies = [ "thiserror-impl", ] [[package]] name = "thiserror-impl" -version = "1.0.47" +version = "1.0.48" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6bb623b56e39ab7dcd4b1b98bb6c8f8d907ed255b18de254088016b27a8ee19b" +checksum = "49922ecae66cc8a249b77e68d1d0623c1b2c514f0060c27cdc68bd62a1219d35" dependencies = [ "proc-macro2", "quote", - "syn 2.0.29", + "syn 2.0.31", ] [[package]] @@ -4462,9 +4577,9 @@ dependencies = [ [[package]] name = "time" -version = "0.3.26" +version = "0.3.28" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a79d09ac6b08c1ab3906a2f7cc2e81a0e27c7ae89c63812df75e52bef0751e07" +checksum = "17f6bb557fd245c28e6411aa56b6403c689ad95061f50e4be16c274e70a17e48" dependencies = [ "deranged", "itoa", @@ -4481,9 +4596,9 @@ checksum = "7300fbefb4dadc1af235a9cef3737cea692a9d97e1b9cbcd4ebdae6f8868e6fb" [[package]] name = "time-macros" -version = "0.2.12" +version = "0.2.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "75c65469ed6b3a4809d987a41eb1dc918e9bc1d92211cbad7ae82931846f7451" +checksum = "1a942f44339478ef67935ab2bbaec2fb0322496cf3cbe84b261e06ac3814c572" dependencies = [ "time-core", ] @@ -4537,7 +4652,7 @@ checksum = "630bdcf245f78637c13ec01ffae6187cca34625e8c63150d424b59e55af2675e" dependencies = [ "proc-macro2", "quote", - "syn 2.0.29", + "syn 2.0.31", ] [[package]] @@ -4635,7 +4750,7 @@ checksum = "5f4f31f56159e98206da9efd823404b79b6ef3143b4a7ab76e67b1751b25a4ab" dependencies = [ "proc-macro2", "quote", - "syn 2.0.29", + "syn 2.0.31", ] [[package]] @@ -4789,9 +4904,9 @@ checksum = "f962df74c8c05a667b5ee8bcf162993134c104e96440b663c8daa176dc772d8c" [[package]] name = "unsigned-varint" -version = "0.7.1" +version = "0.7.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d86a8dc7f45e4c1b0d30e43038c38f274e77af056aa5f74b93c2cf9eb3c1c836" +checksum = "6889a77d49f1f013504cec6bf97a2c730394adedaeb1deb5ea08949a50541105" [[package]] name = "untrusted" @@ -4801,9 +4916,9 @@ checksum = "a156c684c91ea7d62626509bce3cb4e1d9ed5c4d978f7b4352658f96a4c26b4a" [[package]] name = "url" -version = "2.4.0" +version = "2.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "50bff7831e19200a85b17131d085c25d7811bc4e186efdaf54bbd132994a88cb" +checksum = "143b538f18257fac9cad154828a57c6bf5157e1aa604d4816b5995bf6de87ae5" dependencies = [ "form_urlencoded", "idna", @@ -4910,7 +5025,7 @@ dependencies = [ "once_cell", "proc-macro2", "quote", - "syn 2.0.29", + "syn 2.0.31", "wasm-bindgen-shared", ] @@ -4944,7 +5059,7 @@ checksum = "54681b18a46765f095758388f2d0cf16eb8d4169b639ab575a8f5693af210c7b" dependencies = [ "proc-macro2", "quote", - "syn 2.0.29", + "syn 2.0.31", "wasm-bindgen-backend", "wasm-bindgen-shared", ] @@ -4965,24 +5080,11 @@ dependencies = [ "wasm-bindgen", ] -[[package]] -name = "webpki" -version = "0.22.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f095d78192e208183081cc07bc5515ef55216397af48b873e5edcd72637fa1bd" -dependencies = [ - "ring", - "untrusted", -] - [[package]] name = "webpki-roots" -version = "0.22.6" +version = "0.25.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b6c71e40d7d2c34a5106301fb632274ca37242cd0c9d3e64dbece371a40a2d87" -dependencies = [ - "webpki", -] +checksum = "14247bb57be4f377dfb94c72830b8ce8fc6beac03cf4bf7b9732eadd414123fc" [[package]] name = "winapi" @@ -5083,20 +5185,21 @@ checksum = "ed94fce61571a4006852b7389a063ab983c02eb1bb37b47f8272ce92d06d9538" [[package]] name = "winnow" -version = "0.5.14" +version = "0.5.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d09770118a7eb1ccaf4a594a221334119a44a814fcb0d31c5b85e83e97227a97" +checksum = "7c2e3184b9c4e92ad5167ca73039d0c42476302ab603e2fec4487511f38ccefc" dependencies = [ "memchr", ] [[package]] name = "winreg" -version = "0.10.1" +version = "0.50.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "80d0f4e272c85def139476380b12f9ac60926689dd2e01d4923222f40580869d" +checksum = "524e57b2c537c0f9b1e69f1965311ec12182b4122e45035b1508cd24d2adadb1" dependencies = [ - "winapi", + "cfg-if", + "windows-sys", ] [[package]] @@ -5122,5 +5225,5 @@ checksum = "ce36e65b0d2999d2aafac989fb249189a141aee1f53c612c1f37d72631959f69" dependencies = [ "proc-macro2", "quote", - "syn 2.0.29", + "syn 2.0.31", ] diff --git a/Cargo.toml b/Cargo.toml index 90253542..187f5da3 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,5 +1,5 @@ [package] -name = "rust-ceramic-migration-tests" +name = "ceramic-tests" version = "0.1.0" edition = "2021" @@ -28,3 +28,6 @@ hyper = { version = "0.14.27", features = ["client"] } #[patch."https://github.com/3box/rust-ceramic"] #ceramic-api-server = { path = "../rust-ceramic/api-server" } #ceramic-kubo-rpc-server = { path = "../rust-ceramic/kubo-rpc-server" } + +#[patch."https://github.com/3box/ceramic-http-client-rs"] +#ceramic-http-client = { path = "../ceramic-http-client-rs" } diff --git a/Dockerfile b/Dockerfile index 6480a22f..a1dabd4c 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,7 +1,7 @@ FROM public.ecr.aws/r5b3e0r5/3box/rust-builder:latest as builder -RUN mkdir -p /home/builder/rust-ceramic-migration-tests -WORKDIR /home/builder/rust-ceramic-migration-tests +RUN mkdir -p /home/builder/ceramic-tests +WORKDIR /home/builder/ceramic-tests # Use the same ids as the parent docker image by default ARG UID=1001 @@ -17,14 +17,14 @@ COPY . . # To clear the cache use: # docker builder prune --filter type=exec.cachemount RUN --mount=type=cache,target=/home/builder/.cargo,uid=$UID,gid=$GID \ - --mount=type=cache,target=/home/builder/rust-ceramic-migration-tests/target,uid=$UID,gid=$GID \ + --mount=type=cache,target=/home/builder/ceramic-tests/target,uid=$UID,gid=$GID \ make $BUILD_MODE FROM ubuntu:latest as tester -COPY --from=builder /home/builder/rust-ceramic-migration-tests/env/.env /usr/bin/.env -COPY --from=builder /home/builder/rust-ceramic-migration-tests/test-binaries /test-binaries -COPY --from=builder /home/builder/rust-ceramic-migration-tests/entrypoint.sh /usr/bin/entrypoint.sh +COPY --from=builder /home/builder/ceramic-tests/env/.env /usr/bin/.env +COPY --from=builder /home/builder/ceramic-tests/test-binaries /test-binaries +COPY --from=builder /home/builder/ceramic-tests/entrypoint.sh /usr/bin/entrypoint.sh ENV RUST_BACKTRACE=1 ENV ENV_PATH="/usr/bin/.env" diff --git a/ci-scripts/publish.sh b/ci-scripts/publish.sh index 05066b3f..3c689855 100755 --- a/ci-scripts/publish.sh +++ b/ci-scripts/publish.sh @@ -10,6 +10,6 @@ # # to login to docker. That password will be valid for 12h. -docker buildx build --load -t 3box/rust-ceramic-migration-tests . -docker tag 3box/rust-ceramic-migration-tests:latest public.ecr.aws/r5b3e0r5/3box/rust-ceramic-migration-tests:latest -docker push public.ecr.aws/r5b3e0r5/3box/rust-ceramic-migration-tests:latest +docker buildx build --load -t 3box/ceramic-tests . +docker tag 3box/ceramic-tests:latest public.ecr.aws/r5b3e0r5/3box/ceramic-tests:latest +docker push public.ecr.aws/r5b3e0r5/3box/ceramic-tests:latest diff --git a/k8s/networks/basic-go-rust.yaml b/k8s/networks/basic-go-rust.yaml new file mode 100644 index 00000000..177a6fac --- /dev/null +++ b/k8s/networks/basic-go-rust.yaml @@ -0,0 +1,12 @@ +--- +apiVersion: "keramik.3box.io/v1alpha1" +kind: Network +metadata: + name: basic-go-rust +spec: + replicas: 2 + ceramic: + - ipfs: + go: {} + - ipfs: + rust: {} diff --git a/k8s/networks/basic-go.yaml b/k8s/networks/basic-go.yaml new file mode 100644 index 00000000..358b082e --- /dev/null +++ b/k8s/networks/basic-go.yaml @@ -0,0 +1,10 @@ +--- +apiVersion: "keramik.3box.io/v1alpha1" +kind: Network +metadata: + name: basic-go +spec: + replicas: 2 + ceramic: + - ipfs: + go: {} diff --git a/k8s/networks/basic-rust.yaml b/k8s/networks/basic-rust.yaml new file mode 100644 index 00000000..810fa110 --- /dev/null +++ b/k8s/networks/basic-rust.yaml @@ -0,0 +1,10 @@ +--- +apiVersion: "keramik.3box.io/v1alpha1" +kind: Network +metadata: + name: basic-rust +spec: + replicas: 2 + ceramic: + - ipfs: + rust: {} diff --git a/k8s/tests/manifests/prop.yaml b/k8s/tests/manifests/prop.yaml new file mode 100644 index 00000000..e4a9b90b --- /dev/null +++ b/k8s/tests/manifests/prop.yaml @@ -0,0 +1,64 @@ +# Property-based test configuration +--- +kind: Job +apiVersion: batch/v1 +metadata: + name: tests +spec: + backoffLimit: 0 + template: + spec: + serviceAccountName: tests-sa + initContainers: + - name: init-tests + image: stedolan/jq + command: + - "/bin/bash" + - "-c" + - "/network/process-peers.sh" + volumeMounts: + - name: process-peers + mountPath: /network + - name: peers-volume + mountPath: /peers + - name: config-volume + mountPath: /config + envFrom: + - configMapRef: + name: keramik-peers + env: + - name: NAMESPACE + valueFrom: + fieldRef: + fieldPath: metadata.namespace + restartPolicy: Never + containers: + - name: tests + image: public.ecr.aws/r5b3e0r5/3box/ceramic-tests + imagePullPolicy: Always + resources: + limits: + cpu: 250m + ephemeral-storage: 1Gi + memory: 1Gi + requests: + cpu: 250m + ephemeral-storage: 1Gi + memory: 1Gi + volumeMounts: + - name: config-volume + mountPath: /config + env: + - name: ENV_PATH + value: "/config/.env" + volumes: + - name: process-peers + configMap: + name: process-peers + defaultMode: + 0755 + - name: peers-volume + configMap: + name: keramik-peers + - name: config-volume + emptyDir: {} diff --git a/k8s/tests/manifests/setup.yaml b/k8s/tests/manifests/setup.yaml new file mode 100644 index 00000000..42df15d5 --- /dev/null +++ b/k8s/tests/manifests/setup.yaml @@ -0,0 +1,31 @@ +--- +apiVersion: v1 +kind: ServiceAccount +metadata: + name: tests-sa + namespace: keramik-tests +automountServiceAccountToken: true +--- +kind: ClusterRole +apiVersion: rbac.authorization.k8s.io/v1 +metadata: + name: tests-cr + namespace: keramik-tests +rules: + - apiGroups: ["keramik.3box.io"] + resources: ["networks/status"] + verbs: ["get"] +--- +kind: ClusterRoleBinding +apiVersion: rbac.authorization.k8s.io/v1 +metadata: + name: tests-crb + namespace: keramik-tests +subjects: + - kind: ServiceAccount + name: tests-sa + namespace: keramik-tests +roleRef: + kind: ClusterRole + name: tests-cr + apiGroup: rbac.authorization.k8s.io diff --git a/k8s/tests/manifests/smoke.yaml b/k8s/tests/manifests/smoke.yaml new file mode 100644 index 00000000..e386328e --- /dev/null +++ b/k8s/tests/manifests/smoke.yaml @@ -0,0 +1,146 @@ +# Localstack configuration +--- +kind: StatefulSet +apiVersion: apps/v1 +metadata: + name: test-db + labels: + app: test-db +spec: + replicas: 1 + serviceName: test-db + selector: + matchLabels: + app: test-db + template: + metadata: + labels: + app: test-db + spec: + containers: + - name: localstack + image: localstack/localstack + resources: + limits: + cpu: 500m + ephemeral-storage: 512Mi + memory: 1Gi + requests: + cpu: 500m + ephemeral-storage: 512Mi + memory: 1Gi + ports: + - containerPort: 4566 + readinessProbe: + initialDelaySeconds: 0 + periodSeconds: 30 + timeoutSeconds: 30 + exec: + command: + - "bash" + - "-c" + - "awslocal dynamodb list-tables && awslocal es list-domain-names && awslocal s3 ls && awslocal sqs list-queues" + volumeMounts: + - name: test-data + mountPath: /tmp/localstack + volumes: + - name: test-data + persistentVolumeClaim: + claimName: test-data + volumeClaimTemplates: + - metadata: + name: test-data + spec: + accessModes: [ "ReadWriteOnce" ] + resources: + requests: + storage: 1Gi +--- +kind: Service +apiVersion: v1 +metadata: + name: test-db + labels: + app: test-db +spec: + ports: + - port: 4566 + targetPort: 4566 + protocol: TCP + name: test-db + selector: + app: test-db + type: NodePort + +# Smoke test configuration +--- +kind: Job +apiVersion: batch/v1 +metadata: + name: tests +spec: + backoffLimit: 0 + template: + spec: + serviceAccountName: tests-sa + initContainers: + - name: init-tests + image: stedolan/jq + command: + - "/bin/bash" + - "-c" + - "/network/process-peers.sh" + volumeMounts: + - name: process-peers + mountPath: /network + - name: peers-volume + mountPath: /peers + - name: config-volume + mountPath: /config + envFrom: + - configMapRef: + name: keramik-peers + env: + - name: NAMESPACE + valueFrom: + fieldRef: + fieldPath: metadata.namespace + restartPolicy: Never + containers: + - name: tests + image: public.ecr.aws/r5b3e0r5/3box/ceramic-smoke-tests + imagePullPolicy: Always + resources: + limits: + cpu: 250m + ephemeral-storage: 1Gi + memory: 1Gi + requests: + cpu: 250m + ephemeral-storage: 1Gi + memory: 1Gi + volumeMounts: + - name: config-volume + mountPath: /config + env: + - name: ENV_PATH + value: "/config/.env" + - name: AWS_ACCESS_KEY_ID + value: "." + - name: AWS_SECRET_ACCESS_KEY + value: "." + - name: DB_ENDPOINT + value: "http://test-db:4566" + - name: JEST_ARGS + value: "--reporters=default --detectOpenHandles" + volumes: + - name: process-peers + configMap: + name: process-peers + defaultMode: + 0755 + - name: peers-volume + configMap: + name: keramik-peers + - name: config-volume + emptyDir: {} diff --git a/k8s/tests/scripts/check-network.sh b/k8s/tests/scripts/check-network.sh new file mode 100755 index 00000000..6d20dc32 --- /dev/null +++ b/k8s/tests/scripts/check-network.sh @@ -0,0 +1,33 @@ +#!/bin/bash + +# Proxy to the k8s API +kubectl proxy --port=8080 >/dev/null 2>/dev/null & +sleep 3 + +status() { + curl -s "http://localhost:8080/apis/keramik.3box.io/v1alpha1/networks/${NAMESPACE/#keramik-}/status" +} + +check_status() { + status | jq -r 'if (.status != "Failure") and (.status.readyReplicas == .status.replicas) then true else false end' +} + +check_network() { + # Wait for 10 minutes, or till the network is ready. + n=0 + until [ "$n" -ge 60 ]; + do + if [ "$(check_status)" == "true" ]; then + echo Network ready + exit 0 + else + sleep 10 + n=$((n+1)) + fi + done + + echo Network failed to start + exit 1 +} + +check_network diff --git a/k8s/tests/scripts/delete-tests.sh b/k8s/tests/scripts/delete-tests.sh new file mode 100755 index 00000000..f3bdb4b4 --- /dev/null +++ b/k8s/tests/scripts/delete-tests.sh @@ -0,0 +1,31 @@ +#!/bin/bash + +if [[ -n $2 ]]; then + test_type="$2" +else + test_type="prop" +fi + +case "$test_type" in + prop|smoke) + ;; + + *) + echo "usage: $0 {network} {prop|smoke}" + ;; +esac + +# Delete the tests job +yq " + .metadata.name* = \"keramik-$test_type-$1$TEST_SUFFIX\" | + (select(.subjects[] | length) | .subjects[0].name*) = \"keramik-$test_type-$1$TEST_SUFFIX\" | + (select(.roleRef) | .roleRef.name) = \"keramik-$test_type-$1$TEST_SUFFIX\" +" ../manifests/setup.yaml | kubectl delete -f - >/dev/null + +# Delete the test network +yq " + .metadata.name = \"$test_type-$1$TEST_SUFFIX\" +" ../../networks/"$1".yaml | kubectl delete -f - >/dev/null + +# Wait for namespace to get deleted +kubectl wait --for=delete namespace/"keramik-$test_type-$1$TEST_SUFFIX" --timeout=10m >/dev/null diff --git a/k8s/tests/scripts/process-peers.sh b/k8s/tests/scripts/process-peers.sh new file mode 100644 index 00000000..f51e7ec2 --- /dev/null +++ b/k8s/tests/scripts/process-peers.sh @@ -0,0 +1,30 @@ +#!/bin/bash + +available_peers() { + jq -r '. | length' < /peers/peers.json +} + +# Wait for 5 minutes, or till the peers are available. +n=0 +until [ "$n" -ge 30 ]; + do + if [ "$(available_peers)" == "0" ]; then + sleep 10 + n=$((n+1)) + else + mkdir /config/env + + CERAMIC_URLS=$(jq -j '[.[].ceramic.ipfsRpcAddr | select(.)] | join(",")' < /peers/peers.json) + COMPOSEDB_URLS=$(jq -j '[.[].ceramic.ceramicAddr | select(.)] | join(",")' < /peers/peers.json) + + echo "CERAMIC_URLS=$CERAMIC_URLS" > /config/.env + echo "COMPOSEDB_URLS=$COMPOSEDB_URLS" >> /config/.env + + echo "Populated env" + cat /config/.env + + exit 0 + fi +done + +exit 1 diff --git a/k8s/tests/scripts/run-tests.sh b/k8s/tests/scripts/run-tests.sh new file mode 100755 index 00000000..3cb3e16e --- /dev/null +++ b/k8s/tests/scripts/run-tests.sh @@ -0,0 +1,62 @@ +#!/bin/bash + +if [[ -n $2 ]]; then + test_type="$2" +else + test_type="prop" +fi + +case "$test_type" in + prop|smoke) + ;; + + *) + echo "usage: $0 {network} {prop|smoke}" + ;; +esac + +# Create namespace and setup RBAC +kubectl create namespace "keramik-$test_type-$1$TEST_SUFFIX" >/dev/null 2>/dev/null +yq " + .metadata.name* = \"keramik-$test_type-$1$TEST_SUFFIX\" | + (select(.subjects[] | length) | .subjects[0].name*) = \"keramik-$test_type-$1$TEST_SUFFIX\" | + (select(.roleRef) | .roleRef.name) = \"keramik-$test_type-$1$TEST_SUFFIX\" +" ../manifests/setup.yaml | kubectl apply -f - >/dev/null + +# Create the network. +kubectl create configmap process-peers --from-file=process-peers.sh -n "keramik-$test_type-$1$TEST_SUFFIX" >/dev/null 2>/dev/null +yq " + .metadata.name = \"$test_type-$1$TEST_SUFFIX\" +" ../../networks/"$1".yaml | kubectl apply -f - >/dev/null + +# Wait for the network to be up +if ! NAMESPACE="keramik-$test_type-$1$TEST_SUFFIX" ./check-network.sh +then + exit 1 +fi + +# Delete and recreate the test job so that tests are rerun even if they've been run against this network in the past +kubectl delete -n "keramik-$test_type-$1$TEST_SUFFIX" job/tests >/dev/null 2>/dev/null +yq " + (select(.kind == \"Job\") | .spec.template.spec.serviceAccountName) = \"keramik-$test_type-$1$TEST_SUFFIX\" +" ../manifests/"$test_type".yaml | + kubectl apply -n "keramik-$test_type-$1$TEST_SUFFIX" -f - >/dev/null + +# Wait for tests to complete then collect the results +while true; do + if kubectl wait --for=condition=complete --timeout=0 job/tests -n "keramik-$test_type-$1$TEST_SUFFIX" >/dev/null 2>/dev/null; then + job_result=0 + break + fi + if kubectl wait --for=condition=failed --timeout=0 job/tests -n "keramik-$test_type-$1$TEST_SUFFIX" >/dev/null 2>/dev/null; then + job_result=1 + break + fi + sleep 3 +done + +kubectl logs job.batch/tests -c tests -n "keramik-$test_type-$1$TEST_SUFFIX" + +if [[ $job_result -eq 1 ]]; then + exit 1 +fi diff --git a/tests/api.rs b/tests/api.rs index 24c5d0e3..b00894fa 100644 --- a/tests/api.rs +++ b/tests/api.rs @@ -12,7 +12,7 @@ use tokio::sync::OnceCell; use tracing_test::traced_test; use url::Url; -use rust_ceramic_migration_tests::ceramic::{composedb_client, ComposeDbClient}; +use ceramic_tests::ceramic::{composedb_client, ComposeDbClient}; const CERAMIC_URLS: &str = "CERAMIC_URLS"; const COMPOSEDB_URLS: &str = "COMPOSEDB_URLS"; @@ -113,6 +113,7 @@ async fn get_ceramic_clients() -> &'static Vec { }) .await } + async fn get_kubo_rpc_clients() -> &'static Vec { KUBO_RPC_CLIENTS .get_or_init(|| async { @@ -146,7 +147,7 @@ async fn get_kubo_rpc_clients() -> &'static Vec { #[tokio::test] #[traced_test] -async fn hello_composedb() { +async fn composedb_hello() { let composedb_clients = get_composedb_clients().await; for (idx, client) in composedb_clients.iter().enumerate() { println!( @@ -159,29 +160,19 @@ async fn hello_composedb() { #[tokio::test] #[traced_test] -async fn hello_ceramic() { +#[ignore] +async fn ceramic_hello() { let ceramic_clients = get_ceramic_clients().await; assert!(!ceramic_clients.is_empty()); for c in ceramic_clients { - // TODO(nathanielc): change this to a version call once https://github.com/3box/rust-ceramic/pull/83 - // merges - let _ = c - .subscribe_sort_key_sort_value_get( - "model".to_string(), - "sort_value".to_string(), - None, - None, - None, - None, - ) - .await - .unwrap(); + let version = c.version_post().await.unwrap(); + println!("{version:?}"); } } #[tokio::test] #[traced_test] -async fn hello_kubo_rpc() { +async fn kubo_rpc_hello() { let kubo_rpc_clients = get_kubo_rpc_clients().await; assert!(!kubo_rpc_clients.is_empty()); for c in kubo_rpc_clients {