1#!/usr/bin/env python3
2#
3#   Copyright 2019 - Google
4#
5#   Licensed under the Apache License, Version 2.0 (the "License");
6#   you may not use this file except in compliance with the License.
7#   You may obtain a copy of the License at
8#
9#       http://www.apache.org/licenses/LICENSE-2.0
10#
11#   Unless required by applicable law or agreed to in writing, software
12#   distributed under the License is distributed on an "AS IS" BASIS,
13#   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14#   See the License for the specific language governing permissions and
15#   limitations under the License.
16"""
17    Test Script for Telephony Stress data Test
18"""
19from acts.test_decorators import test_tracker_info
20from acts.test_utils.tel.TelephonyBaseTest import TelephonyBaseTest
21from acts.test_utils.tel.tel_test_utils import iperf_test_by_adb
22from acts.test_utils.tel.tel_test_utils import iperf_udp_test_by_adb
23
24
25class TelLiveStressDataTest(TelephonyBaseTest):
26    def setup_class(self):
27        super().setup_class()
28        self.ad = self.android_devices[0]
29        self.iperf_server_address = self.user_params.get("iperf_server",
30                                                         '0.0.0.0')
31        self.iperf_srv_tcp_port = self.user_params.get("iperf_server_tcp_port",
32                                                       0)
33        self.iperf_srv_udp_port = self.user_params.get("iperf_server_udp_port",
34                                                       0)
35        self.test_duration = self.user_params.get("data_stress_duration", 60)
36
37        return True
38
39    @test_tracker_info(uuid="190fdeb1-541e-455f-9f37-762a8e55c07f")
40    @TelephonyBaseTest.tel_test_wrap
41    def test_tcp_upload_stress(self):
42        return iperf_test_by_adb(self.log,
43                                 self.ad,
44                                 self.iperf_server_address,
45                                 self.iperf_srv_tcp_port,
46                                 False,
47                                 self.test_duration)
48
49    @test_tracker_info(uuid="af9805f8-6ed5-4e05-823e-d88dcef45637")
50    @TelephonyBaseTest.tel_test_wrap
51    def test_tcp_download_stress(self):
52        return iperf_test_by_adb(self.log,
53                                 self.ad,
54                                 self.iperf_server_address,
55                                 self.iperf_srv_tcp_port,
56                                 True,
57                                 self.test_duration)
58
59    @test_tracker_info(uuid="55bf5e09-dc7b-40bc-843f-31fed076ffe4")
60    @TelephonyBaseTest.tel_test_wrap
61    def test_udp_upload_stress(self):
62        return iperf_udp_test_by_adb(self.log,
63                                     self.ad,
64                                     self.iperf_server_address,
65                                     self.iperf_srv_udp_port,
66                                     False,
67                                     self.test_duration)
68
69    @test_tracker_info(uuid="02ae88b2-d597-45df-ab5a-d701d1125a0f")
70    @TelephonyBaseTest.tel_test_wrap
71    def test_udp_download_stress(self):
72        return iperf_udp_test_by_adb(self.log,
73                                     self.ad,
74                                     self.iperf_server_address,
75                                     self.iperf_srv_udp_port,
76                                     True,
77                                     self.test_duration)
78