-
Notifications
You must be signed in to change notification settings - Fork 17
[Camera] Add CameraAppTestSuite for Matter Camera TCs #210
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -228,7 +228,7 @@ | |||||||||||
pics_path = f"{PICS_FILE_PATH}" | ||||||||||||
self.logger.info(f"Using PICS file: {pics_path}") | ||||||||||||
|
||||||||||||
if server_type == ChipServerType.CHIP_TOOL: | ||||||||||||
if server_type == ChipServerType.CHIP_TOOL or server_type == ChipServerType.CHIP_CAMERA_CONTROLLER: | ||||||||||||
test_path = f"{YAML_TESTS_PATH}/{test_id}.yaml" | ||||||||||||
else: | ||||||||||||
test_path = f"{YAML_TESTS_PATH}/{test_id}_Simulated.yaml" | ||||||||||||
|
@@ -238,7 +238,8 @@ | |||||||||||
[test_path], parser_config, test_parser_hooks | ||||||||||||
) | ||||||||||||
|
||||||||||||
if server_type == ChipServerType.CHIP_TOOL: | ||||||||||||
#Reuse chip-tool adapter for camera-controller | ||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||
if server_type == ChipServerType.CHIP_TOOL or server_type == ChipServerType.CHIP_CAMERA_CONTROLLER: | ||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||
adapter = ChipToolAdapter.Adapter(parser_config.definitions) | ||||||||||||
elif server_type == ChipServerType.CHIP_APP: | ||||||||||||
adapter = ChipAppAdapter.Adapter(parser_config.definitions) | ||||||||||||
|
Original file line number | Diff line number | Diff line change | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -28,6 +28,7 @@ | |||||||||||
from ...chip.chip_server import ChipServerType | ||||||||||||
from ...models.matter_test_models import MatterTestStep, MatterTestType | ||||||||||||
from ...yaml_tests.models.chip_test import ChipManualPromptTest, ChipTest | ||||||||||||
from .test_suite import SuiteType | ||||||||||||
from .yaml_test_models import YamlTest | ||||||||||||
|
||||||||||||
# Custom type variable used to annotate the factory method in YamlTestCase. | ||||||||||||
|
@@ -81,11 +82,18 @@ | |||||||||||
if test.type == MatterTestType.MANUAL: | ||||||||||||
case_class = YamlManualTestCase | ||||||||||||
elif test.type == MatterTestType.SEMI_AUTOMATED: | ||||||||||||
case_class = YamlSemiAutomatedChipTestCase | ||||||||||||
if test.suite_type == SuiteType.CAMERA_AUTOMATED: | ||||||||||||
case_class = YamlCameraSemiAutomatedChipTestCase | ||||||||||||
else: | ||||||||||||
case_class = YamlSemiAutomatedChipTestCase | ||||||||||||
|
||||||||||||
elif test.type == MatterTestType.SIMULATED: | ||||||||||||
case_class = YamlSimulatedTestCase | ||||||||||||
else: # Automated | ||||||||||||
case_class = YamlChipTestCase | ||||||||||||
if test.suite_type == SuiteType.CAMERA_AUTOMATED: | ||||||||||||
case_class = YamlCameraChipTestCase | ||||||||||||
else: | ||||||||||||
case_class = YamlChipTestCase | ||||||||||||
|
||||||||||||
return case_class.__class_factory(test=test, yaml_version=yaml_version) | ||||||||||||
|
||||||||||||
|
@@ -162,7 +170,8 @@ | |||||||||||
Disabled steps are ignored. | ||||||||||||
(Such tests will be marked as 'Steps Disabled' elsewhere) | ||||||||||||
|
||||||||||||
UserPrompt are special cases that will prompt test operator for input. | ||||||||||||
UserPrompt, PromptWithResponse or VerifyVideoStream are special cases that will | ||||||||||||
prompt test operator for input. | ||||||||||||
""" | ||||||||||||
if yaml_step.disabled: | ||||||||||||
test_engine_logger.info( | ||||||||||||
|
@@ -171,7 +180,11 @@ | |||||||||||
return | ||||||||||||
|
||||||||||||
step = TestStep(yaml_step.label) | ||||||||||||
if yaml_step.command == "UserPrompt": | ||||||||||||
if yaml_step.command in [ | ||||||||||||
"UserPrompt", | ||||||||||||
"PromptWithResponse", | ||||||||||||
"VerifyVideoStream", | ||||||||||||
]: | ||||||||||||
step = ManualVerificationTestStep( | ||||||||||||
name=yaml_step.label, | ||||||||||||
verification=yaml_step.verification, | ||||||||||||
|
@@ -204,6 +217,22 @@ | |||||||||||
for step in self.yaml_test.steps: | ||||||||||||
self._append_automated_test_step(step) | ||||||||||||
|
||||||||||||
class YamlCameraChipTestCase(YamlTestCase, ChipTest): | ||||||||||||
Comment on lines
219
to
+220
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||
"""Automated test cases using chip-camera-controller.""" | ||||||||||||
|
||||||||||||
server_type = ChipServerType.CHIP_CAMERA_CONTROLLER | ||||||||||||
|
||||||||||||
def create_test_steps(self) -> None: | ||||||||||||
self.test_steps = [TestStep("Start chip-camera-controller test")] | ||||||||||||
for step in self.yaml_test.steps: | ||||||||||||
self._append_automated_test_step(step) | ||||||||||||
|
||||||||||||
|
||||||||||||
class YamlCameraSemiAutomatedChipTestCase(YamlChipTestCase, ChipManualPromptTest): | ||||||||||||
"""Camera Semi-Automated test cases, need special step for users to attach logs | ||||||||||||
for manual steps, so inheriting from ChipManualPromptTest. | ||||||||||||
""" | ||||||||||||
|
||||||||||||
|
||||||||||||
class YamlSemiAutomatedChipTestCase(YamlChipTestCase, ChipManualPromptTest): | ||||||||||||
"""Semi-Automated test cases, need special step for users to attach logs | ||||||||||||
|
Original file line number | Diff line number | Diff line change | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -32,6 +32,7 @@ | |||||||||||
SIMULATED = 1 | ||||||||||||
AUTOMATED = 2 | ||||||||||||
MANUAL = 3 | ||||||||||||
CAMERA_AUTOMATED = 4 | ||||||||||||
|
||||||||||||
|
||||||||||||
# Custom Type variable used to annotate the factory methods of classmethod. | ||||||||||||
|
@@ -69,6 +70,8 @@ | |||||||||||
suite_class = ManualYamlTestSuite | ||||||||||||
elif suite_type == SuiteType.SIMULATED: | ||||||||||||
suite_class = SimulatedYamlTestSuite | ||||||||||||
elif suite_type == SuiteType.CAMERA_AUTOMATED: | ||||||||||||
suite_class = ChipCameraYamlTestSuite | ||||||||||||
elif suite_type == SuiteType.AUTOMATED: | ||||||||||||
suite_class = ChipYamlTestSuite | ||||||||||||
|
||||||||||||
|
@@ -111,6 +114,15 @@ | |||||||||||
await YamlTestSuite.setup(self) | ||||||||||||
await ChipSuite.setup(self) | ||||||||||||
|
||||||||||||
class ChipCameraYamlTestSuite(YamlTestSuite, ChipSuite): | ||||||||||||
Comment on lines
116
to
+117
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||
server_type = ChipServerType.CHIP_CAMERA_CONTROLLER | ||||||||||||
|
||||||||||||
async def setup(self) -> None: | ||||||||||||
"""Due top multi inheritance, we need to call setup on both super classes.""" | ||||||||||||
self.server_type = ChipServerType.CHIP_CAMERA_CONTROLLER | ||||||||||||
await YamlTestSuite.setup(self) | ||||||||||||
await ChipSuite.setup(self) | ||||||||||||
|
||||||||||||
|
||||||||||||
class SimulatedYamlTestSuite(ChipYamlTestSuite): | ||||||||||||
server_type = ChipServerType.CHIP_APP |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,20 +13,22 @@ | |
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
# | ||
import re | ||
from pathlib import Path | ||
|
||
from loguru import logger | ||
from pydantic import ValidationError | ||
|
||
from ...models.matter_test_models import MatterTestType | ||
from .test_suite import SuiteType | ||
from .yaml_test_models import YamlTest | ||
|
||
|
||
class YamlParserException(Exception): | ||
"""Raised when an error occurs during the parser of yaml file.""" | ||
|
||
|
||
def _test_type(test: YamlTest) -> MatterTestType: | ||
def _get_types(test: YamlTest) -> tuple[MatterTestType, SuiteType]: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please, also change the method name in the Unit Test file If possible, please run the Unit Tests to verify if anything else is missing or an issue is encountered. |
||
"""Determine the type of a test based on the parsed yaml. | ||
|
||
This is mainly determined by the number of disabled test steps. | ||
|
@@ -35,27 +37,46 @@ def _test_type(test: YamlTest) -> MatterTestType: | |
test (YamlTest): parsed yaml model | ||
|
||
Returns: | ||
TestType: | ||
- Manual: All steps disabled | ||
- Semi-Automated: some steps are disabled | ||
- Automated: no disabled steps | ||
- Simulated: Tests where file name have "Simulated" | ||
tuple[MatterTestType, SuiteType]: | ||
SuiteType: | ||
- Manual: All steps disabled | ||
- Semi-Automated: some steps are disabled | ||
- Automated: no disabled steps | ||
- Simulated: Tests where file name have "Simulated" | ||
SuiteType: | ||
- SIMULATED: Simulated Test Suite | ||
- AUTOMATED: Automated Test Suite | ||
- MANUAL: Manual Test Suite | ||
- CAMERA_AUTOMATED: Automated Camera Test Suite | ||
""" | ||
camera_test_pattern = r"\[TC-WEBRTC-\d+\.\d+\]" | ||
|
||
if test.path is not None and "Simulated" in str(test.path): | ||
return MatterTestType.SIMULATED | ||
return MatterTestType.SIMULATED, SuiteType.SIMULATED | ||
|
||
steps = test.steps | ||
|
||
# If all disabled: | ||
if all(s.disabled is True for s in steps): | ||
return MatterTestType.MANUAL | ||
|
||
# if any step has a UserPrompt, categorize as semi-automated | ||
if any(s.command == "UserPrompt" for s in steps): | ||
return MatterTestType.SEMI_AUTOMATED | ||
|
||
# Otherwise Automated | ||
return MatterTestType.AUTOMATED | ||
return MatterTestType.MANUAL, SuiteType.MANUAL | ||
|
||
# if any step has a UserPrompt, PromptWithResponse or VerifyVideoStream command, | ||
# categorize as semi-automated | ||
if any( | ||
s.command in ["UserPrompt", "PromptWithResponse", "VerifyVideoStream"] | ||
for s in steps | ||
): | ||
if re.search(camera_test_pattern, test.name): | ||
return MatterTestType.SEMI_AUTOMATED, SuiteType.CAMERA_AUTOMATED | ||
else: | ||
return MatterTestType.SEMI_AUTOMATED, SuiteType.AUTOMATED | ||
|
||
# Otherwise | ||
# If test case is camera related, then return SuiteType.CAMERA_AUTOMATED | ||
if re.search(camera_test_pattern, test.name): | ||
return MatterTestType.AUTOMATED, SuiteType.CAMERA_AUTOMATED | ||
else: | ||
return MatterTestType.AUTOMATED, SuiteType.AUTOMATED | ||
|
||
|
||
def parse_yaml_test(path: Path) -> YamlTest: | ||
|
@@ -68,7 +89,9 @@ def parse_yaml_test(path: Path) -> YamlTest: | |
yaml_str = file.read() | ||
test = YamlTest.parse_raw(yaml_str, proto="yaml") | ||
test.path = path | ||
test.type = _test_type(test) | ||
test_type, suite_type = _get_types(test) | ||
test.type = test_type | ||
test.suite_type = suite_type | ||
except ValidationError as e: | ||
logger.error(str(e)) | ||
raise YamlParserException(f"The YAML file {path} is invalid") from e | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.