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

Feature/Extended coverage for Vehicle Data tests #2488

Merged
merged 17 commits into from
Jan 25, 2021

Conversation

dboltovskyi
Copy link
Contributor

@dboltovskyi dboltovskyi commented Nov 26, 2020

This is base PR for test scripts for Vehicle Data proposals:

This PR is [ready] for review.

Summary

Extended test coverage for Vehicle Data tests

ATF version

7.1.0_version_bump

Changelog

  • Introduced new modules

    • APIHelper - set of utility functions to work with both APIs: MOBILE and HMI
    • APITestDataGenerator - generate values for parameters based on existing API restrictions and desired value type
  • Introduced the following test types to verify GetVD and OnVD RPCs:

    • VALID_RANDOM_ALL - positive cases for VD parameters where all possible sub-parameters of hierarchy are defined with valid random values,
    • VALID_RANDOM_SUB - positive cases for struct VD parameters and sub-parameters where only one sub-parameter of hierarchy is defined with valid random value (mandatory also included),
    • LOWER_IN_BOUND/UPPER_IN_BOUND - positive cases for VD parameters and sub-parameters where only one sub-parameter of hierarchy is defined with min/max valid value (mandatory also included),
    • LOWER_OUT_OF_BOUND/UPPER_OUT_OF_BOUND - negative cases for VD parameters and sub-parameters where only one sub-parameter of hierarchy is defined with nearest invalid min/max value,
    • INVALID_TYPE - negative cases for VD parameters and sub-parameters with invalid type value defined for one of them,
    • ENUM_ITEMS/ BOOL_ITEMS - positive cases for enum/boolean VD parameters and sub-parameters with all possible values defined (all items for enum and true/false for boolean),
    • MANDATORY_ONLY - positive cases for struct VD parameters and sub-parameters where only mandatory sub-parameters are defined with valid random values,
    • MANDATORY_MISSING - negative cases for struct VD parameters and sub-parameters where only mandatory sub-parameters are defined and one of them is missing,
    • PARAM_VERSION - positive/negative cases for VD parameters with version defined
  • Deleted existing VD scripts which are covered by a new tests

  • Updated existing scripts

  • Updated vehicle_data.txt test set

  • Added possibility to restrict vehicle data parameters to be tested by defining VD_PARAMS environment variable

Bug Fixes
  • Fixed issue of handling API data types without Common. prefix
  • Improved generation of random values

CLA

@KhrystynaDubovyk
Copy link

@atiwari9 please review this PR

@atiwari9
Copy link

@dboltovskyi - There are significant changes to testing methodology, these changes warrant full regression tests for all VD items including the tests which are removed. I am skeptical of the scope of these changes with-in new VD related proposals, we may need to check with PMs on if this needs to be part of your other ATF related change set.

I'd run the full test suite myself. Meanwhile i have left some comments for the changes.

user_modules/api/APITestDataGenerator.lua Show resolved Hide resolved
test_scripts/API/VehicleData/common.lua Show resolved Hide resolved
test_scripts/API/VehicleData/common.lua Show resolved Hide resolved
test_scripts/API/VehicleData/common.lua Show resolved Hide resolved
test_scripts/API/VehicleData/common.lua Outdated Show resolved Hide resolved
@dboltovskyi
Copy link
Contributor Author

dboltovskyi commented Nov 30, 2020

@atiwari9 Regarding your comment 2488#issuecomment-735976762 please let me add some clarification about the changes in this PR.

