bugfix: Fix shaping no rate limit case fail bug.

This commit is contained in:
fumingwei
2024-06-11 11:09:04 +08:00
parent 7028025701
commit 0e9a9fe83b
2 changed files with 18 additions and 12 deletions

View File

@@ -298,7 +298,8 @@ class URLTransferBuilder:
self._local_port = None
self._remote_ip = None
self._remote_port = None
self._connection_time_ms = None
self._total_time_s = None
self._speed_download = None
def _setup_connection(self):
self._response_buffer = BytesIO()
@@ -318,7 +319,8 @@ class URLTransferBuilder:
self._local_port = self._conn.getinfo(pycurl.LOCAL_PORT)
self._remote_ip = self._conn.getinfo(pycurl.PRIMARY_IP)
self._remote_port = self._conn.getinfo(pycurl.PRIMARY_PORT)
self._connection_time_ms = self._conn.getinfo(pycurl.CONNECT_TIME)
self._total_time_s = self._conn.getinfo(pycurl.TOTAL_TIME)
self._speed_download = self._conn.getinfo(pycurl.SPEED_DOWNLOAD)
def _close_connection(self):
self._conn.close()
@@ -348,15 +350,19 @@ class URLTransferBuilder:
def size_download(self):
return self._size_download
@property
def speed_download(self):
return self._speed_download
@property
def quadruple(self):
return f"{self._local_ip}:{self._local_port},{self._remote_ip}:{self._remote_port}"
@property
def connect_time_s(self):
def total_time_s(self):
if self._close_connection is None:
return None
return self._connection_time_ms/1000000
return self._total_time_s
class HttpURLTransferBuilder(URLTransferBuilder):
def _perform_connection(self):
@@ -915,10 +921,10 @@ class ShapingCaseRunner:
status, info = URLTransferResponseAssertion.is_response_code_equal(conn.response_code, 200)
if not status:
return False, info
status, info = URLTransferResponseAssertion.is_connect_time_less_than(conn.connect_time_s, 5)
status, info = URLTransferResponseAssertion.is_connect_time_less_than(conn.total_time_s, 5)
if not status:
return False, info
return True, f"The connect time in seconds is: {conn.connect_time_s}."
return True, f"The connect total time in seconds is: {conn.total_time_s}."
@staticmethod
def no_rate_limit_protocol_https(url, resolves, conn_timeout, max_recv_speed):
@@ -933,10 +939,10 @@ class ShapingCaseRunner:
status, info = URLTransferResponseAssertion.is_cert_issuer_matched(conn.cert_issuer, r'\bCN[\s]*=[\s]*BadSSL\b')
if not status:
return False, info
status, info = URLTransferResponseAssertion.is_connect_time_less_than(conn.connect_time_s, 5)
status, info = URLTransferResponseAssertion.is_connect_time_less_than(conn.total_time_s, 5)
if not status:
return False, info
return True, f"The connect time in seconds is: {conn.connect_time_s}."
return True, f"The connect total time in seconds is: {conn.total_time_s}."
@staticmethod
def rate_limit_0bps_protocol_http(url, resolves, conn_timeout, max_recv_speed):
@@ -1579,9 +1585,9 @@ class DiagnoseCasesRunner:
},
{
"name": "Shaping_NoRateLimit_HTTPS",
"protocol_type": "http",
"protocol_type": "https",
"test_function": ShapingCaseRunner.no_rate_limit_protocol_https,
"request_content": "http://testing-no-rate-limit.badssl.selftest.gdnt-cloud.website/resources/64M",
"request_content": "https://testing-no-rate-limit.badssl.selftest.gdnt-cloud.website/resources/64M",
"conn_timeout": 12,
"max_recv_speed": None
},

View File

@@ -2,14 +2,14 @@
---
server {
listen 80;
server_name no-rate-limit.{{ site.domain }};
server_name testing-no-rate-limit.{{ site.domain }};
include {{ site.serving-path }}/common/common.conf;
root {{ site.serving-path }}/domains/testing-rate-limit/root;
}
server {
listen 443;
server_name no-rate-limit.{{ site.domain }};
server_name testing-no-rate-limit.{{ site.domain }};
include {{ site.serving-path }}/nginx-includes/wildcard-normal.conf;
include {{ site.serving-path }}/nginx-includes/tls-defaults.conf;
root {{ site.serving-path }}/domains/testing-rate-limit/root;