Add support for dotnet_endpoint/dotnet_functions to integration-test.py (#2192)

This will allow testing client-facing .NET Functions during integration tests (`check-pr`).
This commit is contained in:
George Pollard
2022-07-26 14:44:59 +12:00
committed by GitHub
parent 992751044f
commit c653f2e8ef

View File

@ -230,13 +230,13 @@ OperationResult = TypeVar("OperationResult")
def retry( def retry(
logger: logging.Logger,
operation: Callable[[Any], OperationResult], operation: Callable[[Any], OperationResult],
description: str, description: str,
tries: int = 10, tries: int = 10,
wait_duration: int = 10, wait_duration: int = 10,
data: Any = None, data: Any = None,
) -> OperationResult: ) -> OperationResult:
logger = logging.Logger
count = 0 count = 0
while True: while True:
try: try:
@ -280,7 +280,7 @@ class TestOnefuzz:
def try_info_get(data: Any) -> None: def try_info_get(data: Any) -> None:
self.of.info.get() self.of.info.get()
retry(try_info_get, "testing endpoint") retry(self.logger, try_info_get, "testing endpoint")
self.inject_log(self.start_log_marker) self.inject_log(self.start_log_marker)
for entry in os_list: for entry in os_list:
@ -917,12 +917,16 @@ class Run(Command):
poll: bool = False, poll: bool = False,
stop_on_complete_check: bool = False, stop_on_complete_check: bool = False,
job_ids: List[UUID] = [], job_ids: List[UUID] = [],
dotnet_endpoint: Optional[str] = None,
dotnet_functions: Optional[List[str]] = None,
) -> None: ) -> None:
self.onefuzz.__setup__( self.onefuzz.__setup__(
endpoint=endpoint, endpoint=endpoint,
client_id=client_id, client_id=client_id,
client_secret=client_secret, client_secret=client_secret,
authority=authority, authority=authority,
_dotnet_endpoint=dotnet_endpoint,
_dotnet_functions=dotnet_functions,
) )
tester = TestOnefuzz(self.onefuzz, self.logger, test_id) tester = TestOnefuzz(self.onefuzz, self.logger, test_id)
result = tester.check_jobs( result = tester.check_jobs(
@ -940,12 +944,16 @@ class Run(Command):
client_secret: Optional[str], client_secret: Optional[str],
authority: Optional[str] = None, authority: Optional[str] = None,
job_ids: List[UUID] = [], job_ids: List[UUID] = [],
dotnet_endpoint: Optional[str] = None,
dotnet_functions: Optional[List[str]] = None,
) -> None: ) -> None:
self.onefuzz.__setup__( self.onefuzz.__setup__(
endpoint=endpoint, endpoint=endpoint,
client_id=client_id, client_id=client_id,
client_secret=client_secret, client_secret=client_secret,
authority=authority, authority=authority,
_dotnet_endpoint=dotnet_endpoint,
_dotnet_functions=dotnet_functions,
) )
tester = TestOnefuzz(self.onefuzz, self.logger, test_id) tester = TestOnefuzz(self.onefuzz, self.logger, test_id)
launch_result, repros = tester.launch_repro(job_ids=job_ids) launch_result, repros = tester.launch_repro(job_ids=job_ids)
@ -964,10 +972,13 @@ class Run(Command):
region: Optional[Region] = None, region: Optional[Region] = None,
os_list: List[OS] = [OS.linux, OS.windows], os_list: List[OS] = [OS.linux, OS.windows],
test_id: Optional[UUID] = None, test_id: Optional[UUID] = None,
dotnet_endpoint: Optional[str] = None,
dotnet_functions: Optional[List[str]] = None,
) -> None: ) -> None:
if test_id is None: if test_id is None:
test_id = uuid4() test_id = uuid4()
self.logger.info("launching test_id: %s", test_id) self.logger.info("launching test_id: %s", test_id)
self.logger.info("dotnet configuration: %s, %s", dotnet_endpoint, dotnet_functions)
def try_setup(data: Any) -> None: def try_setup(data: Any) -> None:
self.onefuzz.__setup__( self.onefuzz.__setup__(
@ -975,9 +986,11 @@ class Run(Command):
client_id=client_id, client_id=client_id,
client_secret=client_secret, client_secret=client_secret,
authority=authority, authority=authority,
_dotnet_endpoint=dotnet_endpoint,
_dotnet_functions=dotnet_functions,
) )
retry(try_setup, "trying to configure") retry(self.logger, try_setup, "trying to configure")
tester = TestOnefuzz(self.onefuzz, self.logger, test_id) tester = TestOnefuzz(self.onefuzz, self.logger, test_id)
tester.setup(region=region, pool_size=pool_size, os_list=os_list) tester.setup(region=region, pool_size=pool_size, os_list=os_list)
@ -994,6 +1007,8 @@ class Run(Command):
targets: List[str] = list(TARGETS.keys()), targets: List[str] = list(TARGETS.keys()),
test_id: Optional[UUID] = None, test_id: Optional[UUID] = None,
duration: int = 1, duration: int = 1,
dotnet_endpoint: Optional[str] = None,
dotnet_functions: Optional[List[str]] = None,
) -> None: ) -> None:
if test_id is None: if test_id is None:
test_id = uuid4() test_id = uuid4()
@ -1005,9 +1020,11 @@ class Run(Command):
client_id=client_id, client_id=client_id,
client_secret=client_secret, client_secret=client_secret,
authority=authority, authority=authority,
_dotnet_endpoint=dotnet_endpoint,
_dotnet_functions=dotnet_functions,
) )
retry(try_setup, "trying to configure") retry(self.logger, try_setup, "trying to configure")
tester = TestOnefuzz(self.onefuzz, self.logger, test_id) tester = TestOnefuzz(self.onefuzz, self.logger, test_id)
@ -1026,12 +1043,16 @@ class Run(Command):
authority: Optional[str], authority: Optional[str],
client_id: Optional[str], client_id: Optional[str],
client_secret: Optional[str], client_secret: Optional[str],
dotnet_endpoint: Optional[str] = None,
dotnet_functions: Optional[List[str]] = None,
) -> None: ) -> None:
self.onefuzz.__setup__( self.onefuzz.__setup__(
endpoint=endpoint, endpoint=endpoint,
client_id=client_id, client_id=client_id,
client_secret=client_secret, client_secret=client_secret,
authority=authority, authority=authority,
_dotnet_endpoint=dotnet_endpoint,
_dotnet_functions=dotnet_functions,
) )
tester = TestOnefuzz(self.onefuzz, self.logger, test_id=test_id) tester = TestOnefuzz(self.onefuzz, self.logger, test_id=test_id)
tester.cleanup() tester.cleanup()
@ -1044,12 +1065,16 @@ class Run(Command):
authority: Optional[str] = None, authority: Optional[str] = None,
client_id: Optional[str], client_id: Optional[str],
client_secret: Optional[str], client_secret: Optional[str],
dotnet_endpoint: Optional[str] = None,
dotnet_functions: Optional[List[str]] = None,
) -> None: ) -> None:
self.onefuzz.__setup__( self.onefuzz.__setup__(
endpoint=endpoint, endpoint=endpoint,
client_id=client_id, client_id=client_id,
client_secret=client_secret, client_secret=client_secret,
authority=authority, authority=authority,
_dotnet_endpoint=dotnet_endpoint,
_dotnet_functions=dotnet_functions,
) )
tester = TestOnefuzz(self.onefuzz, self.logger, test_id=test_id) tester = TestOnefuzz(self.onefuzz, self.logger, test_id=test_id)
tester.check_logs_for_errors() tester.check_logs_for_errors()
@ -1064,6 +1089,8 @@ class Run(Command):
skip_repro: bool = False, skip_repro: bool = False,
test_id: UUID, test_id: UUID,
job_ids: List[UUID] = [], job_ids: List[UUID] = [],
dotnet_endpoint: Optional[str] = None,
dotnet_functions: Optional[List[str]] = None,
) -> None: ) -> None:
self.check_jobs( self.check_jobs(
@ -1075,6 +1102,8 @@ class Run(Command):
poll=True, poll=True,
stop_on_complete_check=True, stop_on_complete_check=True,
job_ids=job_ids, job_ids=job_ids,
dotnet_endpoint=dotnet_endpoint,
dotnet_functions=dotnet_functions,
) )
if skip_repro: if skip_repro:
@ -1087,6 +1116,8 @@ class Run(Command):
client_id=client_id, client_id=client_id,
client_secret=client_secret, client_secret=client_secret,
job_ids=job_ids, job_ids=job_ids,
dotnet_endpoint=dotnet_endpoint,
dotnet_functions=dotnet_functions,
) )
def test( def test(
@ -1103,6 +1134,8 @@ class Run(Command):
targets: List[str] = list(TARGETS.keys()), targets: List[str] = list(TARGETS.keys()),
skip_repro: bool = False, skip_repro: bool = False,
duration: int = 1, duration: int = 1,
dotnet_endpoint: Optional[str] = None,
dotnet_functions: Optional[List[str]] = None,
) -> None: ) -> None:
success = True success = True
@ -1116,9 +1149,11 @@ class Run(Command):
client_id=client_id, client_id=client_id,
client_secret=client_secret, client_secret=client_secret,
authority=authority, authority=authority,
_dotnet_endpoint=dotnet_endpoint,
_dotnet_functions=dotnet_functions,
) )
retry(try_setup, "trying to configure") retry(self.logger, try_setup, "trying to configure")
tester = TestOnefuzz(self.onefuzz, self.logger, test_id) tester = TestOnefuzz(self.onefuzz, self.logger, test_id)
tester.setup(region=region, pool_size=pool_size, os_list=os_list) tester.setup(region=region, pool_size=pool_size, os_list=os_list)
tester.launch(samples, os_list=os_list, targets=targets, duration=duration) tester.launch(samples, os_list=os_list, targets=targets, duration=duration)
@ -1150,6 +1185,8 @@ class Run(Command):
client_id=client_id, client_id=client_id,
client_secret=client_secret, client_secret=client_secret,
authority=authority, authority=authority,
dotnet_endpoint=dotnet_endpoint,
dotnet_functions=dotnet_functions,
) )
except Exception as e: except Exception as e:
self.logger.error("testing failed: %s", repr(e)) self.logger.error("testing failed: %s", repr(e))