-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
KCP CLI - List Deprovisioned Instances (#920)
* Add storage layer * List instances archived by filter * Remove instances from the operations table
- Loading branch information
1 parent
6513d02
commit 02452dd
Showing
8 changed files
with
481 additions
and
90 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -165,9 +165,9 @@ func TestRuntimesEndpointForDeprovisionedInstance(t *testing.T) { | |
cfg.EDP.Disabled = true | ||
suite := NewBrokerSuiteTestWithConfig(t, cfg) | ||
defer suite.TearDown() | ||
iid := uuid.New().String() | ||
iid1 := uuid.New().String() | ||
|
||
resp := suite.CallAPI("PUT", fmt.Sprintf("oauth/cf-eu10/v2/service_instances/%s?accepts_incomplete=true&plan_id=7d55d31d-35ae-4438-bf13-6ffdfa107d9f&service_id=47c9dcbf-ff30-448e-ab36-d3bad66ba281", iid), | ||
resp := suite.CallAPI("PUT", fmt.Sprintf("oauth/cf-eu10/v2/service_instances/%s?accepts_incomplete=true&plan_id=7d55d31d-35ae-4438-bf13-6ffdfa107d9f&service_id=47c9dcbf-ff30-448e-ab36-d3bad66ba281", iid1), | ||
`{ | ||
"service_id": "47c9dcbf-ff30-448e-ab36-d3bad66ba281", | ||
"plan_id": "7d55d31d-35ae-4438-bf13-6ffdfa107d9f", | ||
|
@@ -190,14 +190,47 @@ func TestRuntimesEndpointForDeprovisionedInstance(t *testing.T) { | |
suite.processProvisioningByOperationID(opID) | ||
|
||
// deprovision | ||
resp = suite.CallAPI("DELETE", fmt.Sprintf("oauth/cf-eu10/v2/service_instances/%s?accepts_incomplete=true&plan_id=7d55d31d-35ae-4438-bf13-6ffdfa107d9f&service_id=47c9dcbf-ff30-448e-ab36-d3bad66ba281", iid), | ||
resp = suite.CallAPI("DELETE", fmt.Sprintf("oauth/cf-eu10/v2/service_instances/%s?accepts_incomplete=true&plan_id=7d55d31d-35ae-4438-bf13-6ffdfa107d9f&service_id=47c9dcbf-ff30-448e-ab36-d3bad66ba281", iid1), | ||
``) | ||
depOpID := suite.DecodeOperationID(resp) | ||
|
||
suite.FinishDeprovisioningOperationByProvisioner(depOpID) | ||
suite.WaitForOperationsNotExists(iid) // deprovisioning completed, no operations in the DB | ||
suite.WaitForOperationsNotExists(iid1) // deprovisioning completed, no operations in the DB | ||
|
||
iid2 := uuid.New().String() | ||
resp = suite.CallAPI("PUT", fmt.Sprintf("oauth/cf-eu10/v2/service_instances/%s?accepts_incomplete=true&plan_id=b1a5764e-2ea1-4f95-94c0-2b4538b37b55&service_id=47c9dcbf-ff30-448e-ab36-d3bad66ba281", iid2), | ||
`{ | ||
"service_id": "47c9dcbf-ff30-448e-ab36-d3bad66ba281", | ||
"plan_id": "b1a5764e-2ea1-4f95-94c0-2b4538b37b55", | ||
"context": { | ||
"sm_operator_credentials": { | ||
"clientid": "cid", | ||
"clientsecret": "cs", | ||
"url": "url", | ||
"sm_url": "sm_url" | ||
}, | ||
"globalaccount_id": "g-account-id", | ||
"subaccount_id": "sub-id", | ||
"user_id": "[email protected]" | ||
}, | ||
"parameters": { | ||
"name": "testing-cluster", | ||
"region": "eu-central-1" | ||
} | ||
}`) | ||
opID = suite.DecodeOperationID(resp) | ||
suite.processProvisioningByOperationID(opID) | ||
|
||
// deprovision | ||
resp = suite.CallAPI("DELETE", fmt.Sprintf("oauth/cf-eu10/v2/service_instances/%s?accepts_incomplete=true&plan_id=b1a5764e-2ea1-4f95-94c0-2b4538b37b55&service_id=47c9dcbf-ff30-448e-ab36-d3bad66ba281", iid2), | ||
``) | ||
depOpID = suite.DecodeOperationID(resp) | ||
|
||
suite.FinishDeprovisioningOperationByProvisioner(depOpID) | ||
suite.WaitForOperationsNotExists(iid2) // deprovisioning completed, no operations in the DB | ||
|
||
// when | ||
resp = suite.CallAPI("GET", fmt.Sprintf("runtimes?instance_id=%s&state=deprovisioned", iid), "") | ||
resp = suite.CallAPI("GET", fmt.Sprintf("runtimes?instance_id=%s&state=deprovisioned", iid1), "") | ||
|
||
// then | ||
assert.Equal(t, http.StatusOK, resp.StatusCode) | ||
|
@@ -208,5 +241,45 @@ func TestRuntimesEndpointForDeprovisionedInstance(t *testing.T) { | |
require.NoError(t, err) | ||
|
||
assert.Len(t, runtimes.Data, 1) | ||
assert.Equal(t, iid, runtimes.Data[0].InstanceID) | ||
assert.Equal(t, iid1, runtimes.Data[0].InstanceID) | ||
|
||
// when | ||
resp = suite.CallAPI("GET", fmt.Sprintf("runtimes?account=%s&subaccount=%s&state=deprovisioned", "g-account-id", "sub-id"), "") | ||
|
||
// then | ||
assert.Equal(t, http.StatusOK, resp.StatusCode) | ||
response, err = io.ReadAll(resp.Body) | ||
assert.NoError(t, err) | ||
err = json.Unmarshal(response, &runtimes) | ||
require.NoError(t, err) | ||
|
||
assert.Len(t, runtimes.Data, 2) | ||
assert.Equal(t, iid1, runtimes.Data[0].InstanceID) | ||
assert.Equal(t, iid2, runtimes.Data[1].InstanceID) | ||
|
||
// when | ||
resp = suite.CallAPI("GET", fmt.Sprintf("runtimes?plan=%s&state=deprovisioned", "trial"), "") | ||
|
||
// then | ||
assert.Equal(t, http.StatusOK, resp.StatusCode) | ||
response, err = io.ReadAll(resp.Body) | ||
assert.NoError(t, err) | ||
err = json.Unmarshal(response, &runtimes) | ||
require.NoError(t, err) | ||
|
||
assert.Len(t, runtimes.Data, 1) | ||
assert.Equal(t, iid1, runtimes.Data[0].InstanceID) | ||
|
||
// when | ||
resp = suite.CallAPI("GET", fmt.Sprintf("runtimes?region=%s&state=deprovisioned", "eu-central-1"), "") | ||
|
||
// then | ||
assert.Equal(t, http.StatusOK, resp.StatusCode) | ||
response, err = io.ReadAll(resp.Body) | ||
assert.NoError(t, err) | ||
err = json.Unmarshal(response, &runtimes) | ||
require.NoError(t, err) | ||
|
||
assert.Len(t, runtimes.Data, 1) | ||
assert.Equal(t, iid2, runtimes.Data[0].InstanceID) | ||
} |
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
Oops, something went wrong.