def test_post_connectivity_missing(self):
     test_dict = {
         'benchmark_uuid': str(self.benchmark.uuid),
         'order': '0',
         'start_time': "2018-01-16T11:41:40.744000+0100",
         'wait_time': '5.0',
         'duration': '37.421521',
         'wifi_bytes_received': 45,
         'wifi_bytes_sent': 78,
         'cell_bytes_received': 33,
         'cell_bytes_sent': 25,
         'multipath_service': 'aggregate',
         'protocol': 'QUIC',
         'protocol_info': get_quic_info(),
         'config': {
             'url': "superman.com",
             'port': '443',
         },
         'result': {
             'delays': ['25.876', '150.112', '75.844'],
             'success': 'True',
         },
     }
     for k in test_dict.keys():
         poped_data = test_dict.pop(k)
         test_json = json.dumps(test_dict)
         response = self.client.post(reverse("connectivity:create_test"),
                                     test_json,
                                     content_type="application/json")
         # Check that the response is 400 BAD_REQUEST
         self.assertEqual(response.status_code, 400)
         # Check that no instance of ConnectivityTest exists
         self.assertEqual(ConnectivityTest.objects.count(), 0)
         test_dict[k] = poped_data
 def test_post_iperf_missing(self):
     test_dict = {
         'benchmark_uuid': str(self.benchmark.uuid),
         'order': '0',
         'protocol_info': get_quic_info(),
         'start_time': "2018-01-16T11:41:40.744000+0100",
         'wait_time': '5.0',
         'duration': '37.421521',
         'wifi_bytes_received': 45,
         'wifi_bytes_sent': 78,
         'cell_bytes_received': 33,
         'cell_bytes_sent': 25,
         'protocol': 'QUIC',
         'config': {
             "download": True,
             "duration": 2,
             "port": 8008,
             "url": "superman.com",
         },
         'result': {
             'intervals': [
                 {
                     'intervalInSec': "0-1",
                     'transferredLastSecond': 20000,
                     'globalBandwidth': 20000,
                     'retransmittedLastSecond': 10,
                 },
                 {
                     'intervalInSec': "1-2",
                     'transferredLastSecond': 22000,
                     'globalBandwidth': 21000,
                     'retransmittedLastSecond': 770,
                 },
             ],
             'total_sent':
             42000,
             'total_retrans':
             780,
             'success':
             'True',
         },
     }
     for k in test_dict.keys():
         poped_data = test_dict.pop(k)
         test_json = json.dumps(test_dict)
         response = self.client.post(reverse("iperf:create_test"),
                                     test_json,
                                     content_type="application/json")
         # Check that the response is 400 BAD_REQUEST
         self.assertEqual(response.status_code, 400)
         # Check that no instance of ConnectivityTest exists
         self.assertEqual(IPerfTest.objects.count(), 0)
         test_dict[k] = poped_data
 def setUp(self):
     self.client = Client()
     self.benchmark = create_benchmark()
     config = ConnectivityConfig.objects.create(
         url="superman.com",
         port=443,
     )
     test = ConnectivityTest.objects.create(
         benchmark=self.benchmark,
         config=config,
         order=0,
         protocol_info=get_quic_info(),
         start_time=datetime(2018,
                             1,
                             16,
                             10,
                             41,
                             40,
                             744000,
                             tzinfo=pytz.utc),
         wait_time="5.0",
         duration="37.421521",
         wifi_bytes_received=45,
         wifi_bytes_sent=78,
         cell_bytes_received=33,
         cell_bytes_sent=25,
         multipath_service='aggregate',
         protocol='QUIC',
     )
     result = ConnectivityResult.objects.create(
         test=test,
         success=True,
     )
     ConnectivityDelay.objects.create(
         result=result,
         delay=25.876,
     )
     ConnectivityDelay.objects.create(
         result=result,
         delay=150.112,
     )
     ConnectivityDelay.objects.create(
         result=result,
         delay=75.844,
     )
Beispiel #4
0
 def test_post_stream_missing(self):
     test_dict = {
         'benchmark_uuid': str(self.benchmark.uuid),
         'order': '0',
         'protocol_info': get_quic_info(),
         'start_time': "2018-01-16T11:41:40.744000+0100",
         'wait_time': '5.0',
         'duration': '37.421521',
         'wifi_bytes_received': 45,
         'wifi_bytes_sent': 78,
         'cell_bytes_received': 33,
         'cell_bytes_sent': 25,
         'multipath_service': 'aggregate',
         'protocol': 'QUIC',
         'config': {
             'url': "https://superman.com:5202",
             'port': "5202",
             'upload_chunk_size': 2000,
             'download_chunk_size': 2000,
             'duration': '14.0',
             'upload_interval_time': "0.1",
             'download_interval_time': "0.1",
         },
         'result': {
             'success': 'True',
             'error_msg': "Exiting client main with error InternalError: deadline exceeded",
             'upload_delays': [
                 {"time": "2018-01-16T11:41:40.744000+0100", "delay": "0.050500"},
                 {"time": "2018-01-16T11:41:40.844000+0100", "delay": "0.020900"},
             ],
             'download_delays': [
                 {"time": "2018-01-16T11:41:40.744000+0100", "delay": "0.050900"},
                 {"time": "2018-01-16T11:41:40.844000+0100", "delay": "0.020500"},
             ],
         },
     }
     for k in test_dict.keys():
         poped_data = test_dict.pop(k)
         test_json = json.dumps(test_dict)
         response = self.client.post(reverse("stream:create_test"), test_json, content_type="application/json")
         # Check that the response is 400 BAD_REQUEST
         self.assertEqual(response.status_code, 400)
         # Check that no instance of ConnectivityTest exists
         self.assertEqual(StreamTest.objects.count(), 0)
         test_dict[k] = poped_data
 def test_post_simplehttpget_ok(self):
     test_dict = {
         'benchmark_uuid': str(self.benchmark.uuid),
         'order': '0',
         'protocol_info': get_quic_info(),
         'start_time': "2018-01-16T11:41:40.744000+0100",
         'wait_time': '5.0',
         'duration': '37.421521',
         'wifi_bytes_received': 45,
         'wifi_bytes_sent': 78,
         'cell_bytes_received': 33,
         'cell_bytes_sent': 25,
         'multipath_service': 'aggregate',
         'protocol': 'QUIC',
         'config': {
             'url': "https://superman.com:443/superFile",
         },
         'result': {
             'success': 'True',
         },
     }
     test_json = json.dumps(test_dict)
     send_time = timezone.now()
     response = self.client.post(reverse("simplehttpget:create_test"), test_json, content_type="application/json")
     # Check that the response is 201 CREATED
     self.assertEqual(response.status_code, 201)
     # Check that an instance of ConnectivityTest exists
     self.assertEqual(SimpleHttpGetTest.objects.count(), 1)
     test = SimpleHttpGetTest.objects.all()[0]
     self.assertEqual(test.benchmark, self.benchmark)
     self.assertEqual(test.order, 0)
     self.assertEqual(test.start_time, datetime(2018, 1, 16, 10, 41, 40, 744000, tzinfo=pytz.utc))
     self.assertEqual(test.wait_time, timedelta(seconds=5.0))
     self.assertEqual(test.duration, timedelta(seconds=37.421521))
     self.assertEqual(test.wifi_bytes_received, 45)
     self.assertEqual(test.wifi_bytes_sent, 78)
     self.assertEqual(test.cell_bytes_received, 33)
     self.assertEqual(test.cell_bytes_sent, 25)
     self.assertEqual(test.multipath_service, "aggregate")
     self.assertEqual(test.protocol, "QUIC")
     self.assertEqual(test.config.url, "https://superman.com:443/superFile")
     self.assertEqual(test.result.success, True)
     self.assertTrue(test.quic_test_info is not None)
     self.assertTrue(timedelta(seconds=0) <= test.rcv_time - send_time <= timedelta(seconds=1))