Use of APIs to generate tests and test cases had been introduced in a previous release (7.0) (please see #2439)
There was a request from PMs to have a generic approach for testing all VD parameters.

Current PR is an evolution of existing approach which also adds systematization in common modules and tests.

Despite the fact table with test types has been introduced in the current PR, the following checks have been implemented before (in a previous release):

  • VALID_RANDOM_ALL,
  • INVALID_TYPE,
  • MANDATORY_ONLY,
  • MANDATORY_MISSING,
  • PARAM_VERSION

Current PR provides the following changes (comparing to existing approach):

  • Introduced modules to work with APIs (APIHelper and APITestDataGenerator). Previously these were a part of common module
  • Introduced a few tables in common module (e.g. m.testType)
  • Added new functions in common module to generate test cases (e.g. m.createTestCases)
  • Introduced possibility to recursively check all sub-parameters
  • Added new test types and corresponding scripts:
    • VALID_RANDOM_SUB
    • LOWER_IN_BOUND/UPPER_IN_BOUND
    • LOWER_OUT_OF_BOUND/UPPER_OUT_OF_BOUND,
    • ENUM_ITEMS/ BOOL_ITEMS
  • Updated existing scripts to utilize new functions
  • Deleted scripts which are covered by a new approach

I agree there are quite a lot of changes. Though having them we will significantly improve existing approach and I would say "finalize" it. It would be very easy to support new VD parameters in tests. And I hope PMs wouldn't mind to accept the changes.

@atiwari9
Copy link

atiwari9 commented Dec 1, 2020

@dboltovskyi - I ran the vehicle_data test set only for tirePressure and got 5 Failed cases, is this expected?

TOTAL: 38
PASSED: 29
FAILED: 5
ABORTED: 4

Logs:
2020-12-01_15-10-58.736.zip

Test target: test_sets/vehicle_data.txt
----------------------------------------------------------------------------------------------------
01:	PASSED	./test_scripts/API/VehicleData/GetVehicleData/001_GetVD_Success_flow.lua	
02:	ABORTED	./test_scripts/API/VehicleData/GetVehicleData/002_GetVD_disallowed.lua	
03:	FAILED	./test_scripts/API/VehicleData/GetVehicleData/003_GetVD_disallowed_after_PTU.lua	
04:	PASSED	./test_scripts/API/VehicleData/GetVehicleData/004_GetVD_HMI_responds_with_invalid_data.lua	
05:	PASSED	./test_scripts/API/VehicleData/GetVehicleData/005_GetVD_App_sends_invalid_request.lua	
06:	PASSED	./test_scripts/API/VehicleData/GetVehicleData/006_GetVD_mandatory_parameters.lua	
07:	FAILED	./test_scripts/API/VehicleData/GetVehicleData/007_GetVD_app_version_is_greater_than_parameter_version.lua	
08:	PASSED	./test_scripts/API/VehicleData/GetVehicleData/008_GetVD_app_version_is_less_than_parameter_version.lua	
09:	PASSED	./test_scripts/API/VehicleData/GetVehicleData/009_GetVD_min_max_boundary_values.lua	
10:	PASSED	./test_scripts/API/VehicleData/GetVehicleData/010_GetVD_enum_and_bool_values.lua	
11:	PASSED	./test_scripts/API/VehicleData/OnVehicleData/001_OnVD_Success.lua	
12:	ABORTED	./test_scripts/API/VehicleData/OnVehicleData/002_OnVD_disallowed.lua	
13:	FAILED	./test_scripts/API/VehicleData/OnVehicleData/003_OnVD_disallowed_after_PTU.lua	
14:	PASSED	./test_scripts/API/VehicleData/OnVehicleData/004_OnVD_with_invalid_data.lua	
15:	PASSED	./test_scripts/API/VehicleData/OnVehicleData/005_OnVD_App_is_not_subscribed.lua	
16:	PASSED	./test_scripts/API/VehicleData/OnVehicleData/006_OnVD_mandatory_parameters.lua	
17:	PASSED	./test_scripts/API/VehicleData/OnVehicleData/007_OnVD_min_max_boundary_values.lua	
18:	PASSED	./test_scripts/API/VehicleData/OnVehicleData/008_OnVD_enum_and_bool_values.lua	
19:	PASSED	./test_scripts/API/VehicleData/SubscribeVehicleData/001_SubscribeVD_Success.lua	
20:	ABORTED	./test_scripts/API/VehicleData/SubscribeVehicleData/002_SubscribeVD_disallowed.lua	
21:	FAILED	./test_scripts/API/VehicleData/SubscribeVehicleData/003_SubscribeVD_disallowed_after_PTU.lua	
22:	PASSED	./test_scripts/API/VehicleData/SubscribeVehicleData/004_SubscribeVD_HMI_responds_with_invalid_data.lua	
23:	PASSED	./test_scripts/API/VehicleData/SubscribeVehicleData/005_SubscribeVD_App_sends_invalid_request.lua	
24:	PASSED	./test_scripts/API/VehicleData/SubscribeVehicleData/006_SubscribeVD_2nd_request_IGNORED.lua	
25:	PASSED	./test_scripts/API/VehicleData/SubscribeVehicleData/007_SubscribeVD_for_2_apps.lua	
26:	PASSED	./test_scripts/API/VehicleData/SubscribeVehicleData/008_SubscribeVD_HMI_responds_with_not_success_codes.lua	
27:	PASSED	./test_scripts/API/VehicleData/SubscribeVehicleData/009_SubscribeVD_Resumption_of_subscription_Unexpected_Disconnect.lua	
28:	PASSED	./test_scripts/API/VehicleData/SubscribeVehicleData/010_SubscribeVD_Resumption_of_subscription_Ignition_Cycle.lua	
29:	PASSED	./test_scripts/API/VehicleData/SubscribeVehicleData/011_SubscribeVD_Resumption_of_subscription_for_2_apps_Unexpected_Disconnect.lua	
30:	PASSED	./test_scripts/API/VehicleData/SubscribeVehicleData/012_SubscribeVD_Resumption_of_subscription_for_2_apps_Ignition_Cycle.lua	
31:	PASSED	./test_scripts/API/VehicleData/UnsubscribeVehicleData/001_UnsubscribeVD_Success.lua	
32:	ABORTED	./test_scripts/API/VehicleData/UnsubscribeVehicleData/002_UnsubscribeVD_disallowed.lua	
33:	FAILED	./test_scripts/API/VehicleData/UnsubscribeVehicleData/003_UnsubscribeVD_disallowed_after_PTU.lua	
34:	PASSED	./test_scripts/API/VehicleData/UnsubscribeVehicleData/004_UnsubscribeVD_HMI_responds_with_invalid_data.lua	
35:	PASSED	./test_scripts/API/VehicleData/UnsubscribeVehicleData/005_UnsubscribeVD_App_sends_invalid_request.lua	
36:	PASSED	./test_scripts/API/VehicleData/UnsubscribeVehicleData/006_UnsubscribeVD_2nd_request_IGNORED.lua	
37:	PASSED	./test_scripts/API/VehicleData/UnsubscribeVehicleData/007_UnsubscribeVD_for_2_apps.lua	
38:	PASSED	./test_scripts/API/VehicleData/UnsubscribeVehicleData/008_UnsubscribeVD_HMI_responds_with_not_success_codes.lua	

@dboltovskyi
Copy link
Contributor Author

@atiwari9 Please notice approach with commenting of parameters in m.vd table is not working for all scripts.
I'm going to push an update with possibility to define tested VD parameters in environment variable which will work for all VD scripts.

@dboltovskyi
Copy link
Contributor Author

@atiwari9 Please find update in 27af7bf

Now it's possible to define VD parameters for all test scripts in VD_PARAMS environment variable.
It's allowed to define one or many parameters split by coma. E.g: export VD_PARAMS=gps or export VD_PARAMS=gps,speed.
If VD_PARAMS is not defined tests will be run against all possible VD parameters.

One limitation - this approach doesn't work in ATF parallel mode by default since it requires changes in ATF.

However if you would like to do so, you just need to add the following line after https://github.com/smartdevicelink/sdl_atf/blob/6f600b7c8e926e569c9e291973817b21c850177e/atf_parallels/loop.sh#L29

-e VD_PARAMS=$VD_PARAMS \

This will transfer VD_PARAMS environment variable into atf_worker docker container.

@atiwari9
Copy link

atiwari9 commented Dec 2, 2020

@dboltovskyi - Thanks, this seems to be working so i am running another batch of tests now. Is there a place to document this capability of running selectively vehicle data item tests?

@dboltovskyi
Copy link
Contributor Author

dboltovskyi commented Dec 2, 2020

@atiwari9 For now it's "undocumented" feature.
The only place where it's mentioned is a description for restrictAvailableVDParams() function:

--[[ @restrictAvailableVDParams: Restrict VD parameters for test by only ones defined in 'VD_PARAMS' environment variable

Additionally we can do the following:

  1. Update current PR in Scripts with description of this possibility
  2. Create a new PR in ATF repo with update for the README (please see Advanced options section ) and also with update for parallel mode

What do you think would be the best?

@atiwari9
Copy link

atiwari9 commented Dec 2, 2020

@dtrunov - I think option 2 is better, as a user may refer to ReadMe to understand the usage rather than open each and every script to find out.

BTW, with commit 27af7bf , All tests are Passed for individual tirePressure as well as batch for all VD.

Logs:

All_Tests_Pass.7z.changeExtTo7z.log
TirePressure_AllTests_Pass.zip

@dboltovskyi
Copy link
Contributor Author

@atiwari9 Agree. I will do both: 1) and 2) and post a comment when it's ready

@dboltovskyi
Copy link
Contributor Author

@atiwari9 Please notice:

  1. Description of the current PR is updated with note regarding VD_PARAMS environment variable
  2. New PR in ATF is created with appropriate updates: Add possibility to define params for VD tests sdl_atf#218

Copy link

@atiwari9 atiwari9 left a comment

Choose a reason for hiding this comment

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

Approved

@LitvinenkoIra
Copy link
Contributor

@JackLivio This PR is ready for Livio review. Thank you!

test_scripts/API/VehicleData/common.lua Outdated Show resolved Hide resolved
test_scripts/API/VehicleData/common.lua Outdated Show resolved Hide resolved
test_scripts/API/VehicleData/common.lua Outdated Show resolved Hide resolved
test_scripts/API/VehicleData/common.lua Outdated Show resolved Hide resolved
test_scripts/API/VehicleData/common.lua Outdated Show resolved Hide resolved
test_scripts/API/VehicleData/common.lua Show resolved Hide resolved
test_scripts/API/VehicleData/common.lua Show resolved Hide resolved
user_modules/api/APIHelper.lua Show resolved Hide resolved
user_modules/api/APITestDataGenerator.lua Outdated Show resolved Hide resolved
@dboltovskyi
Copy link
Contributor Author

@jacobkeeler Please notice all the comments addressed

@jacobkeeler
Copy link
Contributor

@dboltovskyi Also as a note, several of the tests seem to be causing Core crashes as of now:

----------------------------------------------------------------------------------------------------
1:	ABORTED	./test_scripts/API/VehicleData/GetVehicleData/007_GetVD_app_version_is_greater_than_parameter_version.lua	
2:	ABORTED	./test_scripts/API/VehicleData/OnVehicleData/005_OnVD_App_is_not_subscribed.lua	
3:	ABORTED	./test_scripts/API/VehicleData/UnsubscribeVehicleData/001_UnsubscribeVD_Success.lua	
4:	ABORTED	./test_scripts/API/VehicleData/UnsubscribeVehicleData/003_UnsubscribeVD_disallowed_after_PTU.lua	
5:	ABORTED	./test_scripts/API/VehicleData/UnsubscribeVehicleData/006_UnsubscribeVD_2nd_request_IGNORED.lua	
6:	ABORTED	./test_scripts/API/VehicleData/UnsubscribeVehicleData/007_UnsubscribeVD_for_2_apps.lua	
----------------------------------------------------------------------------------------------------
TOTAL: 6
PASSED: 0 
FAILED: 0 
ABORTED: 6 
SKIPPED: 0 
----------------------------------------------------------------------------------------------------
Execution time: 00:07:20
====================================================================================================

These crashes seem to be random, but they always happen during an UnsubscribeVehicleData step:

==============================
Start './test_scripts/API/VehicleData/UnsubscribeVehicleData/006_UnsubscribeVD_2nd_request_IGNORED.lua'
==============================
SDL build option REMOTE_CONTROL is unavailable.
Assume that SDL was built with REMOTE_CONTROL = ON
Default mobile device transport: TCP
Testing VD parameters are not restricted
Disabled VD parameter:	clusterModeStatus
=====================================================================================================
Description: ATF test script
Severity: Major
=====================================================================================================
--- Preconditions -----------------------------------------------------------------------------------
kill: (127953): No such process
[08:41:39,507] Clean_environment_and_update_preloaded_pt_file                                        [SUCCESS] (404 ms)
SDL pid 127989
tcp        0      0 127.0.0.1:8087          0.0.0.0:*               LISTEN     
SDL started
HMI initialized
HMI is ready
Mobile #1 connected
SDL allowed
[08:41:42,605] Start_SDL__HMI__connect_Mobile__start_Session                                         [SUCCESS] (1467 ms)
[08:41:44,093] Register_App                                                                          [SUCCESS] (2917 ms)
--- Test --------------------------------------------------------------------------------------------
--- VD parameter: accPedalPosition ------------------------------------------------------------------
[08:41:47,011] RPC_SubscribeVehicleData_SUCCESS                                                      [SUCCESS] (396 ms)
[08:41:47,407] RPC_1_UnsubscribeVehicleData_SUCCESS                                                  [SUCCESS] (403 ms)
[08:41:47,811] RPC_2_UnsubscribeVehicleData_IGNORED                                                  [SUCCESS] (1196 ms)
--- VD parameter: airbagStatus ----------------------------------------------------------------------
[08:41:49,008] RPC_SubscribeVehicleData_SUCCESS                                                      [SUCCESS] (401 ms)
SDL has unexpectedly crashed or stop responding!
Mobile #1 disconnected
[08:41:49,409] RPC_1_UnsubscribeVehicleData_SUCCESS                                                  [FAIL] (11196 ms)
 OnHashChange notification: Timeout: OnHashChange notification: Timeout expired
 Response to 7: Timeout: Response to 7: Timeout expired
SDL had already stopped
SCRIPT STATUS: ABORTED

Seeing a SIGSEGV message in the logs:

TRACE [08 Jan 2021 08:41:49,417][139724782024448][Commands] /home/jacobkeeler/sdl_core/src/components/application_manager/src/commands/command_request_impl.cc:798 commands::CommandRequestImpl::IsHMIResultSuccess: Enter
TRACE [08 Jan 2021 08:41:49,417][139724782024448][Commands] /home/jacobkeeler/sdl_core/src/components/application_manager/src/commands/command_request_impl.cc:798 commands::CommandRequestImpl::IsHMIResultSuccess: Exit
TRACE [08 Jan 2021 08:41:49,417][139724782024448][Commands] /home/jacobkeeler/sdl_core/src/components/application_manager/src/commands/command_request_impl.cc:813 commands::CommandRequestImpl::PrepareResultForMobileResponse: Exit
TRACE [08 Jan 2021 08:41:49,417][139724782024448][VehicleInfoPlugin] /home/jacobkeeler/sdl_core/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/custom_vehicle_data_manager_impl.cc:89 CustomVehicleDataManagerImpl::CreateMobileMessageParams: Enter
TRACE [08 Jan 2021 08:41:49,417][139724782024448][VehicleInfoPlugin] /home/jacobkeeler/sdl_core/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/custom_vehicle_data_manager_impl.cc:89 CustomVehicleDataManagerImpl::CreateMobileMessageParams: Exit
DEBUG [08 Jan 2021 08:41:49,417][139724782024448][Commands] /home/jacobkeeler/sdl_core/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/commands/mobile/unsubscribe_vehicle_data_request.cc:316 commands::UnsubscribeVehicleDataRequest::UnsubscribePendingVehicleData: Unsubscribing from all pending VehicleData
DEBUG [08 Jan 2021 08:41:49,417][139724782024448][VehicleInfoPlugin] /home/jacobkeeler/sdl_core/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/vehicle_info_app_extension.cc:67 VehicleInfoAppExtension::unsubscribeFromVehicleInfo: airbagStatus
DEBUG [08 Jan 2021 08:41:49,417][139724782024448][SDLMain] /home/jacobkeeler/sdl_core/src/appMain/life_cycle_impl.cc:240 {anonymous}::sig_handler: SIGSEGV signal has been caught

@dboltovskyi
Copy link
Contributor Author

dboltovskyi commented Jan 8, 2021

@jacobkeeler Please notice the following:

  1. Regarding the crashes, we found out they are not related to ATF tests, but to some system updates in Ubuntu.
    We can't see them on an older version of Ubuntu 18 (~Sep/2020) or on Ubuntu 16 (latest).
    A new issue needs to be created against sdl_core to address it.

  2. Regarding the removed code
    It's related to isSkipped() function and allows to have additional LOWER_OUT_OF_BOUND tests for String (and Array) parameters which have minlength (or minsize) = 0. This is related to the 2488#discussion_r553757334.
    Note: having results described in 2488#discussion_r554084552 exclusion for 0 is retained for String and Array parameters.

@dboltovskyi
Copy link
Contributor Author

@jacobkeeler Please notice all the questions have been addressed

Copy link
Contributor

@jacobkeeler jacobkeeler left a comment

Choose a reason for hiding this comment

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

This should cover all of the changes that need to be made for the IN_BOUND/OUT_OF_BOUND tests

user_modules/api/APITestDataGenerator.lua Outdated Show resolved Hide resolved
user_modules/api/APITestDataGenerator.lua Show resolved Hide resolved
user_modules/api/APITestDataGenerator.lua Show resolved Hide resolved
test_scripts/API/VehicleData/common.lua Show resolved Hide resolved
@dboltovskyi
Copy link
Contributor Author

@jacobkeeler Please notice all the comments addressed.

The following 3 suggested updates were not applied due to discussion: 2488#commitcomment-45860121

@jacobkeeler
Copy link
Contributor

@dboltovskyi After checking the actual RPC parser code, I do see that minsize does default to 0. Going off of memory, I was convinced that it was treated the same as minlength, but it doesn't appear that is the case, my apologies.

@dboltovskyi
Copy link
Contributor Author

@jacobkeeler Please notice descriptions have been updated in afb7faf and conflicts resolved in e490871

Copy link
Contributor

@jacobkeeler jacobkeeler left a comment

Choose a reason for hiding this comment

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

Some suggestions for clarity

test_scripts/API/VehicleData/common.lua Outdated Show resolved Hide resolved
test_scripts/API/VehicleData/common.lua Outdated Show resolved Hide resolved
Co-authored-by: Jacob Keeler <jacob.keeler@livioradio.com>
@jacobkeeler jacobkeeler merged commit 0d02154 into develop Jan 25, 2021
@jacobkeeler jacobkeeler deleted the feature/extended_vd_coverage branch January 25, 2021 14:17
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.

5 participants