| # Copyright 2022 Google LLC |
| # |
| # Licensed under the Apache License, Version 2.0 (the "License"); |
| # you may not use this file except in compliance with the License. |
| # You may obtain a copy of the License at |
| # |
| # http://www.apache.org/licenses/LICENSE-2.0 |
| # |
| # Unless required by applicable law or agreed to in writing, software |
| # distributed under the License is distributed on an "AS IS" BASIS, |
| # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| # See the License for the specific language governing permissions and |
| # limitations under the License. |
| |
| """Matter RPC stress test suite.""" |
| from mobly import test_runner |
| |
| import rpc_tool |
| |
| _STRESS_ITERATION = 50 |
| |
| |
| class MatterRpcStressTest(rpc_tool.MatterRpcTest): |
| """Matter RPC Mobly Test. |
| |
| Tests include: reboot, factory reset, descriptor cluster service |
| and attribute service RPC tests. |
| """ |
| |
| def setup_generated_tests(self): |
| """Creates stress test targets""" |
| self.generate_tests( |
| test_logic=self.reboot_sdk, |
| name_func=lambda i: "test_reboot_%s" % i, |
| arg_sets=[(i,) for i in range(_STRESS_ITERATION)]) |
| |
| self.generate_tests( |
| test_logic=self.factory_reset_sdk, |
| name_func=lambda i: "test_factory_reset_%s" % i, |
| arg_sets=[(i,) for i in range(_STRESS_ITERATION)]) |
| |
| self.generate_tests( |
| test_logic=self.check_descriptor_cluster, |
| name_func=lambda i: "test_descriptor_cluster_%s" % i, |
| arg_sets=[(i,) for i in range(_STRESS_ITERATION)]) |
| |
| self.generate_tests( |
| test_logic=self.check_attribute_service, |
| name_func=lambda i: "test_attribute_service_%s" % i, |
| arg_sets=[(i,) for i in range(_STRESS_ITERATION)]) |
| |
| |
| def reboot_sdk(self, iteration): |
| """Reboot logic.""" |
| del iteration # Unused |
| self.test_rpc_reboot() |
| |
| def factory_reset_sdk(self, iteration): |
| """Factory reset logic.""" |
| del iteration # Unused |
| self.test_rpc_factory_reset() |
| |
| def check_descriptor_cluster(self, iteration): |
| """Descriptor cluster logic.""" |
| del iteration # Unused |
| self.test_rpc_descriptor_cluster() |
| |
| def check_attribute_service(self, iteration): |
| """Attribute service logic.""" |
| del iteration # Unused |
| self.test_rpc_attribute_service() |
| |
| |
| if __name__ == "__main__": |
| test_runner.main() |