azure-developer-loadtesting 1.0.0__zip

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (54) hide show
  1. azure-developer-loadtesting-1.0.0/CHANGELOG.md +72 -0
  2. azure-developer-loadtesting-1.0.0/LICENSE +21 -0
  3. azure-developer-loadtesting-1.0.0/MANIFEST.in +7 -0
  4. azure-developer-loadtesting-1.0.0/PKG-INFO +281 -0
  5. azure-developer-loadtesting-1.0.0/README.md +258 -0
  6. azure-developer-loadtesting-1.0.0/azure/__init__.py +1 -0
  7. azure-developer-loadtesting-1.0.0/azure/developer/__init__.py +1 -0
  8. azure-developer-loadtesting-1.0.0/azure/developer/loadtesting/__init__.py +10 -0
  9. azure-developer-loadtesting-1.0.0/azure/developer/loadtesting/_client.py +97 -0
  10. azure-developer-loadtesting-1.0.0/azure/developer/loadtesting/_generated/__init__.py +26 -0
  11. azure-developer-loadtesting-1.0.0/azure/developer/loadtesting/_generated/_client.py +88 -0
  12. azure-developer-loadtesting-1.0.0/azure/developer/loadtesting/_generated/_configuration.py +71 -0
  13. azure-developer-loadtesting-1.0.0/azure/developer/loadtesting/_generated/_patch.py +24 -0
  14. azure-developer-loadtesting-1.0.0/azure/developer/loadtesting/_generated/_serialization.py +1996 -0
  15. azure-developer-loadtesting-1.0.0/azure/developer/loadtesting/_generated/_vendor.py +20 -0
  16. azure-developer-loadtesting-1.0.0/azure/developer/loadtesting/_generated/_version.py +9 -0
  17. azure-developer-loadtesting-1.0.0/azure/developer/loadtesting/_generated/aio/__init__.py +23 -0
  18. azure-developer-loadtesting-1.0.0/azure/developer/loadtesting/_generated/aio/_client.py +88 -0
  19. azure-developer-loadtesting-1.0.0/azure/developer/loadtesting/_generated/aio/_configuration.py +71 -0
  20. azure-developer-loadtesting-1.0.0/azure/developer/loadtesting/_generated/aio/_patch.py +23 -0
  21. azure-developer-loadtesting-1.0.0/azure/developer/loadtesting/_generated/aio/_vendor.py +17 -0
  22. azure-developer-loadtesting-1.0.0/azure/developer/loadtesting/_generated/aio/operations/__init__.py +21 -0
  23. azure-developer-loadtesting-1.0.0/azure/developer/loadtesting/_generated/aio/operations/_operations.py +6517 -0
  24. azure-developer-loadtesting-1.0.0/azure/developer/loadtesting/_generated/aio/operations/_patch.py +187 -0
  25. azure-developer-loadtesting-1.0.0/azure/developer/loadtesting/_generated/operations/__init__.py +21 -0
  26. azure-developer-loadtesting-1.0.0/azure/developer/loadtesting/_generated/operations/_operations.py +7242 -0
  27. azure-developer-loadtesting-1.0.0/azure/developer/loadtesting/_generated/operations/_patch.py +195 -0
  28. azure-developer-loadtesting-1.0.0/azure/developer/loadtesting/_version.py +6 -0
  29. azure-developer-loadtesting-1.0.0/azure/developer/loadtesting/aio/__init__.py +9 -0
  30. azure-developer-loadtesting-1.0.0/azure/developer/loadtesting/aio/_client.py +107 -0
  31. azure-developer-loadtesting-1.0.0/azure/developer/loadtesting/py.typed +1 -0
  32. azure-developer-loadtesting-1.0.0/azure_developer_loadtesting.egg-info/PKG-INFO +281 -0
  33. azure-developer-loadtesting-1.0.0/azure_developer_loadtesting.egg-info/SOURCES.txt +52 -0
  34. azure-developer-loadtesting-1.0.0/azure_developer_loadtesting.egg-info/dependency_links.txt +1 -0
  35. azure-developer-loadtesting-1.0.0/azure_developer_loadtesting.egg-info/not-zip-safe +1 -0
  36. azure-developer-loadtesting-1.0.0/azure_developer_loadtesting.egg-info/requires.txt +5 -0
  37. azure-developer-loadtesting-1.0.0/azure_developer_loadtesting.egg-info/top_level.txt +1 -0
  38. azure-developer-loadtesting-1.0.0/pyproject.toml +6 -0
  39. azure-developer-loadtesting-1.0.0/samples/begin_test_run.py +52 -0
  40. azure-developer-loadtesting-1.0.0/samples/create_or_update_app_components.py +57 -0
  41. azure-developer-loadtesting-1.0.0/samples/create_or_update_test_function.py +84 -0
  42. azure-developer-loadtesting-1.0.0/samples/delete_load_test_function.py +46 -0
  43. azure-developer-loadtesting-1.0.0/samples/delete_load_test_run.py +39 -0
  44. azure-developer-loadtesting-1.0.0/samples/get_metrics.py +64 -0
  45. azure-developer-loadtesting-1.0.0/samples/upload_test_file.py +45 -0
  46. azure-developer-loadtesting-1.0.0/setup.cfg +4 -0
  47. azure-developer-loadtesting-1.0.0/setup.py +71 -0
  48. azure-developer-loadtesting-1.0.0/tests/conftest.py +60 -0
  49. azure-developer-loadtesting-1.0.0/tests/test_admin_ops.py +284 -0
  50. azure-developer-loadtesting-1.0.0/tests/test_async_admin_ops.py +286 -0
  51. azure-developer-loadtesting-1.0.0/tests/test_async_run_ops.py +286 -0
  52. azure-developer-loadtesting-1.0.0/tests/test_run_ops.py +289 -0
  53. azure-developer-loadtesting-1.0.0/tests/testcase.py +41 -0
  54. azure-developer-loadtesting-1.0.0/tests/testcase_async.py +26 -0
