Skip to content

Commit

Permalink
* [e2e] refactor upgrade test
Browse files Browse the repository at this point in the history
  • Loading branch information
lanfon72 committed Apr 18, 2024
1 parent df9121c commit 3d21068
Show file tree
Hide file tree
Showing 4 changed files with 665 additions and 1,000 deletions.
10 changes: 7 additions & 3 deletions apiclient/harvester_api/managers/internals.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,11 @@ class UpgradeManager(BaseManager):
CREATE_PATH = "v1/harvester/harvesterhci.io.upgrades"
API_PATH_fmt = "v1/harvester/harvesterhci.io.upgrades/{namespace}{name}"

def create_data(self, version_name, namespace=DEFAULT_HARVESTER_NAMESPACE):
def create_data(self, version_name, namespace=DEFAULT_HARVESTER_NAMESPACE, annotations=None):
annotations = annotations or dict()
data = {
"type": "harvesterhci.io.upgrade",
"annotations": annotations,
"metadata": {
"generateName": "hvst-upgrade-",
"namespace": namespace
Expand All @@ -54,8 +56,10 @@ def create_data(self, version_name, namespace=DEFAULT_HARVESTER_NAMESPACE):
}
return data

def create(self, version_name, namespace=DEFAULT_HARVESTER_NAMESPACE, *, raw=False):
data = self.create_data(version_name)
def create(
self, version_name, namespace=DEFAULT_HARVESTER_NAMESPACE, *, raw=False, annotations=None
):
data = self.create_data(version_name, annotations=annotations)
path = self.API_PATH_fmt.format(name="", namespace=namespace)
return self._create(path, json=data, raw=raw)

Expand Down
8 changes: 8 additions & 0 deletions apiclient/harvester_api/managers/storageclasses.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,14 @@ def get(self, name="", *, raw=False, **kwargs):
path = self.PATH_fmt.format(SC_API=self.API_VERSION, name=name)
return self._get(path, raw=raw, **kwargs)

def get_default(self):
code, data = self.get()
for sc in data['items']:
if 'true' == sc['metadata']['annotations'].get(DEFAULT_STORAGE_CLASS_ANNOTATION):
return code, sc
else:
return code, data

def create_data(self, name, replicas):
data = {
"type": f"{self.API_VERSION}",
Expand Down
5 changes: 5 additions & 0 deletions harvester_e2e_tests/fixtures/api_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,11 @@ def sleep_timeout(request):
return request.config.getoption("--sleep-timeout", 4)


@pytest.fixture(scope="session")
def upgrade_timeout(request):
return request.config.getoption('--upgrade-wait-timeout') or 7200


@pytest.fixture(scope="session")
def rancher_wait_timeout(request):
return request.config.getoption("--rancher-cluster-wait-timeout", 1800)
Expand Down

0 comments on commit 3d21068

Please sign in to comment.