CloudMigrations: Query Grafana Migration Status for status while the snapshot is in the cloud (#90314)
* implement querying gms for snapshot status * add some documentation * provide snapshot resources after snapshot is created * add rate limiting to backend * fix compilation error * fix typo * add unit tests * finish merge * lint * swagger gen * more testing * remove duplicate test * address a couple PR comments * update switch statement to a map * add timeouts to gms client through the http client * remove extra whitespace * put method back where it was so the PR is less confusing * fix tests * add todo * fix final unit test
This commit is contained in:
@@ -471,7 +471,7 @@ func TestCloudMigrationAPI_GetSnapshot(t *testing.T) {
|
||||
requestUrl: "/api/cloudmigration/migration/1234/snapshot/1",
|
||||
basicRole: org.RoleAdmin,
|
||||
expectedHttpResult: http.StatusOK,
|
||||
expectedBody: `{"uid":"fake_uid","status":"UNKNOWN","sessionUid":"1234","created":"0001-01-01T00:00:00Z","finished":"0001-01-01T00:00:00Z","results":[],"stats":{"types":{},"statuses":{}}}`,
|
||||
expectedBody: `{"uid":"fake_uid","status":"CREATING","sessionUid":"1234","created":"0001-01-01T00:00:00Z","finished":"0001-01-01T00:00:00Z","results":[],"stats":{"types":{},"statuses":{}}}`,
|
||||
},
|
||||
{
|
||||
desc: "should return 403 if no used is not admin",
|
||||
@@ -521,7 +521,7 @@ func TestCloudMigrationAPI_GetSnapshotList(t *testing.T) {
|
||||
requestUrl: "/api/cloudmigration/migration/1234/snapshots",
|
||||
basicRole: org.RoleAdmin,
|
||||
expectedHttpResult: http.StatusOK,
|
||||
expectedBody: `{"snapshots":[{"uid":"fake_uid","status":"UNKNOWN","sessionUid":"1234","created":"0001-01-01T00:00:00Z","finished":"0001-01-01T00:00:00Z"},{"uid":"fake_uid","status":"UNKNOWN","sessionUid":"1234","created":"0001-01-01T00:00:00Z","finished":"0001-01-01T00:00:00Z"}]}`,
|
||||
expectedBody: `{"snapshots":[{"uid":"fake_uid","status":"CREATING","sessionUid":"1234","created":"0001-01-01T00:00:00Z","finished":"0001-01-01T00:00:00Z"},{"uid":"fake_uid","status":"CREATING","sessionUid":"1234","created":"0001-01-01T00:00:00Z","finished":"0001-01-01T00:00:00Z"}]}`,
|
||||
},
|
||||
{
|
||||
desc: "should return 403 if no used is not admin",
|
||||
|
||||
@@ -224,14 +224,13 @@ const (
|
||||
SnapshotStatusPendingProcessing SnapshotStatus = "PENDING_PROCESSING"
|
||||
SnapshotStatusProcessing SnapshotStatus = "PROCESSING"
|
||||
SnapshotStatusFinished SnapshotStatus = "FINISHED"
|
||||
SnapshotStatusCanceled SnapshotStatus = "CANCELED"
|
||||
SnapshotStatusError SnapshotStatus = "ERROR"
|
||||
SnapshotStatusUnknown SnapshotStatus = "UNKNOWN"
|
||||
)
|
||||
|
||||
func fromSnapshotStatus(status cloudmigration.SnapshotStatus) SnapshotStatus {
|
||||
switch status {
|
||||
case cloudmigration.SnapshotStatusInitializing:
|
||||
return SnapshotStatusInitializing
|
||||
case cloudmigration.SnapshotStatusCreating:
|
||||
return SnapshotStatusCreating
|
||||
case cloudmigration.SnapshotStatusPendingUpload:
|
||||
@@ -244,6 +243,8 @@ func fromSnapshotStatus(status cloudmigration.SnapshotStatus) SnapshotStatus {
|
||||
return SnapshotStatusProcessing
|
||||
case cloudmigration.SnapshotStatusFinished:
|
||||
return SnapshotStatusFinished
|
||||
case cloudmigration.SnapshotStatusCanceled:
|
||||
return SnapshotStatusCanceled
|
||||
case cloudmigration.SnapshotStatusError:
|
||||
return SnapshotStatusError
|
||||
default:
|
||||
|
||||
Reference in New Issue
Block a user