Skip to content

Commit

Permalink
enterprise blobber allocation tests. (#1094)
Browse files Browse the repository at this point in the history
* go mod tidy

* Restricted blobber tests

* Changed repo snapshots

* Skipped authorizer tests

* add owner api calls (#1047)

* add owner api calls

* fix referral tests

* fix fcm, wallet tests

* fix shareinfo

* fix referral leaderboard, response messages

* fix lint

* fix lint

* Added feature blobber auth tests

* Fix API tests create allocation

* Updated gosdk

* Updated gosdk

* Fix

* Fix

* Fix blobber config update test =

* Fix blobber config update cleanup

* Fix

* Hotfix/0box (#1049)

* update headers

* remove phone header dependent tests

* fix lint

* Updated gosdk

* fix commit err message (#1052)

* fix commit err message

* change err msg

* Fix

* Fix

* Fix

* Fix

* Fix

* Fix

* Fix lint

* Fix

* tests to list stakable providers (#1036)

* tests to list stakable providers

* fix list miner and sharder

* apply gofmt

* fix getblobbers function parameter

* update gosdk version

* Update lint version to v1.57.1 ci.yml

* Update go version in lint job

* Updated gosdk

---------

Co-authored-by: shahnawaz-creator <[email protected]>
Co-authored-by: Jayash Satolia <[email protected]>

* Fix 0box tests with create allocation

* fix 0box tests

* Empty commit

* Fix restricted blobber tests

* Update gosdk

* Fix sharder config update

* fix delete wallet (#1057)

* Fixed file format and restricted blobbers test

* Fix resume upload

* Fix restricted blobbers

* fix resume download test (#1058)

* Fix restricted blobbers

* Fix restricted blobbers

* Fix restricted blobbers

* added repair allocation with diff file size (#1034)

* added repair allocation for diff file size

* added repair allocation for diff file size

* added repair allocation for diff file size

* added repair allocation for diff file size

* added repair allocation for diff file size

* added repair allocation for diff file size

* added repair allocation for diff file size

* added repair allocation for diff file size

* added TC

* added TC

* added TC

* added TC

* added TC

* updated timeout to 60 mins

* updated timeout to 60 mins

* updated pricing plan fetch for non-rzp org IDs

* added TC with nested folder

* added TC with nested folder

* added TC with nested folder

* added TC with nested folder

* added TC with nested folder

* added TC with nested folder

* added TC with nested folder

* fixed to current sprint branch in tokenomics_ci.yml

* Fix current branch for challenge nightly tests workflow

* Fix current branch for tokenomics nightly tests workflow

* Fix current branch for tokenomics nightly tests workflow

---------

Co-authored-by: Jayash Satolia <[email protected]>
Co-authored-by: shahnawaz-creator <[email protected]>
Co-authored-by: Jayash Satolia <[email protected]>

* added test suite for dropbox

* test suite for gdrive

* updated for workflow

* lint fix

* changes for dropbox tests

* Fix: Issue previous test cases

* Added lib

* disable lint

* Test for mc and zs3server

* * Test cases for mc commands and warp benchmarking tool

* Test Cases Formatted

* updated comment

* Added changes

* updated readme

* Added binary for mc

* re

* updated for mc

* Warp

* Added minio

* Updated for mc_wrap_test_cases

* updated dir config

* lint fix

* updated cli

* Fix failing testcases for PR #1043 (#1077)

* Initial TC suite #987

* go mod tidy

* Restricted blobber tests

* Changed repo snapshots

* duplicate file name tc rollback allocation

* Skipped authorizer tests

* Multiple update and delete

* updated multi-file upload tests

* Interruped file upload

* add owner api calls (#1047)

* add owner api calls

* fix referral tests

* fix fcm, wallet tests

* fix shareinfo

* fix referral leaderboard, response messages

* fix lint

* fix lint

* Added feature blobber auth tests

* Fix API tests create allocation

* Updated gosdk

* Updated gosdk

* Fix

* Fix

* Fix blobber config update test =

* Fix blobber config update cleanup

* Fix

* Hotfix/0box (#1049)

* update headers

* remove phone header dependent tests

* fix lint

* Updated gosdk

* fix commit err message (#1052)

* fix commit err message

* change err msg

* Fix

* Fix

* Fix

* Fix

* Fix

* Fix

* Fix lint

* Fix

* tests to list stakable providers (#1036)

* tests to list stakable providers

* fix list miner and sharder

* apply gofmt

* fix getblobbers function parameter

* update gosdk version

* Update lint version to v1.57.1 ci.yml

* Update go version in lint job

* Updated gosdk

---------

Co-authored-by: shahnawaz-creator <[email protected]>
Co-authored-by: Jayash Satolia <[email protected]>

* Fix 0box tests with create allocation

* fix 0box tests

* Empty commit

* Fix restricted blobber tests

* Update gosdk

* Fix sharder config update

* fix delete wallet (#1057)

* Fixed file format and restricted blobbers test

* Fix resume upload

* Fix restricted blobbers

* fix resume download test (#1058)

* Fix restricted blobbers

* Fix restricted blobbers

* Fix restricted blobbers

* added repair allocation with diff file size (#1034)

* added repair allocation for diff file size

* added repair allocation for diff file size

* added repair allocation for diff file size

* added repair allocation for diff file size

* added repair allocation for diff file size

* added repair allocation for diff file size

* added repair allocation for diff file size

* added repair allocation for diff file size

* added TC

* added TC

* added TC

* added TC

* added TC

* updated timeout to 60 mins

* updated timeout to 60 mins

* updated pricing plan fetch for non-rzp org IDs

* added TC with nested folder

* added TC with nested folder

* added TC with nested folder

* added TC with nested folder

* added TC with nested folder

* added TC with nested folder

* added TC with nested folder

* fixed to current sprint branch in tokenomics_ci.yml

* Fix current branch for challenge nightly tests workflow

* Fix current branch for tokenomics nightly tests workflow

* Fix current branch for tokenomics nightly tests workflow

---------

Co-authored-by: Jayash Satolia <[email protected]>
Co-authored-by: shahnawaz-creator <[email protected]>
Co-authored-by: Jayash Satolia <[email protected]>

* added test suite for dropbox

* test suite for gdrive

* updated for workflow

* lint fix

* changes for dropbox tests

* Fix: Issue previous test cases

* Added lib

* disable lint

* add TestRepairSize

* add cli tests

* update gosdk version

* apply gofmt

* add remotepath in the file upload for rollback_allocation_after_multiple_files_upload_and_single_file_delete_should_work_wallet test case

* nit fix for remotepath in the prev test case fix.

* fix remotepath for rollback allocation after multiple files upload and single file update

* refactor: assertion in rollback allocation test case.

* nit fixes.

* nit fixes.

* saving file names as they are generated at random from generateFileAndUpload in rollback allocation after multiple files upload and single file delete should work.

* added wait groups for file uploads.
double allocation rollback as we do 2 file updates in the allocation.

* downloading the file after uploading and then getting the checksum.

* fix waitgroup for uploading multiple files and delete single file test case.

* fix nil map error.

* fix test for multiple files upload and single file delete in rollback allocation.

* fix test multiple files upload and single file update (updating a file single time now as rollback only restores to the previous state).

* remove wait group for updating a large file test.

* add test for updating file multiple times and then rolling back.

* refactor: updating single files multiple times test case.

* refactor: rollback while updating a large file should work.

* refactor: rollback while updating a large file should work.

* nit fixes.

* add some logs

* add new testcase involving large file rollback with a small file upload.

* removed file removal as this is created on the /tmp dir.

* removed file removal as this is created on the /tmp dir.

* refactor: assertion for large file test case.

* removed unnecessary delay for large files.

* refactor: add update small file for large files rollback test.

* update gosdk to latest staging.

* file uploads are very fast on ci so increased the filesize and decreased wait time for large file uploads.

* fix lint errors.

* fix lint errors.

* nit fixes.

* test run

---------

Co-authored-by: CristalWilsonLobo <[email protected]>
Co-authored-by: Jayash Satolia <[email protected]>
Co-authored-by: Sanchit Sharma <[email protected]>
Co-authored-by: Hitenjain14 <[email protected]>
Co-authored-by: Yury <[email protected]>
Co-authored-by: Arun Ramanathan <[email protected]>
Co-authored-by: shahnawaz-creator <[email protected]>
Co-authored-by: sanchit <[email protected]>
Co-authored-by: Jayash Satolia <[email protected]>
Co-authored-by: Gaurang Patel <[email protected]>
Co-authored-by: pewssh <[email protected]>

* main_test.go

* Reset location for cli

* Common server

* Revert "Mc warp test cases"

* enterprise create allocation test.

* running rollback allocation tests parallel. (#1096)

* running rollback allocation tests parallel.

* nit fixes.

* create tests for cancel and update allocation for enterprise blobbers.

* move create allocation enterprise from cli_tests to tokenometrics_tests package

* fixes for package migration for create allocation tests.

* file rename.

* fix package migration errors for update and cancel allocation.

* nit fixes.

* nit fixes.

* expose setupAllocation in allocation.go
fix errors for create, update & cancel allocation.
add new general methods in general.go

* add enterprise allocation flags.

* Deploy enterprise blobbers

* add new method for create enterprise allocation in allocation.go
add utility auth ticket method via 0box.
add zboxTeamWallet in tokenomics_tests.

* add test setup for listing blobbers in create allocation.
add zboxTeamWallet for getting auth tickets.

* created a specialized utility method for directly getting all the blobber auth urls appended.
add zboxTeamWallet for tokenometrics.

* auth ticket fixes for enterprise create allocation tests

* temp commit.

* Review

* added utility methods for setting enterprise allocation with wallet.
debug create, cancel, finalize and update allocation tests for green run.

* add new method for getting wallet by name in econometrics utils.

* add test case for enterprise allocation fail without auth tickets.

* add new cost check related cases for cancel allocation.

* cancel allocation cost calculation updates.

* fix update allocation tests.

* fix: cancel allocation first two tests.

* refactor: cancel allocation tests.

* refactor: cancel allocation tests.

* uncomment time.Sleep from test cases in cancel allocation.

* refactor: cancel allocaiton tests.

* refactor: update allocation tests move failing tests at the bottom.

* refactor: add test setup for time change unit.

* refactor: replace blobber tests.

* update blobber updates.

* cost calculations for update allocation tests.

* fix syntax error in update blobber test.
refactor: replace blobber tests.

* Added basic cost related tests

* Remove skip

* create new utility method for getting blobber details.
refactor: replace blobber allocaiton tests.
feat: add new tests for replacing blobber with same price, 2x price and 0.5x price.
remove sdk client and api client from main_test in tokenomics.

* Added rewards check

* Fix duration replace blobber

* Debug

* Fix

* Fix

* replace blobber add cleanup method to restore blobber write prices.

* move failing test cases to bottom in create allocation tests.

* fix: wallet creation error for finalize allocation.
refactor: add rollback methods for blobber write prices in replace blobber tests.

* refactor: add cli config path field to blobber auth ticket utilty methods
refactor: caching zbox team wallet while fetching blobber auth tickets.

* feat: add cost calculations to all tests in cancel allocation.

* feat: add cost calculation check for finalize allocation.

* removed wait time for cancel allocation test cases where we are updating the allocation.

* debug finalize allocation.

* refactor: finalize allocation after duration test case.

* price change tests.

* change lock price in finalize allocation tests to be exact 2e9.

* fix allocation writee pool and blobber reward calculations.

* add bloober rewards calculations from stake pool in update allocation tests

* refactor: fix cost allocation calculations, change data and parity shards to 2,2 along with allocation size as 2GB update allocation tests.
refactor: fix cost calculations for finalize allocation tests.

* refactor: update allocation add cleanup methods.

* refactor: move blobber price change tests to bottom to run sequentially.

* refactor: add compare allocation to update allocation price tests.

* nit fix cost calculation blobber price change update allocaiton test.

* refactor: update allocation blobber price change extend unused allocation test.

* remove cleanup update allocation for non existing allocation test.

* refactor: matching expected write pool tokens in epsilon after updating allocation for blobber write price change tests.

* refactor: fix blobber reward cost calculations in update allocation.

* refactor: fix blobber reward cost calculations in update allocation.

* refactor: finalize allocation test case for updating allocation.

* refactor: update allocation blobber price test for upgrading size.

* refactor: update allocation blobber price test for extending duration.

* refactor: add logs to update allocation blobber price test extend duration.

* nit fix update allocation tests.

* nit fix update allocation tests for blobber price chagne

* using 4 min waits instead of 5 and also using exact values for locking the write pool instead of calculating via timestamps in update allocation tests.

* refactor: update blobber price test.

* refactor: update blobber price test.

* nit cost fixes update allocation blobber price tests.

* nit fix.

* adding time consumed after first update for update allocation blobber price tests

* debug: green run update allocation blobber price change tests.

* debug: tests are not passing for first update expected rewards blobber price tests.

* refactor: replace blobber tests include cost calculations.

* Fix system tests

* Revert "Fix system tests"

This reverts commit fb506c9.

* refactor: setup allocation method for replace blobber.

* refactor: update allocation extend duration cost calculation test.

* refactor: replace blobber tests.

* debug replace blobber 0.5x price.

* remove duplicate test.

* refactor: replace blobber allocation tests

* refactor: change deploy action to master branch in ci/cd

* refactor: replace blobber tests green run.

* refactor: test setup method for update and replace allocation tests.

* fix: green run for finalize allocation.

* lint fixes.

* lint fixes.

* use new enterprise blobber 0chain deployment action.

* refactor: chnage name for enterprise blobber replace allocation tests.

* feat: add enterprise blobber tests in tokenomics nightly run.

* refactor: tokenomics_ci move enterprise blobber tests to top.

* refactor: tokenomics_ci.yml fix network deployment.

* refactor: tokenomics_ci.yml fix network deployment.

* refactor: tokenomics_ci.yml fix test run branch.

* fix: actions test run branch.

* debug: disable notifications for slack on tokenomics workflow run

* debug: pass enterprise blobber tests branch.

* debug: set n/w to static.

* Revert "debug: set n/w to static."

This reverts commit ea1a7fb.

* debug: blobber list method.

* Revert "debug: blobber list method."

This reverts commit 80c22ac.

* debug: network deployment tokenomics ci.

* nit fixes.

* debug tokenomics_ci.yml

* upgrade gosdk to latest sprint-1.17

* debug change deployment action.

* update gosdk to latest.

* green run fixes for create allocation tests.

* reduced facuet tokens in create allocation tests.

* fix kubeconfig param passing tokenomics_ci.yml

* refactor: update error message.

* refactor: add blobber reset prices at test startup.

* refactor: run update allocation run tests in parallel for non price change blobber tests
refactor: update error messages for transactions.

* deploying clean n/w for every enterprise blobber test suite.

* refactor: green run cancel allocation.

* nit fixes.

* Revert "deploying clean n/w for every enterprise blobber test suite."

This reverts commit 34f64ae.

* refactor: moving enterprise blobber tests at bottom to monitor other test runs.

* fix: add tenderly account testnet creation and deletion steps.
refactor: move enterprise blobber tests to top.

* update gosdk with latest fix.

* revert command error outputs for enterprise blobbers tokenomics tests.

* go mod tidy.

* upgrade gosdk to v1.17.3
go mod tidy.

* refactor: error message for create enterprise allocation test.

* cleanup test setups.

* more cleanup.

* refactor: revert test output enterprise create allocation.

* refactor: move blobber price change tests to top to run them sequentially as these changes afftect the allocation creation with non-price change test cases in update allocation.

* enable slack notifications for tokenomics_ci.yml

* add nolint on error message mispells from 0chain.
lint fixes.

* revert api model to remove Enterprise param.

* revert ci-dev-st.yml deploy 0chain to master branch.

* more cleanup.

* reset configs to orignal dev n/w.

* lint formatting for repair_allocation_test.go

* remove review comments.

* run goimports to fix lint.

* update gosdk to v1.17.5
go mod tidy

---------

Co-authored-by: Jayash Satolia <[email protected]>
Co-authored-by: Sanchit Sharma <[email protected]>
Co-authored-by: Hitenjain14 <[email protected]>
Co-authored-by: Yury <[email protected]>
Co-authored-by: Arun Ramanathan <[email protected]>
Co-authored-by: shahnawaz-creator <[email protected]>
Co-authored-by: sanchit <[email protected]>
Co-authored-by: Jayash Satolia <[email protected]>
Co-authored-by: Gaurang Patel <[email protected]>
Co-authored-by: pewssh <[email protected]>
Co-authored-by: CristalWilsonLobo <[email protected]>
Co-authored-by: pewssh <[email protected]>
  • Loading branch information
13 people authored Sep 7, 2024
1 parent e361082 commit 726ccab
Show file tree
Hide file tree
Showing 22 changed files with 4,087 additions and 61 deletions.
152 changes: 148 additions & 4 deletions .github/workflows/tokenomics_ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,25 @@ jobs:
with:
github-token: ${{ github.token }}

- name: 'Setup jq'
uses: dcarbone/[email protected]
with:
version: '1.7'
force: 'false'

- name: "Create Tenderly virtual testnet"
run: |
echo "TENDERLY_CREATION_INFO=$(curl -X POST \
-H "x-access-key: ${{ secrets.TENDERLY_SECRET }}" \
-H "Content-Type: application/json" \
-d '{"slug":"mainnet-dev-${{ env.RUNNER_NUMBER }}-${{ github.run_id }}","displayName":"mainnet-dev-${{ env.RUNNER_NUMBER }}-${{ github.run_id }}","description":"","visibility":"TEAM","tags":{"purpose":"development"},"networkConfig":{"networkId":"1","blockNumber":"18512782","chainConfig":{"chainId":"1"},"baseFeePerGas":"1"},"explorerConfig":{"enabled":false,"verificationVisibility":"bytecode"},"syncState":false}' \
https://api.tenderly.co/api/v1/account/zus_network/project/project/testnet/container)" >> $GITHUB_ENV
- name: "Parse Tenderly virtual testnet creation transaction result"
run: |
echo "TENDERLY_VIRTUAL_TESTNET_ID=$(echo '${{ env.TENDERLY_CREATION_INFO }}' | jq -r '.container.id')" >> $GITHUB_ENV
echo "TENDERLY_VIRTUAL_TESTNET_RPC_ID=$(echo '${{ env.TENDERLY_CREATION_INFO }}' | jq -r '.container.connectivityConfig.endpoints[0].id')" >> $GITHUB_ENV
- name: "Config: Run tests against existing 0Chain network"
if: github.event_name == 'workflow_dispatch' && github.event.inputs.existing_network != ''
run: |
Expand All @@ -44,9 +63,134 @@ jobs:
echo "TOKENOMICS_SLASH_REWARD_TESTS=$(echo $(([ -z 'TestBlobberSlashPenalty' ] && echo '') || echo 'TestBlobberSlashPenalty'))" >> $GITHUB_ENV
echo "TOKENOMICS_BLOCK_REWARD_TESTS=$(echo $(([ -z 'TestBlockRewardsForBlobbers' ] && echo '') || echo 'TestBlockRewardsForBlobbers'))" >> $GITHUB_ENV
echo "TOKENOMICS_MIN_STAKE_TESTS=$(echo $(([ -z 'TestMinStakeForProviders' ] && echo '') || echo 'TestMinStakeForProviders'))" >> $GITHUB_ENV
echo "ENTERPRISE_BLOBBER_CREATE_ALLOCATION_TESTS=$(echo $(([ -z 'TestCreateEnterpriseAllocation' ] && echo '') || echo 'TestCreateEnterpriseAllocation'))" >> $GITHUB_ENV
echo "ENTERPRISE_BLOBBER_UPDATE_ALLOCATION_TESTS=$(echo $(([ -z 'TestUpdateEnterpriseAllocation' ] && echo '') || echo 'TestUpdateEnterpriseAllocation'))" >> $GITHUB_ENV
echo "ENTERPRISE_BLOBBER_REPLACE_ALLOCATION_TESTS=$(echo $(([ -z 'TestReplaceEnterpriseBlobberAllocation' ] && echo '') || echo 'TestReplaceEnterpriseBlobberAllocation'))" >> $GITHUB_ENV
echo "ENTERPRISE_BLOBBER_CANCEL_ALLOCATION_TESTS=$(echo $(([ -z 'TestCancelEnterpriseAllocation' ] && echo '') || echo 'TestCancelEnterpriseAllocation'))" >> $GITHUB_ENV
echo "ENTERPRISE_BLOBBER_FINALIZE_ALLOCATION_TESTS=$(echo $(([ -z 'TestFinalizeEnterpriseAllocation' ] && echo '') || echo 'TestFinalizeEnterpriseAllocation'))" >> $GITHUB_ENV
echo "CLIENT_THROTTLING=$(echo $(([ -z 'TestClientThrottling' ] && echo '') || echo 'TestClientThrottling'))" >> $GITHUB_ENV
echo "REPO_SNAPSHOTS_BRANCH=current-sprint" >> $GITHUB_ENV
- name: "Deploy 0Chain with enterprise blobbers"
if: github.event_name == 'push' || github.event.inputs.existing_network == ''
uses: 0chain/actions/deploy-0chain@feature/enterprise-blobber
with:
repo_snapshots_branch: "${{ env.REPO_SNAPSHOTS_BRANCH }}"
kube_config: ${{ secrets[format('DEV{0}KC', env.RUNNER_NUMBER)] }}
teardown_condition: "TESTS_PASSED"
SUBGRAPH_API_URL: ${{ secrets.SUBGRAPH_API_URL }}
TENDERLY_VIRTUAL_TESTNET_RPC_ID: ${{ env.TENDERLY_VIRTUAL_TESTNET_RPC_ID }}
graphnode_sc: ${{ secrets.GRAPHNODE_SC }}
graphnode_network: ${{ secrets.GRAPHNODE_NETWORK }}
graphnode_ethereum_node_url: https://virtual.mainnet.rpc.tenderly.co/${{ env.TENDERLY_VIRTUAL_TESTNET_RPC_ID }}
svc_account_secret: ${{ secrets.SVC_ACCOUNT_SECRET }}

- name: "Run Enterprise blobber create allocation tests"
uses: 0chain/actions/run-system-tests-tokenomics@master
with:
repo_snapshots_branch: "${{ env.REPO_SNAPSHOTS_BRANCH }}"
network: ${{ env.NETWORK_URL }}
svc_account_secret: ${{ secrets.SVC_ACCOUNT_SECRET }}
deploy_report_page: true
system_tests_branch: feat/enterprise-blobber-tests
archive_results: true
run_flaky_tests: false
run_api_system_tests: false
run_cli_system_tests: false
run_tokenomics_system_tests: true
tokenomics_test_filter: ${{ env.ENTERPRISE_BLOBBER_CREATE_ALLOCATION_TESTS }}
run_smoke_tests: ${{ inputs.run_smoke_tests }}
S3_ACCESS_KEY: ${{ secrets.S3_ACCESS_KEY }}
S3_SECRET_KEY: ${{ secrets.S3_SECRET_KEY }}
TENDERLY_VIRTUAL_TESTNET_RPC_ID: ${{ env.TENDERLY_VIRTUAL_TESTNET_RPC_ID }}

- name: "Run Enterprise blobber update allocation tests"
uses: 0chain/actions/run-system-tests-tokenomics@master
with:
repo_snapshots_branch: "${{ env.REPO_SNAPSHOTS_BRANCH }}"
network: ${{ env.NETWORK_URL }}
svc_account_secret: ${{ secrets.SVC_ACCOUNT_SECRET }}
deploy_report_page: true
archive_results: true
run_flaky_tests: false
system_tests_branch: feat/enterprise-blobber-tests
run_api_system_tests: false
run_cli_system_tests: false
run_tokenomics_system_tests: true
tokenomics_test_filter: ${{ env.ENTERPRISE_BLOBBER_UPDATE_ALLOCATION_TESTS }}
TENDERLY_VIRTUAL_TESTNET_ID: ""
run_smoke_tests: ${{ inputs.run_smoke_tests }}
S3_ACCESS_KEY: ${{ secrets.S3_ACCESS_KEY }}
S3_SECRET_KEY: ${{ secrets.S3_SECRET_KEY }}
TENDERLY_VIRTUAL_TESTNET_RPC_ID: ${{ env.TENDERLY_VIRTUAL_TESTNET_RPC_ID }}

- name: "Run Enterprise blobber replace blobber allocation tests"
uses: 0chain/actions/run-system-tests-tokenomics@master
with:
repo_snapshots_branch: "${{ env.REPO_SNAPSHOTS_BRANCH }}"
network: ${{ env.NETWORK_URL }}
svc_account_secret: ${{ secrets.SVC_ACCOUNT_SECRET }}
deploy_report_page: true
archive_results: true
system_tests_branch: feat/enterprise-blobber-tests
run_flaky_tests: false
run_api_system_tests: false
run_cli_system_tests: false
run_tokenomics_system_tests: true
tokenomics_test_filter: ${{ env.ENTERPRISE_BLOBBER_REPLACE_ALLOCATION_TESTS }}
TENDERLY_VIRTUAL_TESTNET_ID: ""
run_smoke_tests: ${{ inputs.run_smoke_tests }}
S3_ACCESS_KEY: ${{ secrets.S3_ACCESS_KEY }}
S3_SECRET_KEY: ${{ secrets.S3_SECRET_KEY }}
TENDERLY_VIRTUAL_TESTNET_RPC_ID: ${{ env.TENDERLY_VIRTUAL_TESTNET_RPC_ID }}

- name: "Run Enterprise blobber cancel allocation tests"
uses: 0chain/actions/run-system-tests-tokenomics@master
with:
repo_snapshots_branch: "${{ env.REPO_SNAPSHOTS_BRANCH }}"
network: ${{ env.NETWORK_URL }}
svc_account_secret: ${{ secrets.SVC_ACCOUNT_SECRET }}
deploy_report_page: true
archive_results: true
run_flaky_tests: false
system_tests_branch: feat/enterprise-blobber-tests
run_api_system_tests: false
run_cli_system_tests: false
run_tokenomics_system_tests: true
tokenomics_test_filter: ${{ env.ENTERPRISE_BLOBBER_CANCEL_ALLOCATION_TESTS }}
TENDERLY_VIRTUAL_TESTNET_ID: ""
run_smoke_tests: ${{ inputs.run_smoke_tests }}
S3_ACCESS_KEY: ${{ secrets.S3_ACCESS_KEY }}
S3_SECRET_KEY: ${{ secrets.S3_SECRET_KEY }}
TENDERLY_VIRTUAL_TESTNET_RPC_ID: ${{ env.TENDERLY_VIRTUAL_TESTNET_RPC_ID }}

- name: "Run Enterprise blobber finalize allocation tests"
uses: 0chain/actions/run-system-tests-tokenomics@master
with:
repo_snapshots_branch: "${{ env.REPO_SNAPSHOTS_BRANCH }}"
network: ${{ env.NETWORK_URL }}
svc_account_secret: ${{ secrets.SVC_ACCOUNT_SECRET }}
deploy_report_page: true
system_tests_branch: feat/enterprise-blobber-tests
archive_results: true
run_flaky_tests: false
run_api_system_tests: false
run_cli_system_tests: false
run_tokenomics_system_tests: true
tokenomics_test_filter: ${{ env.ENTERPRISE_BLOBBER_FINALIZE_ALLOCATION_TESTS }}
TENDERLY_VIRTUAL_TESTNET_ID: ""
run_smoke_tests: ${{ inputs.run_smoke_tests }}
S3_ACCESS_KEY: ${{ secrets.S3_ACCESS_KEY }}
S3_SECRET_KEY: ${{ secrets.S3_SECRET_KEY }}
TENDERLY_VIRTUAL_TESTNET_RPC_ID: ${{ env.TENDERLY_VIRTUAL_TESTNET_RPC_ID }}

- name: "Remove Tenderly virtual testnet"
if: always()
run: |
curl -X DELETE \
-H "x-access-key: ${{ secrets.TENDERLY_SECRET }}" \
-H "Content-Type: application/json" \
https://api.tenderly.co/api/v1/account/zus_network/project/project/testnet/container/${{ env.TENDERLY_VIRTUAL_TESTNET_ID }}
- name: "Deploy 0Chain"
if: github.event_name == 'push' || github.event.inputs.existing_network == ''
Expand Down Expand Up @@ -261,8 +405,8 @@ jobs:


notify_slack_on_failure:
runs-on: [self-hosted, arc-runner]
needs: [system-tests]
runs-on: [ self-hosted, arc-runner ]
needs: [ system-tests ]
if: always() && (needs.system-tests.result == 'failure')
steps:
- name: "Notify Slack"
Expand All @@ -279,8 +423,8 @@ jobs:
curl -X POST -H 'Content-type: application/json' --data "${payload}" ${{ secrets.DEVOPS_CHANNEL_WEBHOOK_URL }}
notify_slack_on_success:
runs-on: [self-hosted, arc-runner]
needs: [system-tests]
runs-on: [ self-hosted, arc-runner ]
needs: [ system-tests ]
if: always() && (needs.system-tests.result == 'success')
steps:
- name: "Notify Slack"
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ toolchain go1.22.1

require (
github.com/0chain/errors v1.0.3
github.com/0chain/gosdk v1.17.3
github.com/0chain/gosdk v1.17.5
github.com/go-resty/resty/v2 v2.7.0
github.com/herumi/bls-go-binary v1.31.0
github.com/shopspring/decimal v1.3.1
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ github.com/0chain/common v0.0.6-0.20230127095721-8df4d1d72565 h1:z+DtCR8mBsjPnEs
github.com/0chain/common v0.0.6-0.20230127095721-8df4d1d72565/go.mod h1:UyDC8Qyl5z9lGkCnf9RHJPMektnFX8XtCJZHXCCVj8E=
github.com/0chain/errors v1.0.3 h1:QQZPFxTfnMcRdt32DXbzRQIfGWmBsKoEdszKQDb0rRM=
github.com/0chain/errors v1.0.3/go.mod h1:xymD6nVgrbgttWwkpSCfLLEJbFO6iHGQwk/yeSuYkIc=
github.com/0chain/gosdk v1.17.3 h1:nL6x1saSwTku1UFDYoX/uKJO57VQTgowp6id+7UHb7g=
github.com/0chain/gosdk v1.17.3/go.mod h1:y7Ucdmv40VltqulZnncMNjNQ4piX5Dta5ujNmPmXnxg=
github.com/0chain/gosdk v1.17.5 h1:WusXPOj+lyK9XBUY1JPjBqPmkGV4A0J6bqsRluseusg=
github.com/0chain/gosdk v1.17.5/go.mod h1:y7Ucdmv40VltqulZnncMNjNQ4piX5Dta5ujNmPmXnxg=
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo=
github.com/Luzifer/go-openssl/v3 v3.1.0 h1:QqKqo6kYXGGUsvtUoCpRZm8lHw+jDfhbzr36gVj+/gw=
Expand Down
44 changes: 22 additions & 22 deletions tests/api_tests/repair_allocation_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -353,18 +353,18 @@ func TestRepairSize(testSetup *testing.T) {
wallet := createWallet(t)
sdkClient.SetWallet(t, wallet)
apiClient.CreateReadPool(t, wallet, 0.5, client.TxSuccessfulStatus)
t.RunSequentiallyWithTimeout("repair size in case of no blobber failure should be zero", 5 * time.Minute, func(t *test.SystemTest) {

t.RunSequentiallyWithTimeout("repair size in case of no blobber failure should be zero", 5*time.Minute, func(t *test.SystemTest) {
// create allocation with default blobber requirements
blobberRequirements := model.DefaultBlobberRequirements(wallet.Id, wallet.PublicKey)
allocationBlobbers := apiClient.GetAllocationBlobbers(t, wallet, &blobberRequirements, client.HttpOkStatus)
allocationID := apiClient.CreateAllocation(t, wallet, allocationBlobbers, client.TxSuccessfulStatus)
t.Logf("allocationID: %v", allocationID)

// create and upload a file of 2KB to allocation.
op := sdkClient.AddUploadOperation(t, "", "", int64(1024 * 2))
op := sdkClient.AddUploadOperation(t, "", "", int64(1024*2))
sdkClient.MultiOperation(t, allocationID, []sdk.OperationRequest{op})

// assert both upload and download size should be zero
alloc, err := sdk.GetAllocation(allocationID)
require.NoErrorf(t, err, "allocation ID %v is not found", allocationID)
Expand All @@ -374,8 +374,8 @@ func TestRepairSize(testSetup *testing.T) {
require.Equal(t, uint64(0), rs.UploadSize, "upload size doesn't match")
require.Equal(t, uint64(0), rs.DownloadSize, "download size doesn't match")
})
t.RunSequentiallyWithTimeout("repair size on single blobber failure should match", 5 * time.Minute, func(t *test.SystemTest) {

t.RunSequentiallyWithTimeout("repair size on single blobber failure should match", 5*time.Minute, func(t *test.SystemTest) {
// create allocation with default blobber requirements
blobberRequirements := model.DefaultBlobberRequirements(wallet.Id, wallet.PublicKey)
blobberRequirements.DataShards = 2
Expand All @@ -390,18 +390,18 @@ func TestRepairSize(testSetup *testing.T) {
alloc, err := sdk.GetAllocation(allocationID)
require.NoErrorf(t, err, "allocation ID %v is not found", allocationID)
alloc.Blobbers[0].Baseurl = "http://0zus.com/"
op := sdkClient.AddUploadOperation(t, "", "", int64(1024 * 2))
op := sdkClient.AddUploadOperation(t, "", "", int64(1024*2))
sdkClient.MultiOperation(t, allocationID, []sdk.OperationRequest{op}, client.WithRepair(alloc.Blobbers))

// assert upload and download size should be 1KB and 2KB respectively
rs, err := alloc.RepairSize("/")
require.Nil(t, err)
t.Logf("repair size: %v", rs)
require.Equal(t, uint64(1024), rs.UploadSize, "upload size doesn't match")
require.Equal(t, uint64(1024 * 2), rs.DownloadSize, "download size doesn't match")
require.Equal(t, uint64(1024*2), rs.DownloadSize, "download size doesn't match")
})

t.RunSequentiallyWithTimeout("repair size with nested directories and two blobber failure should match", 5 * time.Minute, func(t *test.SystemTest) {
t.RunSequentiallyWithTimeout("repair size with nested directories and two blobber failure should match", 5*time.Minute, func(t *test.SystemTest) {
// create allocation with default blobber requirements
blobberRequirements := model.DefaultBlobberRequirements(wallet.Id, wallet.PublicKey)
blobberRequirements.DataShards = 2
Expand All @@ -419,31 +419,31 @@ func TestRepairSize(testSetup *testing.T) {
ops := []sdk.OperationRequest{
sdkClient.AddUploadOperationWithPath(t, allocationID, "/dir1/"),
sdkClient.AddUploadOperationWithPath(t, allocationID, "/dir1/"),
sdkClient.AddUploadOperationWithPath(t, allocationID, "/"),
sdkClient.AddUploadOperationWithPath(t, allocationID, "/"),
sdkClient.AddUploadOperationWithPath(t, allocationID, "/"),
}
sdkClient.MultiOperation(t, allocationID, ops, client.WithRepair(alloc.Blobbers))

// assert both upload and download size should be 2KB in /dir1
rs, err := alloc.RepairSize("/dir1")
require.Nilf(t, err, "error getting repair size in /dir1: %v", err)
t.Logf("repair size: %v", rs)
require.Equal(t, uint64(1024 * 2), rs.UploadSize, "upload size in directory /dir1 doesn't match")
require.Equal(t, uint64(1024 * 2), rs.DownloadSize, "download size in directory dir1 doesn't match")
require.Equal(t, uint64(1024*2), rs.UploadSize, "upload size in directory /dir1 doesn't match")
require.Equal(t, uint64(1024*2), rs.DownloadSize, "download size in directory dir1 doesn't match")

// with trailing slash
// assert both upload and download size should be 2KB in /dir1/
// assert both upload and download size should be 2KB in /dir1/
rs, err = alloc.RepairSize("/dir1/")
require.Nilf(t, err, "error getting repair size in /dir1/: %v", err)
t.Logf("repair size: %v", rs)
require.Equal(t, uint64(1024 * 2), rs.UploadSize, "upload size in directory /dir1/ doesn't match")
require.Equal(t, uint64(1024 * 2), rs.DownloadSize, "download size in directory /dir1/ doesn't match")
require.Equal(t, uint64(1024*2), rs.UploadSize, "upload size in directory /dir1/ doesn't match")
require.Equal(t, uint64(1024*2), rs.DownloadSize, "download size in directory /dir1/ doesn't match")

// assert both upload and download size should be 4KB in root directory
rs, err = alloc.RepairSize("/")
require.Nilf(t, err, "error getting repair size in /: %v", err)
t.Logf("repair size: %v", rs)
require.Equal(t, uint64(1024 * 4), rs.UploadSize, "upload size in root directory doesn't match")
require.Equal(t, uint64(1024 * 4), rs.DownloadSize, "download size in root directory doesn't match")
require.Equal(t, uint64(1024*4), rs.UploadSize, "upload size in root directory doesn't match")
require.Equal(t, uint64(1024*4), rs.DownloadSize, "download size in root directory doesn't match")
})
}
}
32 changes: 25 additions & 7 deletions tests/cli_tests/sdk.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,21 +50,30 @@ func InitSDK(wallet, configFile string) error {
return err
}

// GetBlobberNotPartOfAllocation returns a blobber not part of current allocation
func GetBlobberNotPartOfAllocation(walletname, configFile, allocationID string) (string, error) {
err := InitSDK(walletname, configFile)
// GetBlobberIDNotPartOfAllocation returns a blobber not part of current allocation
func GetBlobberIDNotPartOfAllocation(walletname, configFile, allocationID string) (string, error) {
blobber, err := getBlobberNotPartOfAllocation(walletname, configFile, allocationID)

if err != nil {
return "", err
}
return string(blobber.ID), err
}

func getBlobberNotPartOfAllocation(walletname, configFile, allocationID string) (*sdk.Blobber, error) {
err := InitSDK(walletname, configFile)
if err != nil {
return nil, err
}

a, err := sdk.GetAllocation(allocationID)
if err != nil {
return "", err
return nil, err
}

blobbers, err := sdk.GetBlobbers(true, false)
if err != nil {
return "", err
return nil, err
}

allocationBlobsMap := map[string]bool{}
Expand All @@ -74,11 +83,20 @@ func GetBlobberNotPartOfAllocation(walletname, configFile, allocationID string)

for _, blobber := range blobbers {
if _, ok := allocationBlobsMap[string(blobber.ID)]; !ok {
return string(blobber.ID), nil
return blobber, nil
}
}

return "", fmt.Errorf("failed to get blobber not part of allocation")
return nil, fmt.Errorf("failed to get blobber not part of allocation")
}

// GetBlobberIdAndUrlNotPartOfAllocation returns a blobber not part of current allocation
func GetBlobberIdAndUrlNotPartOfAllocation(walletName, configFile, allocationID string) (blobberId, blobberUrl string, err error) {
blobber, err := getBlobberNotPartOfAllocation(walletName, configFile, allocationID)
if err != nil || blobber == nil {
return "", "", err
}
return string(blobber.ID), blobber.BaseURL, err
}

func generateRandomIndex(sliceLen int64) (*big.Int, error) {
Expand Down
Loading

0 comments on commit 726ccab

Please sign in to comment.