From 46b93f088290077d72ccf66108fb4cea33e8059f Mon Sep 17 00:00:00 2001 From: A-Harby Date: Thu, 7 Nov 2024 17:29:55 +0200 Subject: [PATCH 01/27] update hompage, transfer and proxy tests --- .../playground/tests/frontend_selenium/pages/dashboard.py | 8 ++++---- .../frontend_selenium/tests/TFChain/test_homepage.py | 4 +++- .../frontend_selenium/tests/TFChain/test_transfer.py | 4 ++-- .../tests/frontend_selenium/utils/grid_proxy.py | 6 +++++- 4 files changed, 14 insertions(+), 8 deletions(-) diff --git a/packages/playground/tests/frontend_selenium/pages/dashboard.py b/packages/playground/tests/frontend_selenium/pages/dashboard.py index 3fd3062822..8778999278 100644 --- a/packages/playground/tests/frontend_selenium/pages/dashboard.py +++ b/packages/playground/tests/frontend_selenium/pages/dashboard.py @@ -45,10 +45,10 @@ class DashboardPage: email_login_label = (By.XPATH, "//label[text()='Email']/following-sibling::input") id_login_label = (By.XPATH, "//label[text()='Twin ID']/following-sibling::input") address_login_label = (By.XPATH, "//label[text()='Address']/following-sibling::input") - capacity_stats = (By.XPATH, '/html/body/div[1]/div/div/main/div/div[2]/div/div/div[2]/div[2]/div[2]/div[1]/div/div[3]/p[1]') - nodes_stats = (By.XPATH, '/html/body/div[1]/div/div/main/div/div[2]/div/div/div[2]/div[2]/div[2]/div[2]/div/div[3]/p[1]') - countries_stats = (By.XPATH, '/html/body/div[1]/div/div/main/div/div[2]/div/div/div[2]/div[2]/div[2]/div[3]/div/div[3]/p[1]') - cores_stats = (By.XPATH, '/html/body/div[1]/div/div/main/div/div[2]/div/div/div[2]/div[2]/div[2]/div[4]/div/div[3]/p[1]') + capacity_stats = (By.XPATH, "//p[contains(@class, 'text-center') and following-sibling::p[text()='Capacity']]") + nodes_stats = (By.XPATH, "//p[contains(@class, 'text-center') and following-sibling::p[text()='Nodes']]") + countries_stats = (By.XPATH, "//p[contains(@class, 'text-center') and following-sibling::p[text()='Countries']]") + cores_stats = (By.XPATH, "//p[contains(@class, 'text-center') and following-sibling::p[text()='Cores']]") profile_button = (By.XPATH, '/html/body/div[1]/div/div/main/header[1]/div/div[3]/i') profile_label = (By.XPATH, '/html/body/div[1]/div/div/main/div/div[2]/div/div/div/div[1]/div/div[1]') qr_code_img = (By.XPATH, "//img[@alt='qrcode']") diff --git a/packages/playground/tests/frontend_selenium/tests/TFChain/test_homepage.py b/packages/playground/tests/frontend_selenium/tests/TFChain/test_homepage.py index c8d608a472..8df431b34b 100644 --- a/packages/playground/tests/frontend_selenium/tests/TFChain/test_homepage.py +++ b/packages/playground/tests/frontend_selenium/tests/TFChain/test_homepage.py @@ -61,8 +61,10 @@ def test_stats(browser): """ dashboard_page = before_test_setup(browser) grid_proxy = GridProxy(browser) - stats = grid_proxy.get_stats() + stats = grid_proxy.get_stats_capicity() dashboard_stats = dashboard_page.get_dashboard_stats() + print(stats) + print(dashboard_stats) assert stats == dashboard_stats diff --git a/packages/playground/tests/frontend_selenium/tests/TFChain/test_transfer.py b/packages/playground/tests/frontend_selenium/tests/TFChain/test_transfer.py index ce11a712f8..0794569cba 100644 --- a/packages/playground/tests/frontend_selenium/tests/TFChain/test_transfer.py +++ b/packages/playground/tests/frontend_selenium/tests/TFChain/test_transfer.py @@ -91,12 +91,12 @@ def test_twin_id(browser): cases = [' ', generate_string(), invalid_address(), generate_leters()] for case in cases: transfer_page.recipient_id_input(case) - assert transfer_page.wait_for('Twin ID should be a number') + assert transfer_page.wait_for('Twin ID should be a valid integer') assert transfer_page.get_id_submit().is_enabled() == False cases = ['0', '-52'] for case in cases: transfer_page.recipient_id_input(case) - assert transfer_page.wait_for('Twin ID should be more than 0') + assert transfer_page.wait_for('Twin ID should be greater than zero') assert transfer_page.get_id_submit().is_enabled() == False diff --git a/packages/playground/tests/frontend_selenium/utils/grid_proxy.py b/packages/playground/tests/frontend_selenium/utils/grid_proxy.py index 55ee69ba7f..3d64d5a05c 100644 --- a/packages/playground/tests/frontend_selenium/utils/grid_proxy.py +++ b/packages/playground/tests/frontend_selenium/utils/grid_proxy.py @@ -61,7 +61,11 @@ def get_twin_node(self, twin_id): r = requests.post(Base.gridproxy_url + 'nodes?farm_ids=' + farms[:-1]) details = r.json() return details - + + def get_stats_capicity(self): + r = requests.post('https://stats.' + Base.net + '.grid.tf/api/stats-summary') + stats_json = r.json() + return list(stats_json.values()) def get_stats(self): up = requests.get(Base.gridproxy_url + 'stats?status=up', timeout=10).json() From 1cfea02b872fd80c22ab98d165dc682e2bdb6d57 Mon Sep 17 00:00:00 2001 From: Ahmed Saleh Harby <109473873+A-Harby@users.noreply.github.com> Date: Sun, 10 Nov 2024 17:59:49 +0200 Subject: [PATCH 02/27] Update test_homepage.py --- .../tests/frontend_selenium/tests/TFChain/test_homepage.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/packages/playground/tests/frontend_selenium/tests/TFChain/test_homepage.py b/packages/playground/tests/frontend_selenium/tests/TFChain/test_homepage.py index 8df431b34b..4433076b39 100644 --- a/packages/playground/tests/frontend_selenium/tests/TFChain/test_homepage.py +++ b/packages/playground/tests/frontend_selenium/tests/TFChain/test_homepage.py @@ -63,8 +63,6 @@ def test_stats(browser): grid_proxy = GridProxy(browser) stats = grid_proxy.get_stats_capicity() dashboard_stats = dashboard_page.get_dashboard_stats() - print(stats) - print(dashboard_stats) assert stats == dashboard_stats @@ -185,4 +183,4 @@ def test_login_links(browser): dashboard_page.open_profile() assert dashboard_page.connect_manual_link() == 'https://www.manual.grid.tf/documentation/threefold_token/storing_tft/tf_connect_app.html' assert dashboard_page.get_connect_google_link() == 'https://play.google.com/store/apps/details?id=org.jimber.threebotlogin&hl=en&gl=US' - assert dashboard_page.get_connect_apple_link() == 'https://apps.apple.com/us/app/threefold-connect/id1459845885' \ No newline at end of file + assert dashboard_page.get_connect_apple_link() == 'https://apps.apple.com/us/app/threefold-connect/id1459845885' From cef7d315b2fbe974e43fc4ac16c2bd8f936e0e70 Mon Sep 17 00:00:00 2001 From: Ahmed Saleh Harby <109473873+A-Harby@users.noreply.github.com> Date: Sun, 10 Nov 2024 18:03:26 +0200 Subject: [PATCH 03/27] Update grid_proxy.py --- .../playground/tests/frontend_selenium/utils/grid_proxy.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/playground/tests/frontend_selenium/utils/grid_proxy.py b/packages/playground/tests/frontend_selenium/utils/grid_proxy.py index 3d64d5a05c..b7f3a9b1af 100644 --- a/packages/playground/tests/frontend_selenium/utils/grid_proxy.py +++ b/packages/playground/tests/frontend_selenium/utils/grid_proxy.py @@ -63,7 +63,7 @@ def get_twin_node(self, twin_id): return details def get_stats_capicity(self): - r = requests.post('https://stats.' + Base.net + '.grid.tf/api/stats-summary') + r = requests.post('https://stats.' + Base.net + '.grid.tf/api/stats-summary', timeout=10) stats_json = r.json() return list(stats_json.values()) @@ -98,4 +98,4 @@ def get_stats(self): total_countries = len(merged_distribution) # Total unique countries merged_data['countries'] = total_countries # Return the dictionary directly - return merged_data \ No newline at end of file + return merged_data From 0971c800dec44dea5f1ee68ddbaa6638c2b36421 Mon Sep 17 00:00:00 2001 From: maayarosama Date: Tue, 19 Nov 2024 12:12:26 +0200 Subject: [PATCH 04/27] Fixing manual link redirects to connect wallet docs --- packages/playground/src/utils/manual.ts | 1 + packages/playground/src/weblets/profile_manager.vue | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/packages/playground/src/utils/manual.ts b/packages/playground/src/utils/manual.ts index 0af98de2e3..538324f33a 100644 --- a/packages/playground/src/utils/manual.ts +++ b/packages/playground/src/utils/manual.ts @@ -10,6 +10,7 @@ export const manual = { dao: `${BASE}/documentation/dashboard/tfchain/tf_dao.html`, caprover: `${BASE}/documentation/dashboard/solutions/caprover.html`, tf_connect_app: `${BASE}/documentation/threefold_token/storing_tft/tf_connect_app.html`, + tf_connect_wallet: `${BASE}/documentation/dashboard/wallet_connector.html`, contract_locking: `${BASE}/documentation/developers/tfchain/tfchain.html#contract-locking`, billing_pricing: `${BASE}/documentation/dashboard/deploy/node_finder.html#billing--pricing`, discount_levels: `${BASE}/knowledge_base/cloud/pricing/pricing.html#staking-discount`, diff --git a/packages/playground/src/weblets/profile_manager.vue b/packages/playground/src/weblets/profile_manager.vue index cef65de4da..8a7590b88e 100644 --- a/packages/playground/src/weblets/profile_manager.vue +++ b/packages/playground/src/weblets/profile_manager.vue @@ -72,7 +72,7 @@

Please visit - the manual + the manual get started.

From ba3aaf4c26e0181fa935e9c15085931130efbaec Mon Sep 17 00:00:00 2001 From: saeedr Date: Wed, 20 Nov 2024 16:31:28 +0200 Subject: [PATCH 05/27] update docs to run tests agains mainnet --- .../tests/frontend_selenium/selenium.md | 48 ++++++++++++++----- 1 file changed, 37 insertions(+), 11 deletions(-) diff --git a/packages/playground/tests/frontend_selenium/selenium.md b/packages/playground/tests/frontend_selenium/selenium.md index 92ab10f270..f3c27e8b44 100644 --- a/packages/playground/tests/frontend_selenium/selenium.md +++ b/packages/playground/tests/frontend_selenium/selenium.md @@ -7,17 +7,40 @@ | [requests](https://pypi.org/project/requests/) | `2.31.0` | | [selenium](https://pypi.org/project/selenium/) | `4.10.0` | | [PyVirtualDisplay](https://pypi.org/project/PyVirtualDisplay/) | `3.0` | -| [webdriver-manager](https://pypi.org/project/webdriver-manager/) | `3.9.1` | +| [webdriver-manager](https://pypi.org/project/webdriver-manager/) | `4.0.2` | ## Running selenium + There are two ways to run the Automation selenium tests: + + 1- Run Tests against the local dashboard environment which installed from latest commit on development branch. + 2- Run Tests against any live environment (Devnet, QAnet, Testnet and Mainnet) -### First +### First (Run Tests against local dashboard) +#### Prepare dashboard locally + - In the root directory 'tfgrid-sdk-ts/', run: + + `yarn install` + `yarn lerna run build` + `make run project=playground` + + - You need to leave the localhost running and open a new terminal. -- In the root directory, run `yarn install`, then `yarn lerna run build`, and finally `make run project=playground`. -- Change directory to frontend selenium by running `cd packages/playground/tests/frontend_selenium/` in the command line. -- Install the recommended version of the pip package listed above for a stable run, or you can just install Python 3 and use the command: - - `pip install -r requirements.txt --break-system-packages` (Use this if you don't use any of the listed packages). - - Or use Virtual Environments: First, create an environment using `python -m venv myenv`, then activate it using `source myenv/bin/activate`, and finally, install packages using `pip install -r requirements.txt`. + +### Second (Run Tests against any live environment) +#### update the config files to point to the target environment + - In order to do that; will need to update the env url and some other variables directly in these files config.ini and base.by + - Ex.: to run agains Mainnet + - config.ini: + ``` + [Base] + net = main + ``` + - base.by: + ``` + base_url = 'https://dashboard.grid.tf/' + ``` + +### Setup environment configurations - Add your configuration either in [config.ini](../frontend_selenium/Config.ini) or by exporting `TFCHAIN_MNEMONICS`, `TFCHAIN_NODE_MNEMONICS`, `STELLAR_ADDRESS`, and `EMAIL`. - Description of config under `Base` section: - `port`: the port that the localhost is running on. @@ -28,16 +51,19 @@ - `address`: a stellar address with a TFT trustline that will be used in TFT bridge-related tests. - `email`: a valid email that will be used for all the automated tests. - If the port in serve changes from `5173` for any reason, you should update the `port` under the `Base` section in [config.ini](../frontend_selenium/Config.ini) to reflect the new value. -- You'll also need to install `Xvfb`, Run `sudo apt install xvfb`. -### Second -- You need to leave the localhost running and open a new terminal. +### Prepare tests requirements +- Change directory to frontend selenium by running `cd packages/playground/tests/frontend_selenium/` in the command line. +- Install the recommended version of the pip package listed above for a stable run, or you can just install Python 3 and use the command: + - `pip install -r requirements.txt --break-system-packages` (Use this if you don't use any of the listed packages). + - Or use Virtual Environments: First, create an environment using `python -m venv myenv`, then activate it using `source myenv/bin/activate`, and finally, install packages using `pip install -r requirements.txt`. +- You'll also need to install `Xvfb`, Run `sudo apt install xvfb`. - You can run selenium tests with pytest through the command line using `python3 -m pytest -v`. ### More options to run tests -- If you want to run the tests visually to see how they are running, you need to comment out the lines `16` and `33` in the [conftest.py](../frontend_selenium/tests/conftest.py). +- If you want to run the tests visually to see how they are running, you need to comment out the lines `16` and `34` in the [conftest.py](../frontend_selenium/tests/conftest.py). - You can also run single test file through the command line using `python3 -m pytest -v tests/file/test_file.py`. - You can also run specific test cases through the command line using `python3 -m pytest -v tests/file/test_file.py::test_func`. - You can also run collection of test cases through the command line using `python3 -m pytest -v -k 'test_func or test_func'`. From 4141b63b8fd144bdebdab1196db1e8a513cb1a58 Mon Sep 17 00:00:00 2001 From: saeedr Date: Wed, 20 Nov 2024 16:35:26 +0200 Subject: [PATCH 06/27] Fix homepage tests, update mainnet config needed --- .../tests/frontend_selenium/tests/TFChain/test_homepage.py | 6 +++++- .../playground/tests/frontend_selenium/tests/conftest.py | 3 ++- packages/playground/tests/frontend_selenium/utils/base.py | 5 ++++- .../playground/tests/frontend_selenium/utils/grid_proxy.py | 6 +++++- 4 files changed, 16 insertions(+), 4 deletions(-) diff --git a/packages/playground/tests/frontend_selenium/tests/TFChain/test_homepage.py b/packages/playground/tests/frontend_selenium/tests/TFChain/test_homepage.py index 4433076b39..217620918e 100644 --- a/packages/playground/tests/frontend_selenium/tests/TFChain/test_homepage.py +++ b/packages/playground/tests/frontend_selenium/tests/TFChain/test_homepage.py @@ -24,7 +24,11 @@ def test_validate_homepage_links(browser): """ dashboard_page = before_test_setup(browser) assert dashboard_page.navigate_to_find_more() == ('https://threefold.io/') - assert dashboard_page.navigate_to_explore_capacity() == ( 'https://stats.' + Base.net + '.grid.tf/') + if Base.net == 'main': + stats_url = 'https://stats.grid.tf/' + else: + stats_url = 'https://stats.' + Base.net + '.grid.tf/' + assert dashboard_page.navigate_to_explore_capacity() == ( stats_url ) assert dashboard_page.navigate_to_learn_about_grid() == ('https://www.manual.grid.tf/') diff --git a/packages/playground/tests/frontend_selenium/tests/conftest.py b/packages/playground/tests/frontend_selenium/tests/conftest.py index 50e29c43d8..3aae3f0e30 100644 --- a/packages/playground/tests/frontend_selenium/tests/conftest.py +++ b/packages/playground/tests/frontend_selenium/tests/conftest.py @@ -1,7 +1,7 @@ import pytest from selenium import webdriver from webdriver_manager.chrome import ChromeDriverManager -from selenium.webdriver.chrome.service import Service +from selenium.webdriver.chrome.service import Service as ChromeService from pyvirtualdisplay import Display """ @@ -19,6 +19,7 @@ def browser(): options = webdriver.ChromeOptions() #options.add_extension('extension.crx') # For Adding Extension driver = webdriver.Chrome(options=options) + # driver = webdriver.Chrome(options=options, service=ChromeService(ChromeDriverManager().install())) driver.set_window_size(1920, 1080) # Make its calls wait up to 60 seconds for elements to appear diff --git a/packages/playground/tests/frontend_selenium/utils/base.py b/packages/playground/tests/frontend_selenium/utils/base.py index b9f632e1de..bace6a6f94 100644 --- a/packages/playground/tests/frontend_selenium/utils/base.py +++ b/packages/playground/tests/frontend_selenium/utils/base.py @@ -6,4 +6,7 @@ class Base: port = config['Base']['port'] net = config['Base']['net'] base_url = 'http://localhost:' + str(port) + '/' - gridproxy_url = 'https://gridproxy.' + str(net) + '.grid.tf/' \ No newline at end of file + if str(net) == 'main': + gridproxy_url = 'https://gridproxy.grid.tf/' + else: + gridproxy_url = 'https://gridproxy.' + str(net) + '.grid.tf/' \ No newline at end of file diff --git a/packages/playground/tests/frontend_selenium/utils/grid_proxy.py b/packages/playground/tests/frontend_selenium/utils/grid_proxy.py index b7f3a9b1af..4f301144c8 100644 --- a/packages/playground/tests/frontend_selenium/utils/grid_proxy.py +++ b/packages/playground/tests/frontend_selenium/utils/grid_proxy.py @@ -63,7 +63,11 @@ def get_twin_node(self, twin_id): return details def get_stats_capicity(self): - r = requests.post('https://stats.' + Base.net + '.grid.tf/api/stats-summary', timeout=10) + if Base.net == 'main': + stats_url = 'https://stats.grid.tf/api/stats-summary' + else: + stats_url = 'https://stats.' + Base.net + '.grid.tf/api/stats-summary' + r = requests.post(stats_url, timeout=10) stats_json = r.json() return list(stats_json.values()) From 6cfbdbe746992f3618ffe1e17d8d973944d29819 Mon Sep 17 00:00:00 2001 From: maayarosama Date: Sun, 24 Nov 2024 11:33:17 +0200 Subject: [PATCH 07/27] using url join in with links in manual.ts --- packages/playground/package.json | 1 + packages/playground/src/utils/manual.ts | 33 +++++++++++++------------ 2 files changed, 18 insertions(+), 16 deletions(-) diff --git a/packages/playground/package.json b/packages/playground/package.json index 34f5593cdf..e2a76fbd54 100644 --- a/packages/playground/package.json +++ b/packages/playground/package.json @@ -41,6 +41,7 @@ "mosha-vue-toastify": "^1.0.23", "pinia": "^2.0.32", "qrcode": "^1.5.1", + "url-join": "^5.0.0", "validator": "^13.9.0", "vue": "^3.2.47", "vue-chartjs": "^5.2.0", diff --git a/packages/playground/src/utils/manual.ts b/packages/playground/src/utils/manual.ts index 538324f33a..6bcf104c94 100644 --- a/packages/playground/src/utils/manual.ts +++ b/packages/playground/src/utils/manual.ts @@ -1,19 +1,20 @@ -const BASE = window.env.MANUAL_URL; +import urlJoin from "url-join"; +const BASE = window.env.MANUAL_URL; export const manual = { - dedicated_machines: `${BASE}/documentation/dashboard/deploy/node_finder.html#dedicated-nodes`, - tft_bridges: `${BASE}/documentation/threefold_token/tft_bridges/tft_bridges.html`, - buy_sell_tft: `${BASE}/documentation/threefold_token/buy_sell_tft/buy_sell_tft.html`, - farmers: `${BASE}/documentation/farmers/farmers.html`, - governance: `${BASE}/documentation/dashboard/tfchain/tf_dao.html`, - pricing: `${BASE}/knowledge_base/cloud/pricing/pricing.html`, - dao: `${BASE}/documentation/dashboard/tfchain/tf_dao.html`, - caprover: `${BASE}/documentation/dashboard/solutions/caprover.html`, - tf_connect_app: `${BASE}/documentation/threefold_token/storing_tft/tf_connect_app.html`, - tf_connect_wallet: `${BASE}/documentation/dashboard/wallet_connector.html`, - contract_locking: `${BASE}/documentation/developers/tfchain/tfchain.html#contract-locking`, - billing_pricing: `${BASE}/documentation/dashboard/deploy/node_finder.html#billing--pricing`, - discount_levels: `${BASE}/knowledge_base/cloud/pricing/pricing.html#staking-discount`, - tfchain_stellar_bridge: `${BASE}/documentation/threefold_token/tft_bridges/tfchain_stellar_bridge.html`, - minting_receipts: `${BASE}/documentation/farmers/3node_building/minting_receipts.html`, + dedicated_machines: urlJoin(BASE, "/documentation/dashboard/deploy/node_finder.html#dedicated-nodes"), + tft_bridges: urlJoin(BASE, "/documentation/threefold_token/tft_bridges/tft_bridges.html"), + buy_sell_tft: urlJoin(BASE, "/documentation/threefold_token/buy_sell_tft/buy_sell_tft.html"), + farmers: urlJoin(BASE, "/documentation/farmers/farmers.html"), + governance: urlJoin(BASE, "/documentation/dashboard/tfchain/tf_dao.html"), + pricing: urlJoin(BASE, "/knowledge_base/cloud/pricing/pricing.html"), + dao: urlJoin(BASE, "/documentation/dashboard/tfchain/tf_dao.html"), + caprover: urlJoin(BASE, "/documentation/dashboard/solutions/caprover.html"), + tf_connect_app: urlJoin(BASE, "/documentation/threefold_token/storing_tft/tf_connect_app.html"), + tf_connect_wallet: urlJoin(BASE, "/documentation/dashboard/wallet_connector.html"), + contract_locking: urlJoin(BASE, "/documentation/developers/tfchain/tfchain.html#contract-locking"), + billing_pricing: urlJoin(BASE, "/documentation/dashboard/deploy/node_finder.html#billing--pricing"), + discount_levels: urlJoin(BASE, "/knowledge_base/cloud/pricing/pricing.html#staking-discount"), + tfchain_stellar_bridge: urlJoin(BASE, "/documentation/threefold_token/tft_bridges/tfchain_stellar_bridge.html"), + minting_receipts: urlJoin(BASE, "/documentation/farmers/3node_building/minting_receipts.html"), }; From e5dd45165867349da0fe79a10320116b9c939bd0 Mon Sep 17 00:00:00 2001 From: Omar Kassem Date: Sun, 24 Nov 2024 14:36:34 +0200 Subject: [PATCH 08/27] FIX(NodeDetails/iperf): show error if the result array is empty (#3664) --- .../src/components/node_details_cards/iperf_details_card.vue | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/packages/playground/src/components/node_details_cards/iperf_details_card.vue b/packages/playground/src/components/node_details_cards/iperf_details_card.vue index 3f8cfe6407..0f03ad7385 100644 --- a/packages/playground/src/components/node_details_cards/iperf_details_card.vue +++ b/packages/playground/src/components/node_details_cards/iperf_details_card.vue @@ -70,6 +70,10 @@ export default { downloadSpeed: format(node.download_speed), uploadSpeed: format(node.upload_speed), })); + if (array.length === 0) { + console.error("Empty array returned from the IPerf test"); + throw new Error("Can't get the test results, please try again later."); + } IperfDetails.value = array; return IperfDetails.value; }; From 6a82a7da59605dba195cb4416fccd84e74e1d62d Mon Sep 17 00:00:00 2001 From: saeedr Date: Sun, 24 Nov 2024 14:40:55 +0200 Subject: [PATCH 09/27] fix codacy issues --- .../playground/tests/frontend_selenium/selenium.md | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/packages/playground/tests/frontend_selenium/selenium.md b/packages/playground/tests/frontend_selenium/selenium.md index f3c27e8b44..054f6ac418 100644 --- a/packages/playground/tests/frontend_selenium/selenium.md +++ b/packages/playground/tests/frontend_selenium/selenium.md @@ -16,26 +16,28 @@ 2- Run Tests against any live environment (Devnet, QAnet, Testnet and Mainnet) ### First (Run Tests against local dashboard) + #### Prepare dashboard locally - - In the root directory 'tfgrid-sdk-ts/', run: +- In the root directory 'tfgrid-sdk-ts/', run: `yarn install` `yarn lerna run build` `make run project=playground` - - You need to leave the localhost running and open a new terminal. +- You need to leave the localhost running and open a new terminal. ### Second (Run Tests against any live environment) + #### update the config files to point to the target environment - - In order to do that; will need to update the env url and some other variables directly in these files config.ini and base.by - - Ex.: to run agains Mainnet - - config.ini: +- Update the env url and some other variables directly in these files config.ini and base.by +- Ex.: to run agains Mainnet + - config.ini: ``` [Base] net = main ``` - - base.by: + - base.by: ``` base_url = 'https://dashboard.grid.tf/' ``` From f2ad5c6031dfee098afdbe8133efc1930d9eb300 Mon Sep 17 00:00:00 2001 From: saeedr Date: Sun, 24 Nov 2024 15:03:49 +0200 Subject: [PATCH 10/27] fix codacy errors --- .../playground/tests/frontend_selenium/selenium.md | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/packages/playground/tests/frontend_selenium/selenium.md b/packages/playground/tests/frontend_selenium/selenium.md index 054f6ac418..28751b6e7a 100644 --- a/packages/playground/tests/frontend_selenium/selenium.md +++ b/packages/playground/tests/frontend_selenium/selenium.md @@ -17,19 +17,23 @@ ### First (Run Tests against local dashboard) + #### Prepare dashboard locally -- In the root directory 'tfgrid-sdk-ts/', run: + + - In the root directory 'tfgrid-sdk-ts/', run: `yarn install` `yarn lerna run build` `make run project=playground` -- You need to leave the localhost running and open a new terminal. + - You need to leave the localhost running and open a new terminal. ### Second (Run Tests against any live environment) + #### update the config files to point to the target environment + - Update the env url and some other variables directly in these files config.ini and base.by - Ex.: to run agains Mainnet - config.ini: @@ -43,6 +47,7 @@ ``` ### Setup environment configurations + - Add your configuration either in [config.ini](../frontend_selenium/Config.ini) or by exporting `TFCHAIN_MNEMONICS`, `TFCHAIN_NODE_MNEMONICS`, `STELLAR_ADDRESS`, and `EMAIL`. - Description of config under `Base` section: - `port`: the port that the localhost is running on. @@ -56,6 +61,7 @@ ### Prepare tests requirements + - Change directory to frontend selenium by running `cd packages/playground/tests/frontend_selenium/` in the command line. - Install the recommended version of the pip package listed above for a stable run, or you can just install Python 3 and use the command: - `pip install -r requirements.txt --break-system-packages` (Use this if you don't use any of the listed packages). From 4a3d4e119dd71459027bea4cd948a49d7199047b Mon Sep 17 00:00:00 2001 From: saeedr Date: Sun, 24 Nov 2024 15:11:47 +0200 Subject: [PATCH 11/27] fix codacy error --- .../playground/tests/frontend_selenium/selenium.md | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/packages/playground/tests/frontend_selenium/selenium.md b/packages/playground/tests/frontend_selenium/selenium.md index 28751b6e7a..d53332f91d 100644 --- a/packages/playground/tests/frontend_selenium/selenium.md +++ b/packages/playground/tests/frontend_selenium/selenium.md @@ -17,21 +17,17 @@ ### First (Run Tests against local dashboard) - #### Prepare dashboard locally - - In the root directory 'tfgrid-sdk-ts/', run: +- In the root directory 'tfgrid-sdk-ts/', run: - `yarn install` - `yarn lerna run build` - `make run project=playground` + `yarn install`, `yarn lerna run build`, `make run project=playground` - - You need to leave the localhost running and open a new terminal. +- You need to leave the localhost running and open a new terminal. ### Second (Run Tests against any live environment) - #### update the config files to point to the target environment - Update the env url and some other variables directly in these files config.ini and base.by From 65d5d239e29bd3b67daee10fca0263bb8a9d0133 Mon Sep 17 00:00:00 2001 From: saeedr Date: Sun, 24 Nov 2024 15:18:13 +0200 Subject: [PATCH 12/27] test codacy fix --- .../playground/tests/frontend_selenium/selenium.md | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/packages/playground/tests/frontend_selenium/selenium.md b/packages/playground/tests/frontend_selenium/selenium.md index d53332f91d..6bd7724416 100644 --- a/packages/playground/tests/frontend_selenium/selenium.md +++ b/packages/playground/tests/frontend_selenium/selenium.md @@ -10,6 +10,7 @@ | [webdriver-manager](https://pypi.org/project/webdriver-manager/) | `4.0.2` | ## Running selenium + There are two ways to run the Automation selenium tests: 1- Run Tests against the local dashboard environment which installed from latest commit on development branch. @@ -25,7 +26,6 @@ - You need to leave the localhost running and open a new terminal. - ### Second (Run Tests against any live environment) #### update the config files to point to the target environment @@ -33,14 +33,16 @@ - Update the env url and some other variables directly in these files config.ini and base.by - Ex.: to run agains Mainnet - config.ini: - ``` + ``` [Base] net = main - ``` + + ``` - base.by: - ``` + ``` base_url = 'https://dashboard.grid.tf/' - ``` + + ``` ### Setup environment configurations @@ -55,7 +57,6 @@ - `email`: a valid email that will be used for all the automated tests. - If the port in serve changes from `5173` for any reason, you should update the `port` under the `Base` section in [config.ini](../frontend_selenium/Config.ini) to reflect the new value. - ### Prepare tests requirements - Change directory to frontend selenium by running `cd packages/playground/tests/frontend_selenium/` in the command line. From 05d105d7fc2939bfff5ae56124410842139bf3ef Mon Sep 17 00:00:00 2001 From: saeedr Date: Sun, 24 Nov 2024 15:25:55 +0200 Subject: [PATCH 13/27] test codacy fix --- .../tests/frontend_selenium/selenium.md | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/packages/playground/tests/frontend_selenium/selenium.md b/packages/playground/tests/frontend_selenium/selenium.md index 6bd7724416..8d455bbf23 100644 --- a/packages/playground/tests/frontend_selenium/selenium.md +++ b/packages/playground/tests/frontend_selenium/selenium.md @@ -33,16 +33,14 @@ - Update the env url and some other variables directly in these files config.ini and base.by - Ex.: to run agains Mainnet - config.ini: - ``` - [Base] - net = main - - ``` + ``` + [Base] + net = main + ``` - base.by: - ``` - base_url = 'https://dashboard.grid.tf/' - - ``` + ``` + base_url = 'https://dashboard.grid.tf/' + ``` ### Setup environment configurations From b8655dececa86138145062239e8c34743684b93f Mon Sep 17 00:00:00 2001 From: saeedr Date: Sun, 24 Nov 2024 15:43:12 +0200 Subject: [PATCH 14/27] test codacy bash fix --- packages/playground/tests/frontend_selenium/selenium.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/playground/tests/frontend_selenium/selenium.md b/packages/playground/tests/frontend_selenium/selenium.md index 8d455bbf23..ec6c237956 100644 --- a/packages/playground/tests/frontend_selenium/selenium.md +++ b/packages/playground/tests/frontend_selenium/selenium.md @@ -33,12 +33,12 @@ - Update the env url and some other variables directly in these files config.ini and base.by - Ex.: to run agains Mainnet - config.ini: - ``` + ```bash [Base] net = main ``` - base.by: - ``` + ```bash base_url = 'https://dashboard.grid.tf/' ``` From a7218fee2da28858739e763994db33d001dbe619 Mon Sep 17 00:00:00 2001 From: saeedr Date: Sun, 24 Nov 2024 15:48:29 +0200 Subject: [PATCH 15/27] codacy fix --- .../tests/frontend_selenium/selenium.md | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/packages/playground/tests/frontend_selenium/selenium.md b/packages/playground/tests/frontend_selenium/selenium.md index ec6c237956..e6b801bdef 100644 --- a/packages/playground/tests/frontend_selenium/selenium.md +++ b/packages/playground/tests/frontend_selenium/selenium.md @@ -32,15 +32,17 @@ - Update the env url and some other variables directly in these files config.ini and base.by - Ex.: to run agains Mainnet - - config.ini: - ```bash - [Base] - net = main - ``` - - base.by: + + - config.ini + ```bash + [Base] + net = main + ``` + + - base.by ```bash - base_url = 'https://dashboard.grid.tf/' - ``` + base_url = "https://dashboard.grid.tf/" + ``` ### Setup environment configurations From 90d20ba925c3fc168adcc3dde2e2f721bbb1906e Mon Sep 17 00:00:00 2001 From: ramezsaeed Date: Sun, 24 Nov 2024 16:05:07 +0200 Subject: [PATCH 16/27] Update selenium.md --- packages/playground/tests/frontend_selenium/selenium.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/playground/tests/frontend_selenium/selenium.md b/packages/playground/tests/frontend_selenium/selenium.md index e6b801bdef..ff5e5007d3 100644 --- a/packages/playground/tests/frontend_selenium/selenium.md +++ b/packages/playground/tests/frontend_selenium/selenium.md @@ -36,8 +36,8 @@ - config.ini ```bash [Base] - net = main - ``` + net = main + ``` - base.by ```bash From c93c13947842ea3b41783d9d12cafc5dc3ddf604 Mon Sep 17 00:00:00 2001 From: ramezsaeed Date: Sun, 24 Nov 2024 16:08:39 +0200 Subject: [PATCH 17/27] Update selenium.md --- packages/playground/tests/frontend_selenium/selenium.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/packages/playground/tests/frontend_selenium/selenium.md b/packages/playground/tests/frontend_selenium/selenium.md index ff5e5007d3..edbb6d1053 100644 --- a/packages/playground/tests/frontend_selenium/selenium.md +++ b/packages/playground/tests/frontend_selenium/selenium.md @@ -34,10 +34,10 @@ - Ex.: to run agains Mainnet - config.ini - ```bash - [Base] - net = main - ``` + ```bash + [Base] + net = main + ``` - base.by ```bash From d5e254a87a3273902478b4ef33804261c87222a6 Mon Sep 17 00:00:00 2001 From: ahmedhanafy725 Date: Sun, 24 Nov 2024 16:45:14 +0200 Subject: [PATCH 18/27] Fix the markdown formating for the selenium tests docs --- .../tests/frontend_selenium/selenium.md | 31 ++++++++++++------- 1 file changed, 19 insertions(+), 12 deletions(-) diff --git a/packages/playground/tests/frontend_selenium/selenium.md b/packages/playground/tests/frontend_selenium/selenium.md index edbb6d1053..b2617ec4fd 100644 --- a/packages/playground/tests/frontend_selenium/selenium.md +++ b/packages/playground/tests/frontend_selenium/selenium.md @@ -11,36 +11,43 @@ ## Running selenium - There are two ways to run the Automation selenium tests: - - 1- Run Tests against the local dashboard environment which installed from latest commit on development branch. - 2- Run Tests against any live environment (Devnet, QAnet, Testnet and Mainnet) +There are two ways to run the Automation selenium tests: + +- Run Tests against the local dashboard environment which installed from latest commit on development branch. + +- Run Tests against any live environment (Devnet, QAnet, Testnet and Mainnet) ### First (Run Tests against local dashboard) #### Prepare dashboard locally - In the root directory 'tfgrid-sdk-ts/', run: - - `yarn install`, `yarn lerna run build`, `make run project=playground` - + + ```bash + yarn install + yarn lerna run build + make run project=playground + ``` + - You need to leave the localhost running and open a new terminal. ### Second (Run Tests against any live environment) #### update the config files to point to the target environment -- Update the env url and some other variables directly in these files config.ini and base.by -- Ex.: to run agains Mainnet +- Update the env url and some other variables directly in these files config.ini and base.py +- Ex.: to run against Mainnet - config.ini - ```bash + + ```ini [Base] net = main ``` - - base.by - ```bash + - base.py + + ```python base_url = "https://dashboard.grid.tf/" ``` From 742f81e77ba3d0ec16f243f7c60c48d5677f1ce8 Mon Sep 17 00:00:00 2001 From: AhmedHanafy725 <41957921+AhmedHanafy725@users.noreply.github.com> Date: Mon, 2 Dec 2024 17:51:16 +0200 Subject: [PATCH 19/27] fix: packages/UI/package.json to reduce vulnerabilities (#3683) The following vulnerabilities are fixed with an upgrade: - https://snyk.io/vuln/SNYK-JS-AXIOS-6671926 Co-authored-by: snyk-bot --- packages/UI/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/UI/package.json b/packages/UI/package.json index 2539673cf2..5ffa60ab16 100644 --- a/packages/UI/package.json +++ b/packages/UI/package.json @@ -20,7 +20,7 @@ "dependencies": { "@polkadot/keyring": "^12.4.2", "@threefold/extension_api": "^0.0.1-rc6", - "axios": "1.7.4", + "axios": "1.7.8", "buffer": "^6.0.3", "crypto-js": "^4.2.0", "html-parsed-element": "^0.4.1", From c4b57da4e1fa1063cc9af1cad7386a6a8c18bb8f Mon Sep 17 00:00:00 2001 From: Mik <77026219+Mik-TF@users.noreply.github.com> Date: Wed, 4 Dec 2024 06:54:38 -0500 Subject: [PATCH 20/27] add manual links for minting process and reports in manual.ts (#3701) --- packages/playground/src/utils/manual.ts | 2 ++ packages/playground/src/views/minting_view.vue | 4 ++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/packages/playground/src/utils/manual.ts b/packages/playground/src/utils/manual.ts index 6bcf104c94..7f77c606ff 100644 --- a/packages/playground/src/utils/manual.ts +++ b/packages/playground/src/utils/manual.ts @@ -17,4 +17,6 @@ export const manual = { discount_levels: urlJoin(BASE, "/knowledge_base/cloud/pricing/pricing.html#staking-discount"), tfchain_stellar_bridge: urlJoin(BASE, "/documentation/threefold_token/tft_bridges/tfchain_stellar_bridge.html"), minting_receipts: urlJoin(BASE, "/documentation/farmers/3node_building/minting_receipts.html"), + minting_process: urlJoin(BASE, "/documentation/farmers/farming_optimization/minting_process.html"), + minting_reports: urlJoin(BASE, "/documentation/dashboard/tfchain/tf_minting_reports.html"), }; diff --git a/packages/playground/src/views/minting_view.vue b/packages/playground/src/views/minting_view.vue index e77183760f..9d3d67abcd 100644 --- a/packages/playground/src/views/minting_view.vue +++ b/packages/playground/src/views/minting_view.vue @@ -9,7 +9,7 @@ TFT minting process.
@@ -17,7 +17,7 @@ minting tool.
From 1c2760c2a6fd6e21647f7c131938e7823158da39 Mon Sep 17 00:00:00 2001 From: maayarosama Date: Thu, 5 Dec 2024 12:52:37 +0200 Subject: [PATCH 21/27] Removing hdd storage repoting from stats --- packages/playground/src/views/stats.vue | 1 - packages/stats/src/components/stats_table.vue | 5 ----- 2 files changed, 6 deletions(-) diff --git a/packages/playground/src/views/stats.vue b/packages/playground/src/views/stats.vue index bfe43b3f7a..da0767e272 100644 --- a/packages/playground/src/views/stats.vue +++ b/packages/playground/src/views/stats.vue @@ -141,7 +141,6 @@ const fetchData = async () => { { data: stats!.countries, title: "Countries", icon: "mdi-earth" }, { data: stats!.totalCru, title: "CPUs", icon: "mdi-cpu-64-bit" }, { data: formatResourceSize(stats!.totalSru), title: "SSD Storage", icon: "mdi-nas" }, - { data: formatResourceSize(stats!.totalHru), title: "HDD Storage", icon: "mdi-harddisk" }, { data: formatResourceSize(stats!.totalMru), title: "RAM", icon: "mdi-memory" }, { data: stats!.gpus, title: "GPUs", icon: "mdi-memory" }, { data: stats!.accessNodes, title: "Access Nodes", icon: "mdi-gate" }, diff --git a/packages/stats/src/components/stats_table.vue b/packages/stats/src/components/stats_table.vue index 2d1c80aa37..2a8ebc737a 100644 --- a/packages/stats/src/components/stats_table.vue +++ b/packages/stats/src/components/stats_table.vue @@ -84,11 +84,6 @@ const Istats = computed((): IStatistics[] => { { data: formattedStats.value.totalCru, title: "CPUs", icon: "mdi-cpu-64-bit" }, { data: formattedStats.value.gpus, title: "GPUs", icon: "mdi-memory" }, { data: toTeraOrGigaOrPeta(formattedStats.value.totalSru.toString()), title: "SSD Storage", icon: "mdi-nas" }, - { - data: toTeraOrGigaOrPeta(formattedStats.value.totalHru.toString()), - title: "HDD Storage", - icon: "mdi-harddisk", - }, { data: toTeraOrGigaOrPeta(formattedStats.value.totalMru.toString()), title: "RAM", icon: "mdi-memory" }, { data: formattedStats.value.accessNodes, title: "Access Nodes", icon: "mdi-gate" }, { data: formattedStats.value.gateways, title: "Gateways", icon: "mdi-boom-gate-outline" }, From f5ee485e57973bdbc48d83666a8e21e821fac9be Mon Sep 17 00:00:00 2001 From: maayarosama Date: Thu, 5 Dec 2024 13:03:40 +0200 Subject: [PATCH 22/27] Fixing cols and md --- packages/playground/src/views/stats.vue | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/packages/playground/src/views/stats.vue b/packages/playground/src/views/stats.vue index da0767e272..be3a506463 100644 --- a/packages/playground/src/views/stats.vue +++ b/packages/playground/src/views/stats.vue @@ -29,13 +29,7 @@ - + From b1f0bee2ca8c1829836f05f8c41f305bf38ba4cd Mon Sep 17 00:00:00 2001 From: maayarosama Date: Thu, 5 Dec 2024 14:30:22 +0200 Subject: [PATCH 23/27] Adding ssd to stats summary endpoint --- packages/playground/src/stores/stats.ts | 2 +- packages/stats/nginx/njs/stats.js | 20 +++++++++++++++++++- 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/packages/playground/src/stores/stats.ts b/packages/playground/src/stores/stats.ts index 60625ed3b6..ac45479b93 100644 --- a/packages/playground/src/stores/stats.ts +++ b/packages/playground/src/stores/stats.ts @@ -12,7 +12,7 @@ export const useStatsStore = defineStore("stats-store", () => { const stats = computed(() => [ { label: "Capacity", - value: data.value?.capacity, + value: data.value?.ssd, image: "capacity.png", }, { diff --git a/packages/stats/nginx/njs/stats.js b/packages/stats/nginx/njs/stats.js index 73d848ffc5..5eaf0e8246 100644 --- a/packages/stats/nginx/njs/stats.js +++ b/packages/stats/nginx/njs/stats.js @@ -78,10 +78,10 @@ function mergeStatsData(stats) { const result = {}; result.capacity = toTeraOrGiga(res.totalHru + res.totalSru); + result.ssd = toTeraOrGigaStats(res.totalSru); result.nodes = res.nodes; result.countries = res.countries; result.cores = res.totalCru; - return result; } @@ -131,5 +131,23 @@ function toTeraOrGiga(value) { return gb.toFixed(2) + " PB"; } +function toTeraOrGigaStats(value) { + const giga = 1024 ** 3; + + if (!value) return "0 GB"; + + const val = +value; + if (val === 0 || isNaN(val)) return "0 GB"; + + const gb = val / giga; + + if (gb < 100) { + return gb.toFixed(2) + " GB"; + } + + const tb = gb / 1024; + return tb.toFixed(2) + " TB"; +} + // Exporting the main function for Nginx export default { getStats, updateStats }; From bb9bb36479e4c23be42f6d7f8538742cdfa5f50b Mon Sep 17 00:00:00 2001 From: maayarosama Date: Thu, 5 Dec 2024 14:53:48 +0200 Subject: [PATCH 24/27] Changing capacity label and changing ssd capacity to tb or gb in stats --- packages/playground/src/stores/stats.ts | 2 +- .../src/utils/format_resource_size.ts | 18 ++++++++++++++++++ packages/playground/src/views/stats.vue | 4 ++-- packages/stats/nginx/njs/stats.js | 2 +- packages/stats/src/components/stats_table.vue | 4 ++-- packages/stats/src/utils/toTeraOrGegaOrPeta.ts | 18 ++++++++++++++++++ 6 files changed, 42 insertions(+), 6 deletions(-) diff --git a/packages/playground/src/stores/stats.ts b/packages/playground/src/stores/stats.ts index ac45479b93..c752de7162 100644 --- a/packages/playground/src/stores/stats.ts +++ b/packages/playground/src/stores/stats.ts @@ -11,7 +11,7 @@ export const useStatsStore = defineStore("stats-store", () => { const data = computed(() => res.value.data); const stats = computed(() => [ { - label: "Capacity", + label: "SSD Capacity", value: data.value?.ssd, image: "capacity.png", }, diff --git a/packages/playground/src/utils/format_resource_size.ts b/packages/playground/src/utils/format_resource_size.ts index afd8862bcf..ba249a5679 100644 --- a/packages/playground/src/utils/format_resource_size.ts +++ b/packages/playground/src/utils/format_resource_size.ts @@ -49,3 +49,21 @@ function toFixedTwo(val: number) { function formatSpeed(val: number) { return Math.round(val); } + +export function toTeraOrGigaStats(sizeInBytes: number) { + const giga = 1024 ** 3; + + if (!sizeInBytes) return "0 GB"; + + const val = +sizeInBytes; + if (val === 0 || isNaN(val)) return "0 GB"; + + const gb = val / giga; + + if (gb < 100) { + return gb.toFixed(2) + " GB"; + } + + const tb = gb / 1024; + return tb.toFixed(2) + " TB"; +} diff --git a/packages/playground/src/views/stats.vue b/packages/playground/src/views/stats.vue index be3a506463..204419751c 100644 --- a/packages/playground/src/views/stats.vue +++ b/packages/playground/src/views/stats.vue @@ -44,7 +44,7 @@ import { NodeStatus, type Stats as GridProxyStats } from "@threefold/gridproxy_client"; import { onMounted, ref } from "vue"; -import formatResourceSize from "@/utils/format_resource_size"; +import formatResourceSize, { toTeraOrGigaStats } from "@/utils/format_resource_size"; import { gridProxyClient } from "../clients"; import StatisticsCard from "../components/statistics_card.vue"; @@ -134,7 +134,7 @@ const fetchData = async () => { { data: stats!.farms, title: "Farms", icon: "mdi-tractor" }, { data: stats!.countries, title: "Countries", icon: "mdi-earth" }, { data: stats!.totalCru, title: "CPUs", icon: "mdi-cpu-64-bit" }, - { data: formatResourceSize(stats!.totalSru), title: "SSD Storage", icon: "mdi-nas" }, + { data: toTeraOrGigaStats(stats!.totalSru), title: "SSD Storage", icon: "mdi-nas" }, { data: formatResourceSize(stats!.totalMru), title: "RAM", icon: "mdi-memory" }, { data: stats!.gpus, title: "GPUs", icon: "mdi-memory" }, { data: stats!.accessNodes, title: "Access Nodes", icon: "mdi-gate" }, diff --git a/packages/stats/nginx/njs/stats.js b/packages/stats/nginx/njs/stats.js index 5eaf0e8246..e7f8336e65 100644 --- a/packages/stats/nginx/njs/stats.js +++ b/packages/stats/nginx/njs/stats.js @@ -131,7 +131,7 @@ function toTeraOrGiga(value) { return gb.toFixed(2) + " PB"; } -function toTeraOrGigaStats(value) { +export function toTeraOrGigaStats(value) { const giga = 1024 ** 3; if (!value) return "0 GB"; diff --git a/packages/stats/src/components/stats_table.vue b/packages/stats/src/components/stats_table.vue index 2a8ebc737a..6e5acf54d2 100644 --- a/packages/stats/src/components/stats_table.vue +++ b/packages/stats/src/components/stats_table.vue @@ -51,7 +51,7 @@ import { computed, type PropType, type Ref, ref, watch } from "vue"; import type { IStatistics, NetworkStats } from "../types/index"; import { formatData, getStats } from "../utils/stats"; -import toTeraOrGigaOrPeta from "../utils/toTeraOrGegaOrPeta"; +import toTeraOrGigaOrPeta, { toTeraOrGigaStats } from "../utils/toTeraOrGegaOrPeta"; import StatisticsCard from "./statistics_card.vue"; const props = defineProps({ @@ -83,7 +83,7 @@ const Istats = computed((): IStatistics[] => { { data: formattedStats.value.countries, title: "Countries", icon: "mdi-earth" }, { data: formattedStats.value.totalCru, title: "CPUs", icon: "mdi-cpu-64-bit" }, { data: formattedStats.value.gpus, title: "GPUs", icon: "mdi-memory" }, - { data: toTeraOrGigaOrPeta(formattedStats.value.totalSru.toString()), title: "SSD Storage", icon: "mdi-nas" }, + { data: toTeraOrGigaStats(formattedStats.value.totalSru.toString()), title: "SSD Storage", icon: "mdi-nas" }, { data: toTeraOrGigaOrPeta(formattedStats.value.totalMru.toString()), title: "RAM", icon: "mdi-memory" }, { data: formattedStats.value.accessNodes, title: "Access Nodes", icon: "mdi-gate" }, { data: formattedStats.value.gateways, title: "Gateways", icon: "mdi-boom-gate-outline" }, diff --git a/packages/stats/src/utils/toTeraOrGegaOrPeta.ts b/packages/stats/src/utils/toTeraOrGegaOrPeta.ts index a03d29f835..b7afdc58f9 100644 --- a/packages/stats/src/utils/toTeraOrGegaOrPeta.ts +++ b/packages/stats/src/utils/toTeraOrGegaOrPeta.ts @@ -19,3 +19,21 @@ export default function toTeraOrGiga(value?: string) { gb = gb / 1024; return `${gb.toFixed(2)} PB`; } + +export function toTeraOrGigaStats(value?: string) { + const giga = 1024 ** 3; + + if (!value) return "0 GB"; + + const val = +value; + if (val === 0 || isNaN(val)) return "0 GB"; + + const gb = val / giga; + + if (gb < 100) { + return gb.toFixed(2) + " GB"; + } + + const tb = gb / 1024; + return tb.toFixed(2) + " TB"; +} From fcfbbb5c4fcca9aba8a62d3d9b1fd878a2ac60eb Mon Sep 17 00:00:00 2001 From: ahmedhanafy725 Date: Thu, 5 Dec 2024 15:12:44 +0200 Subject: [PATCH 25/27] Upgrade the charts and values files version to 2.6.1 --- packages/playground/playground-charts/Chart.yaml | 2 +- packages/playground/playground-charts/values.yaml | 2 +- packages/stats/chart/Chart.yaml | 2 +- packages/stats/chart/values.yaml | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/packages/playground/playground-charts/Chart.yaml b/packages/playground/playground-charts/Chart.yaml index f7dd880c5d..425f6af129 100644 --- a/packages/playground/playground-charts/Chart.yaml +++ b/packages/playground/playground-charts/Chart.yaml @@ -21,4 +21,4 @@ version: 0.1.0 # incremented each time you make changes to the application. Versions are not expected to # follow Semantic Versioning. They should reflect the version the application is using. # It is recommended to use it with quotes. -appVersion: "v2.6.0" +appVersion: "v2.6.1" diff --git a/packages/playground/playground-charts/values.yaml b/packages/playground/playground-charts/values.yaml index 054995022a..d0e99fa9ff 100644 --- a/packages/playground/playground-charts/values.yaml +++ b/packages/playground/playground-charts/values.yaml @@ -8,7 +8,7 @@ image: repository: ghcr.io/threefoldtech/playground pullPolicy: Always # Overrides the image tag whose default is the chart appVersion. - tag: "2.6.0" + tag: "2.6.1" env: - name: "MODE" diff --git a/packages/stats/chart/Chart.yaml b/packages/stats/chart/Chart.yaml index 75cd97bb76..d0a5bee84c 100644 --- a/packages/stats/chart/Chart.yaml +++ b/packages/stats/chart/Chart.yaml @@ -21,4 +21,4 @@ version: 1.0.0 # incremented each time you make changes to the application. Versions are not expected to # follow Semantic Versioning. They should reflect the version the application is using. # It is recommended to use it with quotes. -appVersion: "v2.6.0" +appVersion: "v2.6.1" diff --git a/packages/stats/chart/values.yaml b/packages/stats/chart/values.yaml index 46ff46b0d3..8c6b3d211f 100644 --- a/packages/stats/chart/values.yaml +++ b/packages/stats/chart/values.yaml @@ -4,7 +4,7 @@ image: repository: ghcr.io/threefoldtech/stats pullPolicy: Always # Overrides the image tag whose default is the chart appVersion. - tag: "2.6.0" + tag: "2.6.1" imagePullSecrets: [] nameOverride: "" From 031faa0421ee1dfdf48c8cd93782c74324aca039 Mon Sep 17 00:00:00 2001 From: ahmedhanafy725 Date: Thu, 5 Dec 2024 15:13:38 +0200 Subject: [PATCH 26/27] v2.6.1 --- lerna.json | 2 +- packages/UI/package.json | 2 +- packages/graphql_client/package.json | 4 ++-- packages/grid_client/package.json | 12 ++++++------ packages/grid_http_server/package.json | 4 ++-- packages/grid_rmb_server/package.json | 8 ++++---- packages/gridproxy_client/package.json | 2 +- packages/monitoring/package.json | 8 ++++---- packages/playground/package.json | 12 ++++++------ packages/rmb_direct_client/package.json | 6 +++--- packages/rmb_peer_client/package.json | 2 +- packages/rmb_peer_server/package.json | 2 +- packages/stats/package.json | 4 ++-- packages/tfchain_client/package.json | 4 ++-- packages/types/package.json | 2 +- 15 files changed, 37 insertions(+), 37 deletions(-) diff --git a/lerna.json b/lerna.json index f02311292a..8de3ee638f 100644 --- a/lerna.json +++ b/lerna.json @@ -1,5 +1,5 @@ { "$schema": "node_modules/lerna/schemas/lerna-schema.json", - "version": "2.6.0", + "version": "2.6.1", "npmClient": "yarn" } diff --git a/packages/UI/package.json b/packages/UI/package.json index 5ffa60ab16..8e98489776 100644 --- a/packages/UI/package.json +++ b/packages/UI/package.json @@ -1,6 +1,6 @@ { "name": "@threefold/ui", - "version": "2.6.0", + "version": "2.6.1", "private": false, "main": "dist/threefold-ui.umd.js", "publishConfig": { diff --git a/packages/graphql_client/package.json b/packages/graphql_client/package.json index 5fde89adba..ff0d17b125 100644 --- a/packages/graphql_client/package.json +++ b/packages/graphql_client/package.json @@ -1,6 +1,6 @@ { "name": "@threefold/graphql_client", - "version": "2.6.0", + "version": "2.6.1", "main": "./dist/node/index.js", "module": "./dist/es6/index.js", "exports": { @@ -18,7 +18,7 @@ "es6-build": "tsc --build tsconfig.json" }, "dependencies": { - "@threefold/types": "2.6.0", + "@threefold/types": "^2.6.1", "ts-mixer": "^6.0.2" }, "devDependencies": { diff --git a/packages/grid_client/package.json b/packages/grid_client/package.json index dff04e4275..3636cb3fdb 100644 --- a/packages/grid_client/package.json +++ b/packages/grid_client/package.json @@ -1,7 +1,7 @@ { "name": "@threefold/grid_client", "author": "Ahmed Hanafy", - "version": "2.6.0", + "version": "2.6.1", "license": "ISC", "homepage": "https://github.com/threefoldtech/tfgrid-sdk-ts/tree/development/packages/grid_client/README.md", "repository": { @@ -14,11 +14,11 @@ "dependencies": { "@jimber/pkid": "1.0.4", "@noble/secp256k1": "^1.7.1", - "@threefold/gridproxy_client": "2.6.0", - "@threefold/monitoring": "2.6.0", - "@threefold/rmb_direct_client": "2.6.0", - "@threefold/tfchain_client": "2.6.0", - "@threefold/types": "2.6.0", + "@threefold/gridproxy_client": "^2.6.1", + "@threefold/monitoring": "^2.6.1", + "@threefold/rmb_direct_client": "^2.6.1", + "@threefold/tfchain_client": "^2.6.1", + "@threefold/types": "^2.6.1", "algosdk": "^1.19.0", "appdata-path": "^1.0.0", "await-lock": "^2.2.2", diff --git a/packages/grid_http_server/package.json b/packages/grid_http_server/package.json index b50eae39bc..f2b6d8f2bc 100644 --- a/packages/grid_http_server/package.json +++ b/packages/grid_http_server/package.json @@ -1,7 +1,7 @@ { "name": "@threefold/grid_http_server", "author": "Ahmed Hanafy", - "version": "2.6.0", + "version": "2.6.1", "license": "ISC", "homepage": "https://github.com/threefoldtech/tfgrid-sdk-ts/blob/development/packages/grid_http_server/README.md", "repository": { @@ -12,7 +12,7 @@ "access": "public" }, "dependencies": { - "@threefold/grid_client": "2.6.0", + "@threefold/grid_client": "^2.6.1", "express": "^4.21.1", "http-server": "^14.1.1", "typescript": "^4.7.4" diff --git a/packages/grid_rmb_server/package.json b/packages/grid_rmb_server/package.json index 5553b1792a..f9a501b4fa 100644 --- a/packages/grid_rmb_server/package.json +++ b/packages/grid_rmb_server/package.json @@ -1,7 +1,7 @@ { "name": "@threefold/grid_rmb_server", "author": "Ahmed Hanafy", - "version": "2.6.0", + "version": "2.6.1", "license": "ISC", "homepage": "https://github.com/threefoldtech/tfgrid-sdk-ts/blob/development/packages/grid_rmb_server/README.md", "repository": { @@ -12,12 +12,12 @@ "access": "public" }, "dependencies": { - "@threefold/grid_client": "2.6.0", - "@threefold/rmb_peer_server": "2.6.0", + "@threefold/grid_client": "^2.6.1", + "@threefold/rmb_peer_server": "^2.6.1", "typescript": "^4.7.4" }, "devDependencies": { - "@threefold/rmb_peer_client": "2.6.0", + "@threefold/rmb_peer_client": "^2.6.1", "ts-node": "^10.9.1" }, "main": "./dist/index.js", diff --git a/packages/gridproxy_client/package.json b/packages/gridproxy_client/package.json index 78e18281b6..a7d116f6c9 100644 --- a/packages/gridproxy_client/package.json +++ b/packages/gridproxy_client/package.json @@ -1,6 +1,6 @@ { "name": "@threefold/gridproxy_client", - "version": "2.6.0", + "version": "2.6.1", "description": "gridproxy_client help to interact with gridproxy based on network", "main": "./dist/node/public_api.js", "module": "./dist/es6/public_api.js", diff --git a/packages/monitoring/package.json b/packages/monitoring/package.json index 846bf0daef..03ba618be7 100644 --- a/packages/monitoring/package.json +++ b/packages/monitoring/package.json @@ -1,6 +1,6 @@ { "name": "@threefold/monitoring", - "version": "2.6.0", + "version": "2.6.1", "description": "Threefold monitoring package", "license": "Apache-2.0", "main": "./dist/node/index.js", @@ -26,9 +26,9 @@ "access": "public" }, "dependencies": { - "@threefold/rmb_direct_client": "2.6.0", - "@threefold/tfchain_client": "2.6.0", - "@threefold/types": "2.6.0", + "@threefold/rmb_direct_client": "^2.6.1", + "@threefold/tfchain_client": "^2.6.1", + "@threefold/types": "^2.6.1", "chalk": "4.1.2", "ts-node": "^10.9.1", "typescript": "^5.3.3", diff --git a/packages/playground/package.json b/packages/playground/package.json index e2a76fbd54..f31ff04de9 100644 --- a/packages/playground/package.json +++ b/packages/playground/package.json @@ -1,6 +1,6 @@ { "name": "@threefold/playground", - "version": "2.6.0", + "version": "2.6.1", "private": true, "scripts": { "dev": "vite", @@ -13,11 +13,11 @@ "dependencies": { "@mdi/font": "^7.2.96", "@sentry/vue": "^8.19.0", - "@threefold/graphql_client": "2.6.0", - "@threefold/grid_client": "2.6.0", - "@threefold/gridproxy_client": "2.6.0", - "@threefold/monitoring": "2.6.0", - "@threefold/types": "2.6.0", + "@threefold/graphql_client": "^2.6.1", + "@threefold/grid_client": "^2.6.1", + "@threefold/gridproxy_client": "^2.6.1", + "@threefold/monitoring": "^2.6.1", + "@threefold/types": "^2.6.1", "@types/ip": "^1.1.3", "@types/md5": "^2.3.5", "await-lock": "^2.2.2", diff --git a/packages/rmb_direct_client/package.json b/packages/rmb_direct_client/package.json index 0a38c5c10d..a4e72a4862 100644 --- a/packages/rmb_direct_client/package.json +++ b/packages/rmb_direct_client/package.json @@ -1,6 +1,6 @@ { "name": "@threefold/rmb_direct_client", - "version": "2.6.0", + "version": "2.6.1", "repository": { "type": "git", "url": "https://github.com/threefoldtech/tfgrid-sdk-ts.git" @@ -23,8 +23,8 @@ "dependencies": { "@noble/secp256k1": "^1.7.1", "@polkadot/api": "^8.9.1", - "@threefold/tfchain_client": "2.6.0", - "@threefold/types": "2.6.0", + "@threefold/tfchain_client": "^2.6.1", + "@threefold/types": "^2.6.1", "base64url": "^3.0.1", "bip39": "^3.1.0", "buffer": "^6.0.3", diff --git a/packages/rmb_peer_client/package.json b/packages/rmb_peer_client/package.json index 51d9d6e086..772ce62142 100644 --- a/packages/rmb_peer_client/package.json +++ b/packages/rmb_peer_client/package.json @@ -1,7 +1,7 @@ { "name": "@threefold/rmb_peer_client", "author": "Ahmed Hanafy", - "version": "2.6.0", + "version": "2.6.1", "license": "ISC", "homepage": "https://github.com/threefoldtech/tfgrid-sdk-ts/blob/development/packages/rmb_peer_client/README.md", "repository": { diff --git a/packages/rmb_peer_server/package.json b/packages/rmb_peer_server/package.json index 0df6efe41d..5606213bcb 100644 --- a/packages/rmb_peer_server/package.json +++ b/packages/rmb_peer_server/package.json @@ -1,7 +1,7 @@ { "name": "@threefold/rmb_peer_server", "author": "Ahmed Hanafy", - "version": "2.6.0", + "version": "2.6.1", "license": "ISC", "homepage": "https://github.com/threefoldtech/tfgrid-sdk-ts/blob/development/packages/rmb_peer_server/README.md", "repository": { diff --git a/packages/stats/package.json b/packages/stats/package.json index 577afecf70..1f88086679 100644 --- a/packages/stats/package.json +++ b/packages/stats/package.json @@ -1,6 +1,6 @@ { "name": "@threefold/stats", - "version": "2.6.0", + "version": "2.6.1", "private": true, "scripts": { "dev": "vite", @@ -11,7 +11,7 @@ "type-check": "vue-tsc --noEmit -p tsconfig.vitest.json --composite false" }, "dependencies": { - "@threefold/gridproxy_client": "2.6.0", + "@threefold/gridproxy_client": "^2.6.1", "vue": "^3.3.5", "vuetify": "^3.3.21" }, diff --git a/packages/tfchain_client/package.json b/packages/tfchain_client/package.json index 998eadab8c..924e2a4571 100644 --- a/packages/tfchain_client/package.json +++ b/packages/tfchain_client/package.json @@ -1,6 +1,6 @@ { "name": "@threefold/tfchain_client", - "version": "2.6.0", + "version": "2.6.1", "description": "A client for TF chain", "private": false, "publishConfig": { @@ -48,7 +48,7 @@ }, "dependencies": { "@polkadot/api": "^8.9.1", - "@threefold/types": "2.6.0", + "@threefold/types": "^2.6.1", "await-lock": "^2.2.2", "bip39": "^3.1.0", "moment": "^2.30.1" diff --git a/packages/types/package.json b/packages/types/package.json index 40af6e680c..1526ba6cab 100644 --- a/packages/types/package.json +++ b/packages/types/package.json @@ -1,6 +1,6 @@ { "name": "@threefold/types", - "version": "2.6.0", + "version": "2.6.1", "main": "dist/node/index.js", "types": "dist/es6/index.d.ts", "scripts": { From 08b50d4c57561b63b146b1f4c8c65dbe288abc10 Mon Sep 17 00:00:00 2001 From: Omar Kassem Date: Sun, 8 Dec 2024 14:26:18 +0200 Subject: [PATCH 27/27] FIX(Status(NJS) remove syntax error (#3715) * FIX(Status(NJS) remove syntax error * CHORE(stats): update dummy data * feat(Status): update status in case of cache is invalid or there is an error * feat(Status): return cached data in case of updateStats failed with 304 code * fix: remove 304 as the body is required --- packages/stats/nginx/njs/cache.js | 9 +++++---- packages/stats/nginx/njs/stats.js | 10 ++++++++-- 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/packages/stats/nginx/njs/cache.js b/packages/stats/nginx/njs/cache.js index 67944fafdf..d31be5498f 100644 --- a/packages/stats/nginx/njs/cache.js +++ b/packages/stats/nginx/njs/cache.js @@ -15,10 +15,11 @@ function isLessThan24Hours(timestamp) { } const DUMMY_DATA = { - capacity: "32.74 PB", - nodes: 2569, - countries: 61, - cores: 63968, + capacity: "17.46 PB", + ssd: "6800.54 TB", + nodes: 2081, + countries: 52, + cores: 59828, }; function readCache(path) { try { diff --git a/packages/stats/nginx/njs/stats.js b/packages/stats/nginx/njs/stats.js index e7f8336e65..d369264155 100644 --- a/packages/stats/nginx/njs/stats.js +++ b/packages/stats/nginx/njs/stats.js @@ -13,6 +13,10 @@ let URLS = [ async function getStats(r) { const cachedData = cache.readCache(cache_path); + if (!cachedData.valid || cachedData.error) { + await updateStats(r); + return; + } r.return(200, JSON.stringify(cachedData.summary)); } @@ -24,7 +28,9 @@ async function updateStats(r) { return; } catch (error) { r.error(`Failed to fetch stats: ${error}`); - r.return(500, `Failed to fetch stats: ${error}`); + r.error(`Returning cached data`); + const cachedData = cache.readCache(cache_path); + r.return(200, JSON.stringify(cachedData.summary)); return; } } @@ -131,7 +137,7 @@ function toTeraOrGiga(value) { return gb.toFixed(2) + " PB"; } -export function toTeraOrGigaStats(value) { +function toTeraOrGigaStats(value) { const giga = 1024 ** 3; if (!value) return "0 GB";