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

COE-892: test simulator script #80

Merged
merged 117 commits into from
Apr 19, 2023
Merged

Conversation

namnhatpham
Copy link
Collaborator

No description provided.

Nam Nhat Pham added 30 commits March 24, 2023 13:13
Copy link
Collaborator

@mvoigt-sag mvoigt-sag left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • LGTM so far

  • I'm not sure if the description in the Readme is correct though: https://github.com/SoftwareAG/oee-simulators#unit-test

  • if I execute python -m unittest discover -s test -p "*_test.py", I get:
    PS C:_git\oee-simulators\test> python -m unittest discover -s test -p "*_test.py"

s.........sss..............................................................s......s.........................................................................................................................sssssssssssss..............................................................................................sssssssssssss........................................................................................
----------------------------------------------------------------------
Ran 412 tests in 7.500s

OK (skipped=32)
  • 412 tests sounds quite a lot & I dont see a failed test; where as I get failed tests with python ..\test\simulators_test.py -b https://cwc.latest.stage.c8y.io -u cicduser -p *** -t t57566908:
Ran 10 tests in 71.912s

FAILED (failures=1, errors=2)
2023-04-12 14:03:01,850 Test:Executed: 10
2023-04-12 14:03:01,851 Test:Failed: 1
2023-04-12 14:03:01,852 Test:Errors: 2
  • another error that I get:
PS C:\_git\oee-simulators\test> python .\export_import_test.py -b https://cwc.latest.stage.c8y.io -u cicduser -p *** -t t57566908   
2023-04-12 14:06:00,890 sims:started at 2023-04-12T12:06:00.890Z
2023-04-12 14:06:00,890 sims:CREATE_PROFILES:ProfileCreateMode.CREATE_IF_NOT_EXISTS
2023-04-12 14:06:00,890 sims:Shiftplan polling interval is set to 86,400 secs      
2023-04-12 14:06:00,892 C8yAPI:MOCK_REQUESTS: False
2023-04-12 14:06:01,162 C8yAPI:Device(8925278) has been found by its external id "c8y_EventBasedSimulator/sim_001".
2023-04-12 14:06:01,286 Test Import Export:Begin export data
Traceback (most recent call last):
  File "C:\_git\oee-simulators\simulators\extras\ExportProfileData.py", line 10, in <module>
    DATA_TYPE, DEVICE_ID_LIST, CREATE_FROM, CREATE_TO, LOG_LEVEL, c8y, PASSWORD = ArgumentsAndCredentialsHandler.HandleExportArguments()
  File "C:\_git\oee-simulators\simulators\extras\ArgumentsAndCredentialsHandler.py", line 108, in HandleExportArguments
    c8y = CumulocityApi(base_url=baseurl,  # the url of your Cumulocity tenant here
  File "C:\Python310\lib\site-packages\c8y_api\_main_api.py", line 30, in __init__
    super().__init__(base_url, tenant_id, username=username, password=password, tfa_token=tfa_token,
  File "C:\Python310\lib\site-packages\c8y_api\_base_api.py", line 63, in __init__
    raise ValueError("One of 'auth' or 'username/password' must be defined.")
ValueError: One of 'auth' or 'username/password' must be defined.
2023-04-12 14:06:02,560 Test Import Export:Delete all extract data
2023-04-12 14:06:02,759 Test Import Export:Begin import data
Traceback (most recent call last):
  File "C:\_git\oee-simulators\simulators\extras\ImportData.py", line 15, in <module>
    json_filename_list_to_import, console_log_level, c8y, password, verifySslCertificate = ArgumentsAndCredentialsHandler.HandleImportArguments()
  File "C:\_git\oee-simulators\simulators\extras\ArgumentsAndCredentialsHandler.py", line 165, in HandleImportArguments
    c8y = CumulocityApi(base_url=BASEURL,  # the url of your Cumulocity tenant here
  File "C:\Python310\lib\site-packages\c8y_api\_main_api.py", line 30, in __init__
    super().__init__(base_url, tenant_id, username=username, password=password, tfa_token=tfa_token,
  File "C:\Python310\lib\site-packages\c8y_api\_base_api.py", line 63, in __init__
    raise ValueError("One of 'auth' or 'username/password' must be defined.")
ValueError: One of 'auth' or 'username/password' must be defined.
F
======================================================================
FAIL: test_export_import_profile_data (__main__.Test)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "C:\Python310\lib\unittest\mock.py", line 1369, in patched
    return func(*newargs, **newkeywargs)
  File "C:\_git\oee-simulators\test\export_import_test.py", line 70, in test_export_import_profile_data
    self.assertEqual(exit_code, 0, msg="ImportData.py script failed to run")
AssertionError: 1 != 0 : ImportData.py script failed to run

----------------------------------------------------------------------
Ran 1 test in 2.567s

FAILED (failures=1)
2023-04-12 14:06:03,461 Test Import Export:Executed: 1
2023-04-12 14:06:03,462 Test Import Export:Failed: 1
2023-04-12 14:06:03,462 Test Import Export:Errors: 0

test/simulators_test.py Outdated Show resolved Hide resolved
test/simulators_test.py Outdated Show resolved Hide resolved
Base automatically changed from COE-893-fix-issue-with-github-action-after-merging-unit-test-coe-810-branch to main April 12, 2023 12:30
Copy link
Collaborator

@mvoigt-sag mvoigt-sag left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the code looks good so far, but I didnt run the tests locally yet, will do that later...

@namnhatpham namnhatpham temporarily deployed to oee-dev April 19, 2023 07:37 — with GitHub Actions Inactive
@namnhatpham namnhatpham merged commit 6b4b0c7 into main Apr 19, 2023
1 check passed
@namnhatpham namnhatpham deleted the COE-892-test-simulator-script branch April 19, 2023 07:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants