Skip to content

Commit cef4a80

Browse files
authored
Add threaded utils tests, update CRC usage, add OWNERS (#1)
* Add threaded utils tests * Update to openshift-python-wrapper 11.0.44 * update owners * Add PR template and in-solidarity action * Add vme-perf to reviewers * Correct typing and update dependencies * Update OWNERS * Update pyproject.toml links
1 parent 2ec5e8c commit cef4a80

File tree

14 files changed

+733
-511
lines changed

14 files changed

+733
-511
lines changed

.github/in-solidarity.yml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
rules:
2+
master:
3+
level: failure # default rules are set to warning
4+
slave:
5+
level: failure
6+
blacklist:
7+
level: failure
8+
whitelist:
9+
level: failure
10+
ignore:
11+
- ".github/in-solidarity.yml" # default
12+
- ".github/workflows/*.yml"
13+
- "**/*.yml"

.github/pull_request_template.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
### Short description:
2+
3+
### More details:
4+
5+
### What this PR does / why we need it:
6+
7+
### Which issue(s) this PR fixes:
8+
9+
### Special notes for reviewer:
10+
11+
### Bug:

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,5 @@
55
.ruff_cache
66
dist
77
__pycache__
8+
.tests_coverage
9+
.pytest_cache

OWNERS

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
approvers:
2+
- sarahbx
3+
- m0rdechai
4+
reviewers:
5+
- sarahbx
6+
- qwang1
7+
- TzahiAshkenazi
8+
- duduvaa
9+
- m0rdechai
10+
- guchen11

ocp_scale_utilities/threaded/scale.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
import time
44
from contextlib import ExitStack, contextmanager
5-
from typing import Any, Optional
5+
from typing import Any, Optional, Sequence
66

77
import pytest
88
from ocp_resources.resource import Resource
@@ -19,18 +19,18 @@
1919
class ThreadedScaleResources(ExitStack):
2020
def __init__(
2121
self,
22-
resources: list[Resource],
23-
request_resources: Optional[list[Resource]] = None,
22+
resources: Sequence[Resource],
23+
request_resources: Optional[Sequence[Resource]] = None,
2424
pytest_cache: Optional[pytest.Cache] = None,
2525
cache_key_prefix: Optional[str] = None,
26-
wait_for_status: Optional[Resource.Status] = None,
26+
wait_for_status: Optional[str] = None,
2727
):
2828
"""
2929
Args:
30-
resources (list): List of Resource objects to be managed
30+
resources (Sequence): List of Resource objects to be managed
3131
pytest_cache (pytest.Cache): config.cache from python run to store results in
3232
cache_key_prefix (str): prefix to use for cache_keys
33-
wait_for_status (Resource.Status): Wait for provided status upon deploy
33+
wait_for_status (str): Wait for provided status upon deploy
3434
"""
3535
super().__init__()
3636
self.resources = resources
@@ -61,6 +61,7 @@ def __enter__(self) -> ThreadedScaleResources:
6161

6262
stop_time = time.time()
6363
if self.pytest_cache and self.cache_key_prefix:
64+
self.pytest_cache.set(f"{self.cache_key_prefix}-deploy-count", len(self.resources))
6465
self.pytest_cache.set(f"{self.cache_key_prefix}-deploy-start", start_time)
6566
self.pytest_cache.set(f"{self.cache_key_prefix}-deploy-stop", stop_time)
6667
self.pytest_cache.set(f"{self.cache_key_prefix}-deploy-elapsed", stop_time - start_time)

ocp_scale_utilities/threaded/utils.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import logging
44
from concurrent.futures import ThreadPoolExecutor
55
from contextlib import ExitStack
6-
from typing import Any, Optional
6+
from typing import Any, Optional, Sequence
77

88
from ocp_resources.resource import Resource
99

@@ -12,7 +12,7 @@
1212
LOGGER = logging.getLogger(__name__)
1313

1414

15-
def threaded_clean_up_resources(resources: list[Resource]) -> list[Any]:
15+
def threaded_clean_up_resources(resources: Sequence[Resource]) -> list[Any]:
1616
"""
1717
Call clean_up() for multiple resources via threads
1818
@@ -26,7 +26,7 @@ def threaded_clean_up_resources(resources: list[Resource]) -> list[Any]:
2626
return list(executor.map(lambda x: x.clean_up(), resources))
2727

2828

29-
def threaded_delete_resources(resources: list[Resource]) -> list[Any]:
29+
def threaded_delete_resources(resources: Sequence[Resource]) -> list[Any]:
3030
"""
3131
Call delete() for multiple resources via threads
3232
@@ -40,7 +40,7 @@ def threaded_delete_resources(resources: list[Resource]) -> list[Any]:
4040
return list(executor.map(lambda x: x.delete(), resources))
4141

4242

43-
def threaded_wait_deleted_resources(resources: list[Resource]) -> list[Any]:
43+
def threaded_wait_deleted_resources(resources: Sequence[Resource]) -> list[Any]:
4444
"""
4545
Call wait_deleted() for multiple resources via threads
4646
@@ -55,7 +55,7 @@ def threaded_wait_deleted_resources(resources: list[Resource]) -> list[Any]:
5555

5656

5757
def threaded_deploy_requested_resources(
58-
resources: list[Resource], request_resources: list[Resource], exit_stack: Optional[ExitStack] = None
58+
resources: Sequence[Resource], request_resources: Sequence[Resource], exit_stack: Optional[ExitStack] = None
5959
) -> list[Any]:
6060
"""
6161
Deploy multiple resources via threads
@@ -81,7 +81,7 @@ def _deploy(_resource: tuple[Resource, Resource]) -> Any:
8181
return list(executor.map(_deploy, zip(request_resources, resources)))
8282

8383

84-
def threaded_deploy_resources(resources: list[Resource], exit_stack: Optional[ExitStack] = None) -> list[Any]:
84+
def threaded_deploy_resources(resources: Sequence[Resource], exit_stack: Optional[ExitStack] = None) -> list[Any]:
8585
"""
8686
Deploy multiple resources via threads
8787
@@ -104,14 +104,14 @@ def _deploy(_resource: Resource) -> Any:
104104

105105

106106
def threaded_wait_for_resources_status(
107-
resources: list[Resource], status: Resource.Status, timeout: int = TIMEOUT_2MIN
107+
resources: Sequence[Resource], status: str, timeout: int = TIMEOUT_2MIN
108108
) -> list[Any]:
109109
"""
110110
Wait for multiple resources to to reach status via threads
111111
112112
Args:
113113
resources (list): List of Resources
114-
status: (Resource.Status): Status to wait for
114+
status: (str): Status to wait for
115115
timeout: (int): Length of time for each thread to wait for resource to reach status
116116
117117
Returns:

pyproject.toml

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ omit = [
2020
]
2121

2222
[tool.coverage.report]
23-
fail_under = 45
23+
fail_under = 90
2424
skip_empty = true
2525

2626
[tool.coverage.html]
@@ -49,7 +49,7 @@ dev-dependencies = [ "ipdb>=0.13.13", "ipython>=8.12.3" ]
4949
[project]
5050
name = "openshift-python-scale-utilities"
5151
requires-python = ">=3.12.0"
52-
version = "0.1.1.3"
52+
version = "0.1.1.4"
5353
description = "OpenShift Python Scale Utilities"
5454
readme = "README.md"
5555
license = "Apache-2.0"
@@ -59,23 +59,26 @@ classifiers = [
5959
"Operating System :: OS Independent"
6060
]
6161
dependencies = [
62-
"pytest>=8.3.3",
63-
"timeout-sampler>=1.0.1",
64-
"openshift-python-wrapper~=11.0.10",
62+
"openshift-python-wrapper>=11.0.44",
6563
"openshift-python-utilities>=6.0.0",
64+
"pytest>=8.3.3",
65+
"pytest-order>=1.3.0",
6666
"python-simple-logger~=2.0.9",
67+
"timeout-sampler>=1.0.1",
6768
]
6869

6970
[[project.authors]]
7071
name = "Sarah Bennert"
72+
email = "sarahbx@redhat.com"
7173

7274
[[project.maintainers]]
7375
name = "Sarah Bennert"
76+
email = "sarahbx@redhat.com"
7477

7578
[project.urls]
76-
homepage = "https://github.com/sarahbx/openshift-python-scale-utilities"
79+
homepage = "https://github.com/redhat-vmeperf/openshift-python-scale-utilities"
7780
Download = "https://pypi.org/project/openshift-python-scale-utilities/"
78-
"Bug Tracker" = "https://github.com/sarahbx/openshift-python-scale-utilities/issues"
81+
"Bug Tracker" = "https://github.com/redhat-vmeperf/openshift-python-scale-utilities/issues"
7982

8083

8184
[build-system]

tests/README.md

Lines changed: 12 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,16 @@
11
# Running Tests
22

3-
## Pre-configuration
3+
## Setup uv
4+
https://github.com/astral-sh/uv
45

5-
### Existing Running Cluster (CRC or otherwise)
6-
Simply set the KUBECONFIG environment variable
7-
```
8-
export KUBECONFIG=...
9-
```
6+
## OpenShift Local (CRC)
107

11-
### OpenShift Local (CRC)
12-
13-
#### Download CRC
8+
### Download CRC
149
https://console.redhat.com/openshift/create/local
1510

16-
#### Setup CRC
11+
### Setup CRC
1712
https://crc.dev/docs/installing/
13+
1814
https://crc.dev/docs/configuring/
1915

2016
Example setup:
@@ -27,16 +23,15 @@ Example setup:
2723
./crc setup
2824
```
2925

30-
#### Set ENV vars to provide necessary paths to pytest
26+
### Set ENV vars to provide necessary paths to pytest
3127

32-
If you wish to use a running CRC cluster set the KUBECONFIG path only
28+
Set CRC_PATH only. If CRC is already running, will use it, otherwise will start/stop CRC.
3329
```
34-
unset CRC_PATH
35-
export KUBECONFIG=~/.crc/machines/crc/kubeconfig
30+
unset KUBECONFIG
31+
export CRC_PATH=~/openshift-local/crc-linux-2.49.0-amd64/crc
3632
```
3733

38-
If you want the test automation to start and stop CRC, set the CRC_PATH only
34+
## Run tests
3935
```
40-
unset KUBECONFIG
41-
export CRC_PATH=~/openshift-local/crc-linux-2.49.0-amd64/crc
36+
uv run pytest tests
4237
```

0 commit comments

Comments
 (0)