Skip to content

Commit

Permalink
Merge pull request #27 from wenxinll/master
Browse files Browse the repository at this point in the history
添加边缘节点用例
  • Loading branch information
wenxinll authored Apr 14, 2023
2 parents 57be10c + d42cee4 commit 8b06e5a
Show file tree
Hide file tree
Showing 6 changed files with 247 additions and 118 deletions.
240 changes: 157 additions & 83 deletions TestCase/test_multiClusterManage.py

Large diffs are not rendered by default.

62 changes: 40 additions & 22 deletions TestCase/test_multiClusterStorage.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
from step import multi_cluster_storages_step, multi_cluster_steps, multi_workspace_steps, multi_project_steps


@allure.feature('multi_cluster_storage')
@allure.feature('多集群存储')
@pytest.mark.skipif(commonFunction.check_multi_cluster() is False, reason='单集群环境下不执行')
@pytest.mark.skipif(commonFunction.get_multi_cluster_sc_qingcloud() is False, reason='csi-qingcloud存储插件不存在')
class TestMultiClusterStorage:
Expand All @@ -32,6 +32,7 @@ class TestMultiClusterStorage:
strategy = {"type": "RollingUpdate", "rollingUpdate": {"maxUnavailable": "25%", "maxSurge": "25%"}}

def setup_class(self):
r = ''
self.cluster_name = multi_cluster_steps.step_get_host_cluster_name()
multi_workspace_steps.step_create_multi_ws(ws_name=self.ws_name, alias_name='', description='',
cluster_names=self.cluster_name)
Expand Down Expand Up @@ -90,7 +91,7 @@ def test_storage(self, id, url, params, data, story, title, method, severity, co
request_resource(targets_new[0], targets_new[1], targets_new[2], story, targets_new[3], method, severity,
targets_new[4], targets_new[5])

@allure.story("存储-存储类")
@allure.story("存储类")
@allure.title('设置卷操作')
@allure.severity('normal')
def test_set_volume_operations(self, create_multi_cluster_sc):
Expand All @@ -102,10 +103,12 @@ def test_set_volume_operations(self, create_multi_cluster_sc):
# 查看存储类详细信息
re = multi_cluster_storages_step.get_sc_info(self.cluster_name, create_multi_cluster_sc)
# 验证设置成功
pytest.assume(re.json()['metadata']['annotations']['storageclass.kubesphere.io/allow-clone'] == 'false')
pytest.assume(re.json()['metadata']['annotations']['storageclass.kubesphere.io/allow-snapshot'] == 'false')
with pytest.assume:
assert re.json()['metadata']['annotations']['storageclass.kubesphere.io/allow-clone'] == 'false'
with pytest.assume:
assert re.json()['metadata']['annotations']['storageclass.kubesphere.io/allow-snapshot'] == 'false'

@allure.story("存储-存储类")
@allure.story("存储类")
@allure.title('设置默认类')
@allure.severity('normal')
def test_set_default_sc(self):
Expand All @@ -120,7 +123,7 @@ def test_set_default_sc(self):
multi_cluster_storages_step.set_default_sc(self.cluster_name, self.sc_name, 'false')
multi_cluster_storages_step.set_default_sc(self.cluster_name, 'local', 'true')

@allure.story("存储-存储类")
@allure.story("存储类")
@allure.title('存储类的存储卷信息')
@allure.severity('normal')
def test_sc_pvc(self, create_multi_cluster_sc):
Expand All @@ -134,8 +137,10 @@ def test_sc_pvc(self, create_multi_cluster_sc):
'annotations'][
'kubesphere.io/pvc-count']
# 验证存储卷存在以及数量正确
pytest.assume(re.json()['items'][0]['metadata']['name'] == volume_name)
pytest.assume(num == '1')
with pytest.assume:
assert re.json()['items'][0]['metadata']['name'] == volume_name
with pytest.assume:
assert num == '1'
# 删除存储卷
multi_cluster_storages_step.delete_volume(self.cluster_name, self.pro_ws_name, volume_name)
# 查询存储卷数量
Expand All @@ -145,10 +150,12 @@ def test_sc_pvc(self, create_multi_cluster_sc):
# 查询存储类已有存储卷信息
re = multi_cluster_storages_step.search_volume_by_sc(self.cluster_name, create_multi_cluster_sc)
# 验证存储卷不存在以及数量正确
pytest.assume(re.json()['totalItems'] == 0)
pytest.assume(num1 == '0')
with pytest.assume:
assert re.json()['totalItems'] == 0
with pytest.assume:
assert num1 == '0'

@allure.story("存储-存储类")
@allure.story("存储类")
@allure.title('查询存储类已有存储卷')
@allure.severity('normal')
def test_search_pvc(self):
Expand All @@ -167,7 +174,7 @@ def test_search_pvc(self):
# 删除存储卷
multi_cluster_storages_step.delete_volume(self.cluster_name, self.pro_ws_name, volume_name)

@allure.story("存储-卷快照类")
@allure.story("卷快照类")
@allure.title('创建卷快照类')
@allure.severity('normal')
def test_create_vsc(self):
Expand All @@ -182,7 +189,7 @@ def test_create_vsc(self):
# 删除卷快照类
multi_cluster_storages_step.delete_vsc(self.cluster_name, vsc_name)

@allure.story("存储-卷快照类")
@allure.story("卷快照类")
@allure.title('编辑卷快照类信息')
@allure.severity('normal')
def test_set_vsc_info(self):
Expand All @@ -202,14 +209,18 @@ def test_set_vsc_info(self):
generation, version, uid, alias_name, des)
# 验证别名设置成功
res = multi_cluster_storages_step.search_vsc_by_name(self.cluster_name, vsc_name)
pytest.assume(res.json()['items'][0]['metadata']['annotations']['kubesphere.io/alias-name'] == alias_name)
with pytest.assume:
assert res.json()['items'][0]['metadata']['annotations']['kubesphere.io/alias-name'] == alias_name
# 验证描述信息设置成功
pytest.assume(res.json()['items'][0]['metadata']['annotations']['kubesphere.io/description'] == des)
with pytest.assume:
assert res.json()['items'][0]['metadata']['annotations']['kubesphere.io/description'] == des

@allure.story("存储-卷快照类")
@allure.story("卷快照类")
@allure.title('验证卷快照类的卷快照数量')
@allure.severity('normal')
def test_get_vs_by_vsc(self):
r1 = ''
r2 = ''
vs_name = 'snapshot-' + str(get_random())
vsc_name = self.sc_name1
volume_name = self.volume_name
Expand Down Expand Up @@ -248,10 +259,12 @@ def test_get_vs_by_vsc(self):
# 判断快照数量
assert r.json()['items'][0]['metadata']['annotations']['kubesphere.io/snapshot-count'] == '0'

@allure.story("存储-卷快照类")
@allure.story("卷快照类")
@allure.title('查询卷快照类的卷快照')
@allure.severity('normal')
def test_search_vs_by_vsc(self):
r1 = ''
r2 = ''
vs_name = 'snapshot-' + str(get_random())
vsc_name = self.sc_name1
volume_name = self.volume_name
Expand Down Expand Up @@ -295,10 +308,12 @@ def test_search_vs_by_vsc(self):
j = j + 1
assert r2.json()['totalItems'] == 0

@allure.story("存储-卷快照")
@allure.story("卷快照")
@allure.title('创建快照')
@allure.severity('normal')
def test_create_snapshots(self):
r1 = ''
r2 = ''
vs_name = 'snapshot-' + str(get_random())
vsc_name = self.sc_name1
volume_name = self.volume_name
Expand Down Expand Up @@ -331,10 +346,11 @@ def test_create_snapshots(self):
j = j + 1
assert r2.json()['totalItems'] == 0

@allure.story("存储-卷快照")
@allure.story("卷快照")
@allure.title('创建同名的快照')
@allure.severity('normal')
def test_create_same_snapshots(self):
r2 = ''
vs_name = 'snapshot-' + str(get_random())
vsc_name = self.sc_name1
volume_name = self.volume_name
Expand Down Expand Up @@ -369,7 +385,7 @@ def test_create_same_snapshots(self):
j = j + 1
assert r2.json()['totalItems'] == 0

@allure.story("存储-卷快照")
@allure.story("卷快照")
@allure.title('查询卷快照')
@allure.severity('normal')
def test_search_snapshots(self):
Expand Down Expand Up @@ -412,10 +428,11 @@ def test_search_snapshots(self):
j = j + 1
assert r2.json()['totalItems'] == 0

@allure.story("存储-卷快照")
@allure.story("卷快照")
@allure.title('使用卷快照创建存储卷')
@allure.severity('normal')
def test_create_volume_by_snapshots(self):
r2 = ''
vs_name = 'snapshot-' + str(get_random())
vsc_name = self.sc_name1
volume_name = self.volume_name
Expand Down Expand Up @@ -458,10 +475,11 @@ def test_create_volume_by_snapshots(self):
j = j + 1
assert r2.json()['totalItems'] == 0

@allure.story("存储-卷快照")
@allure.story("卷快照")
@allure.title('使用卷快照创建同名存储卷')
@allure.severity('normal')
def test_create_same_volume_by_snapshots(self):
r2 = ''
vs_name = 'snapshot-' + str(get_random())
vsc_name = self.sc_name1
volume_name = self.volume_name
Expand Down
2 changes: 2 additions & 0 deletions common/commonFunction.py
Original file line number Diff line number Diff line change
Expand Up @@ -430,6 +430,8 @@ def get_components_status_of_cluster(component):
component_status = spec[component]['networkpolicy']['enabled']
elif component == 'whizard':
component_status = spec['monitoring']['whizard']['enabled']
elif component == 'kubeedge':
component_status = spec['edgeruntime']['kubeedge']['enabled']
else:
component_status = spec[component]['enabled']
return component_status
Expand Down
3 changes: 2 additions & 1 deletion config/config_new.yaml
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
env:
url: ${ENV_URL}
# url: ${ENV_URL}
url: '139.198.113.104:31305'
34 changes: 22 additions & 12 deletions data/multi_cluster_storage.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,27 +2,29 @@
- /apis/clusters/${cluster_name}/storage.k8s.io/v1/storageclasses/${sc_name}
- ''
- '{"metadata":{"name":"${sc_name}","annotations":{"kubesphere.io/alias-name":"test","kubesphere.io/creator":"admin","kubesphere.io/provisioner":"disk.csi.qingcloud.com","kubesphere.io/pvc-count":"0","storageclass.kubesphere.io/allow-clone":"true","storageclass.kubesphere.io/allow-snapshot":"true","storageclass.kubesphere.io/supported-access-modes":"[\"ReadWriteOnce\"]"}},"provisioner":"disk.csi.qingcloud.com","parameters":{"fstype":"ext4"},"reclaimPolicy":"Delete","allowVolumeExpansion":True,"volumeBindingMode":"WaitForFirstConsumer"}'
- multi-cluster-storage
- 存储类
- 编辑存储类别名
- patch
- normal
- r.json()['metadata']['annotations']['kubesphere.io/alias-name']
- test

- - 2
- /apis/clusters/${cluster_name}/storage.k8s.io/v1/storageclasses/${sc_name}
- ''
- '{"kind":"StorageClass","apiVersion":"storage.k8s.io/v1","metadata":{"name":"${sc_name}","annotations":{"kubesphere.io/alias-name":"","kubesphere.io/creator":"admin","kubesphere.io/provisioner":"disk.csi.qingcloud.com","kubesphere.io/pvc-count":"0","storageclass.kubesphere.io/allow-clone":"true","storageclass.kubesphere.io/allow-snapshot":"true","storageclass.kubesphere.io/supported-access-modes":"[\"ReadWriteOnce\"]","kubesphere.io/description":"test-description"}},"provisioner":"disk.csi.qingcloud.com","parameters":{"fstype":"ext4"},"reclaimPolicy":"Delete","allowVolumeExpansion":True,"volumeBindingMode":"WaitForFirstConsumer"}'
- multi-cluster-storage
- 存储类
- 编辑存储类描述信息
- patch
- normal
- r.json()['metadata']['annotations']['kubesphere.io/description']
- test-description

- - 3
- /apis/clusters/${cluster_name}/storage.k8s.io/v1/storageclasses
- ''
- '{"apiVersion":"storage.k8s.io/v1","kind":"StorageClass","metadata":{"name":"S@","annotations":{"kubesphere.io/provisioner":"disk.csi.qingcloud.com","storageclass.kubesphere.io/supported-access-modes":"[\"ReadWriteOnce\"]","kubesphere.io/creator":"admin"}},"parameters":{"fstype":"ext4"},"reclaimPolicy":"Delete","allowVolumeExpansion":True,"volumeBindingMode":"WaitForFirstConsumer","provisioner":"disk.csi.qingcloud.com"}'
- multi-cluster-storage
- 存储类
- 使用不符合规则的名称创建存储类
- post
- normal
Expand All @@ -31,51 +33,56 @@
a lowercase RFC 1123 subdomain must consist of lower case alphanumeric characters,
''-'' or ''.'', and must start and end with an alphanumeric character (e.g. ''example.com'',
regex used for validation is ''[a-z0-9]([-a-z0-9]*[a-z0-9])?(\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*'')'

- - 4
- /apis/clusters/${cluster_name}/storage.k8s.io/v1/storageclasses
- ''
- '{"apiVersion":"storage.k8s.io/v1","kind":"StorageClass","metadata":{"name":"${sc_name}","annotations":{"kubesphere.io/provisioner":"disk.csi.qingcloud.com","storageclass.kubesphere.io/supported-access-modes":"[\"ReadWriteOnce\"]","kubesphere.io/creator":"admin"}},"parameters":{"fstype":"ext4"},"reclaimPolicy":"Delete","allowVolumeExpansion":True,"volumeBindingMode":"WaitForFirstConsumer","provisioner":"disk.csi.qingcloud.com"}'
- multi-cluster-storage
- 存储类
- 创建同名的存储类
- post
- normal
- r.json()['message']
- storageclasses.storage.k8s.io "${sc_name}" already exists

- - 5
- /kapis/clusters/${cluster_name}/resources.kubesphere.io/v1alpha3/storageclasses
- name=local&sortBy=createTime&limit=10
- ''
- multi-cluster-storage
- 存储类
- 精确查询存在的存储类
- get
- normal
- r.json()['items'][0]['metadata']['name']
- local

- - 6
- /kapis/clusters/${cluster_name}/resources.kubesphere.io/v1alpha3/storageclasses
- name=ca&sortBy=createTime&limit=10
- ''
- multi-cluster-storage
- 存储类
- 模糊查询存在的存储类
- get
- normal
- r.json()['items'][0]['metadata']['name']
- local

- - 7
- /kapis/clusters/${cluster_name}/resources.kubesphere.io/v1alpha3/storageclasses
- name=kk&sortBy=createTime&limit=10
- ''
- multi-cluster-storage
- 存储类
- 查询不存在的存储类
- get
- normal
- r.json()['totalItems']
- 0

- - 8
- /kapis/clusters/${cluster_name}/resources.kubesphere.io/v1alpha3/volumesnapshotclasses
- name=${sc_name}&sortBy=createTime&limit=10
- ''
- multi-cluster-storage
- 卷快照类
- 精确查询存在的卷快照类
- get
- normal
Expand All @@ -85,37 +92,40 @@
- /kapis/clusters/${cluster_name}/resources.kubesphere.io/v1alpha3/volumesnapshotclasses
- name=cluster-sc&sortBy=createTime&limit=10
- ''
- multi-cluster-storage
- 卷快照类
- 模糊查询存在的卷快照类
- get
- normal
- r.json()['items'][0]['metadata']['name']
- ${sc_name}

- - 10
- /kapis/clusters/${cluster_name}/resources.kubesphere.io/v1alpha3/volumesnapshotclasses
- name=kk&sortBy=createTime&limit=10
- ''
- multi-cluster-storage
- 卷快照类
- 查询不存在的卷快照类
- get
- normal
- r.json()['totalItems']
- 0

- - 11
- /apis/clusters/${cluster_name}/snapshot.storage.k8s.io/v1beta1/volumesnapshotclasses
- ''
- '{"apiVersion":"snapshot.storage.k8s.io/v1beta1","kind":"VolumeSnapshotClass","deletionPolicy":"Retain","driver":"disk.csi.qingcloud.com","metadata":{"name":"${sc_name}","annotations":{"kubesphere.io/creator":"admin"}}}'
- multi-cluster-storage
- 卷快照类
- 创建同名的卷快照类
- post
- normal
- r.json()['message']
- volumesnapshotclasses.snapshot.storage.k8s.io "${sc_name}" already exists

- - 12
- /apis/clusters/${cluster_name}/snapshot.storage.k8s.io/v1beta1/volumesnapshotclasses
- ''
- '{"apiVersion":"snapshot.storage.k8s.io/v1beta1","kind":"VolumeSnapshotClass","deletionPolicy":"Retain","driver":"disk.csi.qingcloud.com","metadata":{"name":"Vsc&","annotations":{"kubesphere.io/creator":"admin"}}}'
- multi-cluster-storage
- 卷快照类
- 使用不符合规则的名称创建卷快照类
- post
- normal
Expand Down
24 changes: 24 additions & 0 deletions step/multi_cluster_steps.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,30 @@ def step_get_nodes(cluster_name):
return response


@allure.step('获取指定集群的边缘节点列表信息')
def step_get_edge_nodes(cluster_name):
url = env_url + '/kapis/clusters/' + cluster_name + '/resources.kubesphere.io/v1alpha3/nodes?sortBy=createTime' \
'&limit=10&labelSelector=node-role.kubernetes.io%2Fedge%3D'
response = requests.get(url=url, headers=get_header())
return response


@allure.step('添加边缘节点-检验内部IP地址')
def step_check_internal_ip(cluster_name, node_name, internal_ip):
url = env_url + '/kapis/clusters/' + cluster_name + '/edgeruntime.kubesphere.io/v1alpha1/nodes/join?node_name=' \
+ node_name + '&node_ip=' + internal_ip
response = requests.get(url=url, headers=get_header())
return response


@allure.step('添加边缘节点-获取边缘节点配置命令')
def step_get_edge_node_config_command(cluster_name, node_name, internal_ip, add_default_taint):
url = env_url + '/kapis/clusters/' + cluster_name + '/edgeruntime.kubesphere.io/v1alpha1/nodes/join?node_name=' \
+ node_name + '&node_ip=' + internal_ip + '&add_default_taint=' + add_default_taint
response = requests.get(url=url, headers=get_header())
return response


@allure.step('为节点设置污点')
def step_ste_taints(cluster_name, node_name, taints):
url = env_url + '/api/clusters/' + cluster_name + '/v1/nodes/' + node_name
Expand Down

0 comments on commit 8b06e5a

Please sign in to comment.