@@ -0,0 +1,187 @@
1
+ # ------------------------------------
2
+ # Copyright (c) Microsoft Corporation.
3
+ # Licensed under the MIT License.
4
+ # ------------------------------------
5
+ """Customize generated code here.
6
+
7
+ Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize
8
+ """
9
+ import asyncio
10
+ import logging
11
+ from functools import partial
12
+ from typing import List, Optional, Any, IO, Union, Callable, overload, Generic, TypeVar
13
+
14
+ from azure.core.polling import AsyncPollingMethod, AsyncLROPoller
15
+ from azure.core.tracing.decorator import distributed_trace
16
+
17
+ from ._operations import AdministrationOperations as AdministrationOperationsGenerated, JSON
18
+ from ._operations import TestRunOperations as TestRunOperationsGenerated
19
+
20
+ PollingReturnType = TypeVar("PollingReturnType")
21
+ logger = logging.getLogger(__name__)
22
+
23
+
24
+ class AsyncLoadTestingPollingMethod(AsyncPollingMethod):
25
+ """Base class for custom async polling methods."""
26
+
27
+ def _update_status(self) -> None:
28
+ raise NotImplementedError("This method needs to be implemented")
29
+
30
+ async def _update_resource(self) -> None:
31
+ self._resource = await self._command()
32
+
33
+ def initialize(self, client, initial_response, deserialization_callback) -> None:
34
+ self._command = client
35
+ self._initial_response = initial_response
36
+ self._resource = initial_response
37
+
38
+ def status(self) -> str:
39
+ return self._status
40
+
41
+ def finished(self) -> bool:
42
+ return self._status in self._termination_statuses
43
+
44
+ def resource(self) -> JSON:
45
+ return self._resource
46
+
47
+ async def run(self) -> None:
48
+ try:
49
+ while not self.finished():
50
+ await self._update_resource()
51
+ self._update_status()
52
+
53
+ if not self.finished():
54
+ await asyncio.sleep(self._polling_interval)
55
+ except Exception as e:
56
+ logger.error(e)
57
+ raise e
58
+
59
+
60
+ class AsyncValidationCheckPoller(AsyncLoadTestingPollingMethod):
61
+ def __init__(self, interval=5) -> None:
62
+ self._resource = None
63
+ self._command = None
64
+ self._initial_response = None
65
+ self._polling_interval = interval
66
+ self._status = None
67
+ self._termination_statuses = ["VALIDATION_SUCCESS", "VALIDATION_FAILED", "VALIDATION_NOT_REQUIRED"]
68
+
69
+ def _update_status(self) -> None:
70
+ self._status = self._resource["validationStatus"]
71
+
72
+
73
+ class AsyncTestRunStatusPoller(AsyncLoadTestingPollingMethod):
74
+ def __init__(self, interval=5) -> None:
75
+ self._resource = None
76
+ self._command = None
77
+ self._initial_response = None
78
+ self._polling_interval = interval
79
+ self._status = None
80
+ self._termination_statuses = ["DONE", "FAILED", "CANCELLED"]
81
+
82
+ def _update_status(self) -> None:
83
+ self._status = self._resource["status"]
84
+
85
+
86
+ class AdministrationOperations(AdministrationOperationsGenerated):
87
+ """
88
+ for performing the operations on test
89
+ """
90
+
91
+ def __init__(self, *args, **kwargs):
92
+ super(AdministrationOperations, self).__init__(*args, **kwargs)
93
+
94
+ @distributed_trace
95
+ async def begin_upload_test_file(
96
+ self, test_id: str, file_name: str, body: IO, *, file_type: Optional[str] = None, **kwargs: Any
97
+ ) -> AsyncLROPoller[JSON]:
98
+ """Upload file to the test
99
+
100
+ :param test_id: Unique id for the test
101
+ :type test_id: str
102
+ :param file_name: Name of the file to be uploaded
103
+ :type file_name: str
104
+ :param body: File content to be uploaded
105
+ :type body: IO
106
+ :param file_type: Type of the file to be uploaded
107
+ :type file_type: str
108
+ :return: An instance of LROPoller object to check the validation status of file
109
+ :rtype: ~azure.core.polling.LROPoller
110
+ :raises ~azure.core.exceptions.HttpResponseError:
111
+ :raises ~azure.core.exceptions.ResourceNotFoundError:
112
+ """
113
+
114
+ polling_interval = kwargs.pop("_polling_interval", None)
115
+ if polling_interval is None:
116
+ polling_interval = 5
117
+ upload_test_file_operation = await super().begin_upload_test_file(
118
+ test_id=test_id, file_name=file_name, body=body, file_type=file_type, **kwargs
119
+ )
120
+
121
+ command = partial(self.get_test_file, test_id=test_id, file_name=file_name)
122
+
123
+ create_validation_status_polling = AsyncValidationCheckPoller(interval=polling_interval)
124
+ return AsyncLROPoller(command, upload_test_file_operation, lambda *_: None, create_validation_status_polling)
125
+
126
+
127
+ class TestRunOperations(TestRunOperationsGenerated):
128
+ """
129
+ class to perform operations on TestRun
130
+ """
131
+
132
+ def __init__(self, *args, **kwargs):
133
+ super(TestRunOperations, self).__init__(*args, **kwargs)
134
+
135
+ @distributed_trace
136
+ async def begin_test_run(
137
+ self, test_run_id: str, body: Union[JSON, IO], *, old_test_run_id: Optional[str] = None, **kwargs: Any
138
+ ) -> AsyncLROPoller[JSON]:
139
+ """Create and start a new test run with the given name.
140
+
141
+ Create and start a new test run with the given name.
142
+
143
+ :param test_run_id: Unique name for the load test run, must contain only lower-case alphabetic,
144
+ numeric, underscore or hyphen characters. Required.
145
+ :type test_run_id: str
146
+ :param body: Load test run model. Is either a model type or a IO type. Required.
147
+ :type body: JSON or IO
148
+ :keyword old_test_run_id: Existing test run identifier that should be rerun, if this is
149
+ provided, the test will run with the JMX file, configuration and app components from the
150
+ existing test run. You can override the configuration values for new test run in the request
151
+ body. Default value is None.
152
+ :paramtype old_test_run_id: str
153
+ :keyword content_type: Body Parameter content-type. Known values are:
154
+ 'application/merge-patch+json'. Default value is None.
155
+ :paramtype content_type: str
156
+
157
+ :rtype: ~azure.developer.loadtesting._polling.LoadTestingLROPoller
158
+ :raises ~azure.core.exceptions.HttpResponseError:
159
+ :raises ~azure.core.exceptions.ResourceNotFoundError:
160
+ """
161
+
162
+ polling_interval = kwargs.pop("_polling_interval", None)
163
+ if polling_interval is None:
164
+ polling_interval = 5
165
+ create_or_update_test_run_operation = await super()._test_run_initial(
166
+ test_run_id, body, old_test_run_id=old_test_run_id, **kwargs
167
+ )
168
+
169
+ command = partial(self.get_test_run, test_run_id=test_run_id)
170
+
171
+ create_test_run_polling = AsyncTestRunStatusPoller(interval=polling_interval)
172
+ return AsyncLROPoller(command, create_or_update_test_run_operation, lambda *_: None, create_test_run_polling)
173
+
174
+
175
+ __all__: List[str] = ["AdministrationOperations", "TestRunOperations"]
176
+
177
+
178
+ # Add all objects you want publicly available to users at this package level
179
+
180
+
181
+ def patch_sdk():
182
+ """Do not remove from this file.
183
+
184
+ `patch_sdk` is a last resort escape hatch that allows you to do customizations
185
+ you can't accomplish using the techniques described in
186
+ https://aka.ms/azsdk/python/dpcodegen/python/customize
187
+ """
@@ -0,0 +1,21 @@
1
+ # coding=utf-8
2
+ # --------------------------------------------------------------------------
3
+ # Copyright (c) Microsoft Corporation. All rights reserved.
4
+ # Licensed under the MIT License. See License.txt in the project root for license information.
5
+ # Code generated by Microsoft (R) AutoRest Code Generator.
6
+ # Changes may cause incorrect behavior and will be lost if the code is regenerated.
7
+ # --------------------------------------------------------------------------
8
+
9
+ from ._operations import AdministrationOperations
10
+ from ._operations import TestRunOperations
11
+
12
+ from ._patch import __all__ as _patch_all
13
+ from ._patch import * # pylint: disable=unused-wildcard-import
14
+ from ._patch import patch_sdk as _patch_sdk
15
+
16
+ __all__ = [
17
+ "AdministrationOperations",
18
+ "TestRunOperations",
19
+ ]
20
+ __all__.extend([p for p in _patch_all if p not in __all__])
21
+ _patch_sdk()