Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🐞 [Bug]: fix selenium test in statistics & twin pages #3751

Open
1 task done
ramezsaeed opened this issue Dec 15, 2024 · 0 comments
Open
1 task done

🐞 [Bug]: fix selenium test in statistics & twin pages #3751

ramezsaeed opened this issue Dec 15, 2024 · 0 comments
Labels
type_bug Something isn't working
Milestone

Comments

@ramezsaeed
Copy link
Contributor

ramezsaeed commented Dec 15, 2024

Is there an existing issue for this?

  • I have searched the existing issues

which package/s did you face the problem with?

Dashboard

What happened?

failing tests:

  • tests/TFChain/test_twin.py::test_twin_links
  • tests/TFGrid/test_statistics.py::test_statistics_details

Due to changes in the values and removing the HDD in stats view.
the selenium test for test_statistics_details should be fixed.

_______________________________________________________________________________ test_statistics_details ________________________________________________________________________________

browser = <selenium.webdriver.chrome.webdriver.WebDriver (session="debe5fa7de4dc7b86f9cb0e5677247cc")>

    def test_statistics_details(browser):
        """
          TC1503 - Verify Statistics
          Steps:
              - Navigate to the dashboard.
              - Click on TFGrid from side menu.
              - Click on Stats.
          Result: Assert that the displayed values should match the data from the grid proxy.
        """
        statistics_page = before_test_setup(browser)
        grid_proxy = GridProxy(browser)
        statistics_details = statistics_page.statistics_detials()
        grid_statistics_details = grid_proxy.get_stats()
        # Convert necessary values from string to integer for comparison, but keeping the dictionary structure
        statistics_details_converted = {
            key: int(value.replace(',', '')) if value is not None and value.replace(',', '').isdigit() else value
            for key, value in statistics_details.items()
        }
        # Full set of assertions, comparing UI stats with proxy stats
        assert grid_statistics_details['nodes'] == statistics_details_converted['nodes']
        assert grid_statistics_details['dedicatedNodes'] == statistics_details_converted['dedicatedNodes']
        assert grid_statistics_details['farms'] == statistics_details_converted['farms']
        assert grid_statistics_details['countries'] == statistics_details_converted['countries']
        assert grid_statistics_details['totalCru'] == statistics_details_converted['totalCru']
>       assert math.isclose(convert_to_scaled_float(grid_statistics_details['totalSru']), convert_to_scaled_float(byte_converter(statistics_details_converted['totalSru'])), abs_tol=0.002)

tests/TFGrid/test_statistics.py:39: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

value = '26,040 GB'

    def byte_converter(value):
        # Define the unit and the numeric value before checking conditions
        unit = value[-2].upper()  # Last character represents the unit (P, T, G)
        number_str = value[:-3].strip()  # Everything except the last two characters is the number
    
        if value != '0':
            # Convert based on the unit
            if unit == 'P':  # Petabytes
                return float(number_str) * (1024 ** 5)
            elif unit == 'T':  # Terabytes
                return float(number_str) * (1024 ** 4)
            elif unit == 'G':  # Gigabytes
>               return float(number_str) * (1024 ** 3)
E               ValueError: could not convert string to float: '26,040'

utils/utils.py:203: ValueError
------------------------------ Generated html report: file:///home/ramez/ramez/work/tfgrid-sdk-ts/packages/playground/tests/frontend_selenium/report.html ------------------------------
=============================================================================== short test summary info ================================================================================
FAILED tests/TFGrid/test_statistics.py::test_statistics_details - ValueError: could not convert string to float: '26,040'

Steps To Reproduce

No response

which network/s did you face the problem on?

Dev

version

2.6.3

Twin ID/s

No response

Node ID/s

No response

Farm ID/s

No response

Contract ID/s

No response

Relevant screenshots/screen records

Screenshot from 2024-12-15 19-23-52

Relevant log output

https://github.com/threefoldtech/tfgrid-sdk-ts/actions/runs/12336547750/job/34429194672
@ramezsaeed ramezsaeed added the type_bug Something isn't working label Dec 15, 2024
@ramezsaeed ramezsaeed changed the title 🐞 [Bug]: fix selenium test "test_statistics_details" 🐞 [Bug]: fix selenium test in statistics & twin pages Dec 16, 2024
@ramezsaeed ramezsaeed added this to the 2.7.0 milestone Dec 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type_bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant