10 KiB
English | [简体中文]](/docs/zh/test/3-4-E2E-resource-operation.md)
In the E2E process, when creating a resource, it is often necessary to create the associated resource first, and after deleting the resource, the related resource also needs to be deleted. Therefore, the operation of the related resource is encapsulated based on the principle of complete creation/deletion.
-
createInstance
-
Create instance and wait for the instance to become
running
-
Parameter
name
, the name of the instance -
Parameter
networkName
, the network name selected when the instance was created -
Take the floating IP associated instance
test/e2e/integration/pages/network/floatingip.spec.js
as an example- In order to successfully associate with the instance, the router connected to the subnet where the instance's interfae is located must have a public network gateway turned on
- Create a network
networkName
with subnet - Create a router
routerName
with the public network gateway turned on and connected to the networknetworkName
subnet - Create a instance
instanceName
with a interfae on the networknetworkName
- Create a network
it('successfully prepair resource', () => { cy.createNetwork({ name: networkName }); cy.createRouter({ name: routerName, network: networkName }); cy.createInstance({ name: instanceName, networkName }); });
- In order to successfully associate with the instance, the router connected to the subnet where the instance's interfae is located must have a public network gateway turned on
-
-
createNetwork
-
Create a network with a subnet
-
Parameter
name
, the name of the network -
Parameter
networkName
, the network name selected when the instance was created -
Take the router connected to the subnet as an example
test/e2e/integration/pages/network/router.spec.js
as an example- Created a network named
networkName
in preparation for connecting to subnets
it('successfully prepair resource', () => { cy.createNetwork({ name: networkName }); });
- Created a network named
-
-
createNetworkPolicy
-
Create network QoS policy
-
Parameter
name
, the name of the strategy -
Take virtual adapter modification QoS as an example
test/e2e/integration/pages/network/virtual-adapter.spec.js
as an example- Created a policy named
policyName
in preparation for modifying QoS
it('successfully prepair resource by admin', () => { cy.loginAdmin().wait(5000).createNetworkPolicy({ name: policyName }); });
- Created a policy named
-
-
createRouter
-
Create a router with a public network gateway turned on
-
Parameter
name
, the name of the router -
Parameter
network
- If set, the router will connect to the subnet of the
network
network
- If set, the router will connect to the subnet of the
-
Take the floating IP associated instance
test/e2e/integration/pages/network/floatingip.spec.js
as an example- In order to successfully associate with the instance, the router connected to the subnet where the instance's interfae is located must have a public network gateway turned on
- Create a network
networkName
with subnets - Create a router
routerName
with the public network gateway turned on and connected to the networknetworkName
subnet - Create a instance
instanceName
with a interfae on the networknetworkName
- Create a network
it('successfully prepair resource', () => { cy.createNetwork({ name: networkName }); cy.createRouter({ name: routerName, network: networkName }); cy.createInstance({ name: instanceName, networkName }); });
- In order to successfully associate with the instance, the router connected to the subnet where the instance's interfae is located must have a public network gateway turned on
-
-
deleteRouter
-
Deleting the router will disconnect the router's subnet, turn off the router's public network gateway, and finally successfully delete the router
-
Parameter
network
- If set, you need to disconnect the router's subnet first
-
Parameter
name
, the name of the router -
Take the floating IP to delete the associated resource
test/e2e/integration/pages/network/floatingip.spec.js
as an example- In order to successfully associate with the instance, the router connected to the subnet where the instance's interfae is located must have a public network gateway turned on
it('successfully delete related resources', () => { cy.forceDeleteInstance(instanceName); cy.deleteRouter(routerName, networkName); cy.deleteAll('network', networkName); cy.loginAdmin().wait(5000); cy.deleteAll('networkQosPolicy', policyName); });
-
-
forceDeleteInstance
-
Force delete instance instead of soft delete
-
Parameter
name
, the name of the instance -
Take deleting the instance group
test/e2e/integration/pages/compute/server-group.spec.js
as an example- Delete the instance under the instance group first
- Then successfully delete the instance group
it('successfully delete', () => { cy.clickFirstActionDisabled(); cy.forceDeleteInstance(instanceName); cy.wait(5000); cy.visitPage(listUrl) .tableSearchText(name) .clickConfirmActionInFirst() .checkEmptyTable(); });
-
-
createVolume
-
Create volume
-
Parameter
name
, the name of the volume -
Take volume backup
test/e2e/integration/pages/storage/backup.spec.js
as an example- To create a volume backup, you need to prepare the volume first
it('successfully prepair resource', () => { cy.createVolume(volumeName); cy.createNetwork({ name: networkName }); cy.createInstance({ name: instanceName, networkName }); });
-
-
createSecurityGrouop
-
Create a security group
-
Parameter
name
, the name of the security group -
Take the virtual adapter card
test/e2e/integration/pages/network/virtual-adapter.spec.js
as an example -To test management security group, you need to prepare the security group firstit('successfully prepair resource', () => { cy.createFip(); cy.createSecurityGrouop({ name: securityGroupName }); cy.createNetwork({ name: networkName }); cy.createRouter({ name: routerName, network: networkName }); cy.createInstance({ name: instanceName, networkName }); });
-
-
createFip
-
Create floating ip
-
Take instance
test/e2e/integration/pages/compute/instance.spec.js
as an example- Test associate floating IP, you need to prepare reachable floating IP
it('successfully prepair resource', () => { cy.createNetwork({ name: networkName }); cy.createRouter({ name: routerName, network: networkName }); cy.createFip(); cy.createVolume(volumeName); });
-
-
createUserGroup
-
Create user group
-
Parameter
name
, the name of user group -
Take project
test/e2e/integration/pages/identity/project.spec.js
as an example- To test management user group, you need to prepare the user group
it('successfully prepair resource', () => { cy.createUser({ name: username }); cy.createUserGroup({ name: userGroupName }); });
-
-
createUser
-
Create user
-
Parameter
name
, user name -
Take project
test/e2e/integration/pages/identity/project.spec.js
as an example- To test management user, you need to prepare user
it('successfully prepair resource', () => { cy.createUser({ name: username }); cy.createUserGroup({ name: userGroupName }); });
-
-
createProject
-
Create project
-
Parameter
name
, the name of project -
Take user
test/e2e/integration/pages/identity/user.spec.js
as an example- To test creater user, need to prepare project
- To test management project permission, need to prepare project
it('successfully prepair resource', () => { cy.createProject({ name: projectName }); cy.createProject({ name: projectName2 }); cy.createUserGroup({ name: userGroupName }); });
-
-
createIronicImage
-
Create image for ironic
-
Parameter
name
, the name of the image -
Take ironic
test/e2e/integration/pages/compute/ironic.spec.js
as an example- Create a ironic, image need to be able to create a ironic
it('successfully prepair resource', () => { cy.createNetwork({ name: networkName }); cy.createRouter({ name: routerName, network: networkName }); cy.createFip(); cy.createIronicImage({ name: imageName }); });
-
-
deleteInstance
-
Delete instance
-
Parameter
name
, name of instance -
Parameter
deleteRecycleBin
, Defaulttrue
, Indicates that you need to enter the recycle bin to delete again -
Take delete instance
test/e2e/integration/pages/compute/instance.spec.js
as an exampleit('successfully delete', () => { cy.deleteInstance(newname); });
-
-
deleteAllAvailableVolume
-Delete all availablevolume -Take instancetest/e2e/integration/pages/compute/instance.spec.js
as an exampleit('successfully delete related resources', () => { cy.deleteAll('fip'); cy.deleteRouter(routerName, networkName); cy.deleteAll('network', networkName); cy.deleteAll('volume', volumeName); cy.deleteAllAvailableVolume(); });
-
deleteAll
-
Delete qualified resources
-
Parameter
resourceName
, resource nameexport default { // compute instance: instanceListUrl, image: imageListUrl, // storage volume: volumeListUrl, volumeSnapshot: volumeSnapshotListUrl, backup: backupListUrl, volumeType: volumeTypeListUrl, // network network: networkListUrl, router: routerListUrl, networkQosPolicy: policyListUrl, fip: fipListUrl, virtualAdapter: virtualAdapterListUrl, // security securityGroup: securityGroupListUrl, // identity project: projectListUrl, user: userListUrl, userGroup: userGroupListUrl, };
-
Parameter
name
- If set, delete the resource with the specified name
- If not set, all resources under the resource list will be deleted
-
Parameter
tab
-
If set, it means that the resource is located under the tab
tab
, you need to switch to the specified tab first -
Take the volume type
test/e2e/integration/pages/storage/volume-type.spec.js
as an example -
Delete the QoS prepared when managing QoS
it('successfully delete related resources', () => { cy.deleteAll('volumeType', qosName, 'QoS'); });
-