Beispiel #6
0
 def test_post_stream_ok(self):
     test_dict = {
         'benchmark_uuid': str(self.benchmark.uuid),
         'order': '0',
         'protocol_info': get_quic_info(),
         'start_time': "2018-01-16T11:41:40.744000+0100",
         'wait_time': '5.0',
         'duration': '37.421521',
         'wifi_bytes_received': 45,
         'wifi_bytes_sent': 78,
         'cell_bytes_received': 33,
         'cell_bytes_sent': 25,
         'multipath_service': 'aggregate',
         'protocol': 'QUIC',
         'config': {
             'url': "https://superman.com:5202",
             'port': "5202",
             'upload_chunk_size': 2000,
             'download_chunk_size': 2000,
             'duration': '14.0',
             'upload_interval_time': "0.1",
             'download_interval_time': "0.1",
         },
         'result': {
             'success': 'True',
             'error_msg': "Exiting client main with error InternalError: deadline exceeded",
             'upload_delays': [
                 {"time": "2018-01-16T11:41:40.744000+0100", "delay": "0.050500"},
                 {"time": "2018-01-16T11:41:40.844000+0100", "delay": "0.020900"},
             ],
             'download_delays': [
                 {"time": "2018-01-16T11:41:40.744000+0100", "delay": "0.050900"},
                 {"time": "2018-01-16T11:41:40.844000+0100", "delay": "0.020500"},
             ],
         },
     }
     test_json = json.dumps(test_dict)
     send_time = timezone.now()
     response = self.client.post(reverse("stream:create_test"), test_json, content_type="application/json")
     # Check that the response is 201 CREATED
     self.assertEqual(response.status_code, 201)
     # Check that an instance of ConnectivityTest exists
     self.assertEqual(StreamTest.objects.count(), 1)
     test = StreamTest.objects.all()[0]
     self.assertEqual(test.benchmark, self.benchmark)
     self.assertEqual(test.order, 0)
     self.assertEqual(test.start_time, datetime(2018, 1, 16, 10, 41, 40, 744000, tzinfo=pytz.utc))
     self.assertEqual(test.wait_time, timedelta(seconds=5.0))
     self.assertEqual(test.duration, timedelta(seconds=37.421521))
     self.assertEqual(test.wifi_bytes_received, 45)
     self.assertEqual(test.wifi_bytes_sent, 78)
     self.assertEqual(test.cell_bytes_received, 33)
     self.assertEqual(test.cell_bytes_sent, 25)
     self.assertEqual(test.multipath_service, "aggregate")
     self.assertEqual(test.protocol, "QUIC")
     self.assertEqual(test.config.url, "https://superman.com:5202")
     self.assertEqual(test.config.port, 5202),
     self.assertEqual(test.config.upload_chunk_size, 2000)
     self.assertEqual(test.config.download_chunk_size, 2000)
     self.assertEqual(test.config.duration, timedelta(seconds=14.0))
     self.assertEqual(test.config.upload_interval_time, timedelta(seconds=0.1))
     self.assertEqual(test.config.download_interval_time, timedelta(seconds=0.1))
     self.assertEqual(test.result.success, True)
     self.assertEqual(test.result.error_msg, "Exiting client main with error InternalError: deadline exceeded")
     self.assertEqual(test.result.delays.count(), 4)
     self.assertEqual(test.result.delays.filter(upload=True).count(), 2)
     self.assertEqual(test.result.delays.filter(upload=False).count(), 2)
     self.assertEqual(max([x.delay for x in test.result.delays.filter(upload=True)]), timedelta(seconds=0.050500))
     self.assertEqual(min([x.delay for x in test.result.delays.filter(upload=True)]), timedelta(seconds=0.020900))
     self.assertEqual(max([x.delay for x in test.result.delays.filter(upload=False)]), timedelta(seconds=0.050900))
     self.assertEqual(min([x.delay for x in test.result.delays.filter(upload=False)]), timedelta(seconds=0.020500))
     self.assertTrue(test.quic_test_info is not None)
     self.assertTrue(timedelta(seconds=0) <= test.rcv_time - send_time <= timedelta(seconds=1))
 def test_post_iperf_ok(self):
     test_dict = {
         'benchmark_uuid': str(self.benchmark.uuid),
         'order': '0',
         'protocol_info': get_quic_info(),
         'start_time': "2018-01-16T11:41:40.744000+0100",
         'wait_time': '5.0',
         'duration': '37.421521',
         'wifi_bytes_received': 45,
         'wifi_bytes_sent': 78,
         'cell_bytes_received': 33,
         'cell_bytes_sent': 25,
         'multipath_service': 'aggregate',
         'protocol': 'QUIC',
         'config': {
             "download": True,
             "duration": 2,
             "port": 8008,
             "url": "superman.com",
         },
         'result': {
             'intervals': [
                 {
                     'intervalInSec': "0-1",
                     'transferredLastSecond': 20000,
                     'globalBandwidth': 20000,
                     'retransmittedLastSecond': 10,
                 },
                 {
                     'intervalInSec': "1-2",
                     'transferredLastSecond': 22000,
                     'globalBandwidth': 21000,
                     'retransmittedLastSecond': 770,
                 },
             ],
             'total_sent':
             42000,
             'total_retrans':
             780,
             'success':
             'True',
         },
     }
     test_json = json.dumps(test_dict)
     send_time = timezone.now()
     response = self.client.post(reverse("iperf:create_test"),
                                 test_json,
                                 content_type="application/json")
     # Check that the response is 201 CREATED
     self.assertEqual(response.status_code, 201)
     # Check that an instance of ConnectivityTest exists
     self.assertEqual(IPerfTest.objects.count(), 1)
     test = IPerfTest.objects.all()[0]
     self.assertEqual(test.benchmark, self.benchmark)
     self.assertEqual(test.order, 0)
     self.assertEqual(
         test.start_time,
         datetime(2018, 1, 16, 10, 41, 40, 744000, tzinfo=pytz.utc))
     self.assertEqual(test.wait_time, timedelta(seconds=5.0))
     self.assertEqual(test.duration, timedelta(seconds=37.421521))
     self.assertEqual(test.wifi_bytes_received, 45)
     self.assertEqual(test.wifi_bytes_sent, 78)
     self.assertEqual(test.cell_bytes_received, 33)
     self.assertEqual(test.cell_bytes_sent, 25)
     self.assertEqual(test.multipath_service, 'aggregate')
     self.assertEqual(test.protocol, "QUIC")
     self.assertEqual(test.config.download, True)
     self.assertEqual(test.config.duration, 2)
     self.assertEqual(test.config.port, 8008)
     self.assertEqual(test.config.url, "superman.com")
     self.assertEqual(test.result.intervals.count(), 2)
     self.assertEqual(
         max([x.transferredLastSecond
              for x in test.result.intervals.all()]), 22000)
     self.assertEqual(
         min([x.transferredLastSecond
              for x in test.result.intervals.all()]), 20000)
     self.assertEqual(
         max([x.globalBandwidth for x in test.result.intervals.all()]),
         21000)
     self.assertEqual(
         min([x.globalBandwidth for x in test.result.intervals.all()]),
         20000)
     self.assertEqual(
         max([
             x.retransmittedLastSecond for x in test.result.intervals.all()
         ]), 770)
     self.assertEqual(
         min([
             x.retransmittedLastSecond for x in test.result.intervals.all()
         ]), 10)
     self.assertEqual(
         [x.intervalInSec for x in test.result.intervals.all()],
         ['0-1', '1-2'])
     self.assertEqual(test.result.success, True)
     self.assertEqual(test.result.total_sent, 42000)
     self.assertEqual(test.result.total_retrans, 780)
     self.assertTrue(test.quic_test_info is not None)
     self.assertTrue(
         timedelta(seconds=0) <= test.rcv_time -
         send_time <= timedelta(seconds=1))