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 2539673cf2..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": { @@ -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", 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 34f5593cdf..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", @@ -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/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/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; }; diff --git a/packages/playground/src/stores/stats.ts b/packages/playground/src/stores/stats.ts index 60625ed3b6..c752de7162 100644 --- a/packages/playground/src/stores/stats.ts +++ b/packages/playground/src/stores/stats.ts @@ -11,8 +11,8 @@ export const useStatsStore = defineStore("stats-store", () => { const data = computed(() => res.value.data); const stats = computed(() => [ { - label: "Capacity", - value: data.value?.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/utils/manual.ts b/packages/playground/src/utils/manual.ts index 0af98de2e3..7f77c606ff 100644 --- a/packages/playground/src/utils/manual.ts +++ b/packages/playground/src/utils/manual.ts @@ -1,18 +1,22 @@ -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`, - 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"), + 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..a290fa2554 100644 --- a/packages/playground/src/views/minting_view.vue +++ b/packages/playground/src/views/minting_view.vue @@ -6,20 +6,10 @@ For more information about minting check - TFT minting process. - + TFT minting process.
The user can verify the 3Nodes' payments on Stellar Blockchain through the Threefold's - minting tool. - + minting tool.
TFT minting address on Stellar Chain: - + @@ -50,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"; @@ -140,8 +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: formatResourceSize(stats!.totalHru), title: "HDD Storage", icon: "mdi-harddisk" }, + { 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/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.

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/selenium.md b/packages/playground/tests/frontend_selenium/selenium.md index 92ab10f270..b2617ec4fd 100644 --- a/packages/playground/tests/frontend_selenium/selenium.md +++ b/packages/playground/tests/frontend_selenium/selenium.md @@ -7,17 +7,52 @@ | [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 -### First +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: + + ```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.py +- Ex.: to run against Mainnet + + - config.ini + + ```ini + [Base] + net = main + ``` + + - base.py + + ```python + base_url = "https://dashboard.grid.tf/" + ``` + +### Setup environment configurations -- 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`. - 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 +63,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 +### Prepare tests requirements -- You need to leave the localhost running and open a new terminal. +- 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'`. 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..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/') @@ -61,7 +65,7 @@ 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() assert stats == dashboard_stats @@ -183,4 +187,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' 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/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 55ee69ba7f..4f301144c8 100644 --- a/packages/playground/tests/frontend_selenium/utils/grid_proxy.py +++ b/packages/playground/tests/frontend_selenium/utils/grid_proxy.py @@ -61,7 +61,15 @@ 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): + 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()) def get_stats(self): up = requests.get(Base.gridproxy_url + 'stats?status=up', timeout=10).json() @@ -94,4 +102,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 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/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: "" 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 73d848ffc5..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; } } @@ -78,10 +84,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 +137,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 }; 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/stats/src/components/stats_table.vue b/packages/stats/src/components/stats_table.vue index 2d1c80aa37..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,12 +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: toTeraOrGigaOrPeta(formattedStats.value.totalHru.toString()), - title: "HDD Storage", - icon: "mdi-harddisk", - }, + { 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"; +} 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": {