From 113d1b5f3c3a02510ba4b74e3c2fad245cc13ad0 Mon Sep 17 00:00:00 2001 From: Roman Date: Sun, 26 May 2024 19:10:26 +0000 Subject: [PATCH 1/2] test(e2e): reduce flakiness in candidate route and prices tests --- router/usecase/router.go | 3 ++- tests/constants.py | 5 +++++ tests/test_candidate_routes.py | 8 ++++++++ tests/test_tokens_prices.py | 2 +- tests/util.py | 19 +++++++++++++++++++ 5 files changed, 35 insertions(+), 2 deletions(-) create mode 100644 tests/util.py diff --git a/router/usecase/router.go b/router/usecase/router.go index 85a75d3c2..090097185 100644 --- a/router/usecase/router.go +++ b/router/usecase/router.go @@ -2,6 +2,7 @@ package usecase import ( "sort" + "strings" sdk "github.com/cosmos/cosmos-sdk/types" cosmwasmpooltypes "github.com/osmosis-labs/osmosis/v25/x/cosmwasmpool/types" @@ -115,7 +116,7 @@ func sortPools(pools []sqsdomain.PoolI, transmuterCodeIDs map[uint64]struct{}, t // rating += 1/ 100 of TVL of asset across all pools // (Ignoring any pool with an error in TVL) - if pool.GetSQSPoolModel().PoolLiquidityCapError == noPoolLiquidityCapError { + if strings.TrimSpace(pool.GetSQSPoolModel().PoolLiquidityCapError) == noPoolLiquidityCapError { rating += totalTVLFloat / 100 } diff --git a/tests/constants.py b/tests/constants.py index d50e6e50b..c488a4a00 100644 --- a/tests/constants.py +++ b/tests/constants.py @@ -29,3 +29,8 @@ ## Unsupported token count threshold UNSUPPORTED_TOKEN_COUNT_THRESHOLD = 10 + +# Min liquidity in USD of each token in the transmuter pool +# required to run the transmuter test. This is to avoid the flakiness +# stemming from transmuter pool imbalance. +TRANSMUTER_MIN_TOKEN_LIQ_USD = 15000 diff --git a/tests/test_candidate_routes.py b/tests/test_candidate_routes.py index 81619b501..c3132600f 100644 --- a/tests/test_candidate_routes.py +++ b/tests/test_candidate_routes.py @@ -4,6 +4,7 @@ from sqs_service import * import constants +import util from conftest import SERVICE_MAP # Arbitrary choice based on performance at the time of test writing @@ -48,6 +49,8 @@ def test_transmuter_tokens(self, environment_url): transmuter_pool_id = transmuter_token_data[0] tansmuter_token_pair = transmuter_token_data[1] + util.skip_imbalanced_pool_test(transmuter_token_data) + config = sqs_service.get_config() expected_num_routes = config['Router']['MaxRoutes'] @@ -56,6 +59,11 @@ def test_transmuter_tokens(self, environment_url): validate_pool_id_in_route(routes, [transmuter_pool_id]) def test_astroport_tokens(self, environment_url): + + # See: + # https://linear.app/osmosis/issue/DATA-191/[techdebt]-re-enable-astroport-integration-test-for-candidate-routes + pytest.skip("Skipping Astroport PCL candidate route test per DATA-191") + sqs_service = SERVICE_MAP[environment_url] astroport_token_data = setup.astroport_token_pair[0] diff --git a/tests/test_tokens_prices.py b/tests/test_tokens_prices.py index f014cf567..7aecf2d5d 100644 --- a/tests/test_tokens_prices.py +++ b/tests/test_tokens_prices.py @@ -63,7 +63,7 @@ def test_low_volume_token_prices(self, environment_url, token): # NUM_TOKENS_DEFAULT mid volume tokens @pytest.mark.parametrize("token",setup.choose_tokens_volume_range(NUM_TOKENS_DEFAULT, MIN_VOL_FILTER_DEFAULT, MAX_VAL_MID_VOL_FILTER_DEFAULT)) def test_mid_volume_token_prices(self, environment_url, token): - self.run_coingecko_comparison_test(environment_url, token, MID_PRICE_DIFF, allow_blank_coingecko_id=False) + self.run_coingecko_comparison_test(environment_url, token, MID_PRICE_DIFF, allow_blank_coingecko_id=True) # NUM_TOKENS_DEFAULT top by-volume tokens @pytest.mark.parametrize("token", setup.choose_tokens_volume_range(NUM_TOKENS_DEFAULT)) diff --git a/tests/util.py b/tests/util.py new file mode 100644 index 000000000..8340d3a97 --- /dev/null +++ b/tests/util.py @@ -0,0 +1,19 @@ +import setup +import constants +import pytest + +def skip_imbalanced_pool_test(token_data): + """ + Skip the test if any of the tokens in the pool (token_data[0]) have less than TRANSMUTER_MIN_TOKEN_LIQ_USD liquidity. + See definition of TRANSMUTER_MIN_TOKEN_LIQ_USD for more information. + + This is useful for skipping pools such as transmuter that tend to get out of balance, consisting + only of one token and causing the flakiness in our test suite. + """ + pool_id = token_data[0] + pool_data = setup.pool_by_id_map.get(pool_id) + pool_tokens = pool_data.get("pool_tokens") + for token in pool_tokens: + if float(token.get("amount")) < constants.TRANSMUTER_MIN_TOKEN_LIQ_USD: + pytest.skip("Skipped test due to pool being imbalanced") + return From 7845d0d8916aba8dc10d330be1e55c94e1225fa2 Mon Sep 17 00:00:00 2001 From: Roman Date: Sun, 26 May 2024 19:11:09 +0000 Subject: [PATCH 2/2] fix stage service --- tests/sqs_service.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/sqs_service.py b/tests/sqs_service.py index 0961d4b72..bc6e1dfff 100644 --- a/tests/sqs_service.py +++ b/tests/sqs_service.py @@ -1,6 +1,6 @@ import requests -SQS_STAGE = "http://localhost:9092" +SQS_STAGE = "https://sqs.stage.osmosis.zone" SQS_PROD = "https://sqs.osmosis.zone" ROUTER_ROUTES_URL = "/router/routes"