Skip to content

Commit

Permalink
Support delete compute
Browse files Browse the repository at this point in the history
Added UT for provisioing action compute node delete.

Change-Id: I39da78d85b152cbbdd58c637057f8dae651e6d0e
Partial-Bug: 1788447
  • Loading branch information
cijohnson committed Nov 2, 2018
1 parent 0d3193b commit 5af9fa1
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 6 deletions.
26 changes: 20 additions & 6 deletions pkg/cluster/ansible.go
Expand Up @@ -21,11 +21,12 @@ const (
updateAction = "update"
deleteAction = "delete"

provisionProvisioningAction = "PROVISION"
upgradeProvisioningAction = "UPGRADE"
importProvisioningAction = "IMPORT"
addComputeProvisioningAction = "ADD_COMPUTE"
addCSNProvisioningAction = "ADD_CSN"
provisionProvisioningAction = "PROVISION"
upgradeProvisioningAction = "UPGRADE"
importProvisioningAction = "IMPORT"
addComputeProvisioningAction = "ADD_COMPUTE"
deleteComputeProvisioningAction = "DELETE_COMPUTE"
addCSNProvisioningAction = "ADD_CSN"

enable = "yes"
disable = "no"
Expand Down Expand Up @@ -412,7 +413,7 @@ func (a *ansibleProvisioner) playOrchestratorProvision(ansibleArgs []string) err
case orchestratorOpenstack:
ansibleArgs = append(ansibleArgs, "-e force_checkout=yes")
switch a.clusterData.clusterInfo.ProvisioningAction {
case addComputeProvisioningAction:
case addComputeProvisioningAction, deleteComputeProvisioningAction:
ansibleArgs = append(ansibleArgs, "--tags=nova")
}
ansibleArgs = append(ansibleArgs, defaultOpenstackProvPlay)
Expand Down Expand Up @@ -532,6 +533,19 @@ func (a *ansibleProvisioner) playBook() error {
if err := a.playAppformixProvision(); err != nil {
return err
}
case deleteComputeProvisioningAction:
if err := a.playInstancesConfig(args); err != nil {
return err
}
if err := a.playOrchestratorProvision(args); err != nil {
return err
}
if err := a.playContrailProvision(args); err != nil {
return err
}
if err := a.playAppformixProvision(); err != nil {
return err
}
case addCSNProvisioningAction:
if err := a.playInstancesConfig(args); err != nil {
return err
Expand Down
12 changes: 12 additions & 0 deletions pkg/cluster/cluster_test.go
Expand Up @@ -21,6 +21,7 @@ const (
updatePlaybooks = "./test_data/expected_ansible_update_playbook.yml"
upgradePlaybooks = "./test_data/expected_ansible_upgrade_playbook.yml"
addComputePlaybooks = "./test_data/expected_ansible_add_compute_playbook.yml"
deleteComputePlaybooks = "./test_data/expected_ansible_delete_compute_playbook.yml"
addCSNPlaybooks = "./test_data/expected_ansible_add_csn_playbook.yml"
createEncryptPlaybooks = "./test_data/expected_ansible_create_encrypt_playbook.yml"
updateEncryptPlaybooks = "./test_data/expected_ansible_update_encrypt_playbook.yml"
Expand Down Expand Up @@ -136,6 +137,12 @@ func runClusterActionTest(t *testing.T, testScenario integration.TestScenario,
if expectedInventory != "" {
expectedPlaybooks = addComputeEncryptPlaybooks
}
case deleteComputeProvisioningAction:
// remove instances.yml to mock trriger cluster update
err = os.Remove(generatedInstancesPath())
if err != nil {
assert.NoError(t, err, "failed to delete instances.yml")
}
case addCSNProvisioningAction:
// remove instances.yml to mock trriger cluster update
err = os.Remove(generatedInstancesPath())
Expand Down Expand Up @@ -290,6 +297,11 @@ func runClusterTest(t *testing.T, expectedInstance, expectedInventory string,
addComputeProvisioningAction, expectedInstance, expectedInventory,
addComputePlaybooks, expectedEndpoints)

// DELETE_COMPUTE test
runClusterActionTest(t, testScenario, config,
deleteComputeProvisioningAction, expectedInstance, "",
deleteComputePlaybooks, expectedEndpoints)

// ADD_CSN test
runClusterActionTest(t, testScenario, config,
addCSNProvisioningAction, expectedInstance, expectedInventory,
Expand Down
@@ -0,0 +1,6 @@
playbooks/configure_instances.yml:
args: -i inventory/ -e config_file=/var/tmp/contrail_cluster/test_cluster_uuid/instances.yml -e orchestrator=openstack
playbooks/install_openstack.yml:
args: -i inventory/ -e config_file=/var/tmp/contrail_cluster/test_cluster_uuid/instances.yml -e orchestrator=openstack -e force_checkout=yes --tags=nova
playbooks/install_contrail.yml:
args: -i inventory/ -e config_file=/var/tmp/contrail_cluster/test_cluster_uuid/instances.yml -e orchestrator=openstack
1 change: 1 addition & 0 deletions schemas/abstract/has_status.yml
Expand Up @@ -88,6 +88,7 @@ schema:
enum:
- "PROVISION"
- "ADD_COMPUTE"
- "DELETE_COMPUTE"
- "ADD_CSN"
- "UPGRADE"
permission:
Expand Down

0 comments on commit 5af9fa1

Please sign in to comment.