-
Notifications
You must be signed in to change notification settings - Fork 54
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test(robot): add storageclass for different replica count
longhorn/longhorn-8440 Signed-off-by: Chris <[email protected]>
- Loading branch information
1 parent
694c746
commit 89be495
Showing
9 changed files
with
85 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
*** Settings *** | ||
Documentation Storageclass Keywords | ||
Library Collections | ||
Library ../libs/keywords/common_keywords.py | ||
Library ../libs/keywords/storageclass_keywords.py | ||
|
||
*** Keywords *** | ||
Create storageclass ${storageclass_id} with | ||
[Arguments] &{config} | ||
${storageclass_name} = generate_name_with_suffix storageclass ${storageclass_id} | ||
create_storageclass ${storageclass_name} &{config} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
from utility.utility import logging | ||
from storageclass.storageclass import create | ||
from storageclass.storageclass import delete | ||
from storageclass.storageclass import delete_all | ||
|
||
class storageclass_keywords: | ||
|
||
def __init__(self): | ||
pass | ||
|
||
def init_storageclasses(self): | ||
create('longhorn-test') | ||
create('longhorn-test-strict-local', replica_count="1", data_locality='strict-local') | ||
|
||
def create_storageclass(self, name, replica_count="", migratable="", data_locality="", from_backup=""): | ||
logging(f'Creating storageclass {name}') | ||
create(name, replica_count, migratable, data_locality, from_backup) | ||
|
||
def delete_storageclass(self, name): | ||
delete(name) | ||
|
||
def cleanup_storageclasses(self): | ||
delete_all() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
from storageclass import storageclass |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
import yaml | ||
|
||
from kubernetes import client | ||
from kubernetes.client.rest import ApiException | ||
from kubernetes.stream import stream | ||
|
||
|
||
def create(name, replica_count="", migratable="", data_locality="", from_backup=""): | ||
filepath = "./templates/workload/storageclass.yaml" | ||
|
||
with open(filepath, 'r') as f: | ||
manifest_dict = yaml.safe_load(f) | ||
manifest_dict['metadata']['name'] = name | ||
|
||
if replica_count != "": | ||
manifest_dict['parameters']['numberOfReplicas'] = replica_count | ||
if migratable != "": | ||
manifest_dict['parameters']['migratable'] = migratable | ||
if data_locality != "": | ||
manifest_dict['parameters']['dataLocality'] = data_locality | ||
if from_backup != "": | ||
manifest_dict['parameters']['fromBackup'] = from_backup | ||
|
||
api = client.StorageV1Api() | ||
api.create_storage_class(body=manifest_dict) | ||
|
||
|
||
def delete(name): | ||
api = client.StorageV1Api() | ||
try: | ||
api.delete_storage_class(name, grace_period_seconds=0) | ||
except ApiException as e: | ||
assert e.status == 404 | ||
|
||
|
||
def delete_all(): | ||
api = client.StorageV1Api() | ||
storage_classes = api.list_storage_class() | ||
|
||
for item in storage_classes.items: | ||
if "longhorn-test" in item.metadata.name: | ||
delete(item.metadata.name) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters