diff --git a/inttests/replication_test.go b/inttests/replication_test.go index 5be1a68..51dcdb3 100644 --- a/inttests/replication_test.go +++ b/inttests/replication_test.go @@ -499,6 +499,67 @@ func TestExecuteResumeOnReplicationGroup(t *testing.T) { assert.Nil(t, err) } +// Test TestSetRPOOnReplicationGroup +func TestSetRPOOnReplicationGroup(t *testing.T) { + // Set the RCG context + TestGetReplicationConsistencyGroups(t) + // Update the RPO + err := rep.rcg.SetRPOOnReplicationGroup(siotypes.SetRPOReplicationConsistencyGroup{RpoInSeconds: "60"}) + assert.Nil(t, err) +} + +// Test TestSetTargetVolumeAccessModeOnReplicationGroup +func TestSetTargetVolumeAccessModeOnReplicationGroup(t *testing.T) { + // Set the RCG context + TestGetReplicationConsistencyGroups(t) + err := rep.rcg.SetTargetVolumeAccessModeOnReplicationGroup(siotypes.SetTargetVolumeAccessModeOnReplicationGroup{TargetVolumeAccessMode: "ReadOnly"}) + assert.Nil(t, err) +} + +// Test TestSetNewNameOnReplicationGroup +func TestSetNewNameOnReplicationGroup(t *testing.T) { + // Set the RCG context + TestGetReplicationConsistencyGroups(t) + err := rep.rcg.SetNewNameOnReplicationGroup(siotypes.SetNewNameOnReplicationGroup{NewName: "UpdatedNameRCG"}) + assert.Nil(t, err) + // Sleep for 10 to make sure the name is updated, then update it back to the original name + time.Sleep(10 * time.Second) + err = rep.rcg.SetNewNameOnReplicationGroup(siotypes.SetNewNameOnReplicationGroup{NewName: "inttestrcg"}) + assert.Nil(t, err) +} + +// Test TestExecuteInconsistentOnReplicationGroup +func TestExecuteInconsistentOnReplicationGroup(t *testing.T) { + // Set the RCG context + TestGetReplicationConsistencyGroups(t) + err := rep.rcg.ExecuteInconsistentOnReplicationGroup() + assert.Nil(t, err) +} + +// Test TestExecuteConsistentOnReplicationGroup +func TestExecuteConsistentOnReplicationGroup(t *testing.T) { + // Set the RCG context + TestGetReplicationConsistencyGroups(t) + err := rep.rcg.ExecuteConsistentOnReplicationGroup() + assert.Nil(t, err) +} + +// Test TestExecuteTerminateOnReplicationGroup +func TestExecuteTerminateOnReplicationGroup(t *testing.T) { + // Set the RCG context + TestGetReplicationConsistencyGroups(t) + err := rep.rcg.ExecuteTerminateOnReplicationGroup() + assert.Nil(t, err) +} + +// Test TestExecuteActivateOnReplicationGroup +func TestExecuteActivateOnReplicationGroup(t *testing.T) { + // Set the RCG context + TestGetReplicationConsistencyGroups(t) + err := rep.rcg.ExecuteActivateOnReplicationGroup() + assert.Nil(t, err) +} + // Test ResizeReplicationPair func TestResizeReplicationPair(t *testing.T) { if C2 == nil { @@ -605,7 +666,7 @@ func TestRemoveReplicationConsistencyGroup(t *testing.T) { if C2 == nil { t.Skip("no client connection to replication target system") } - + TestGetReplicationConsistencyGroups(t) assert.NotNil(t, rep.rcg) err := rep.rcg.RemoveReplicationConsistencyGroup(false) diff --git a/replication.go b/replication.go index 968caf3..1c56d7d 100644 --- a/replication.go +++ b/replication.go @@ -369,6 +369,80 @@ func (rcg *ReplicationConsistencyGroup) ExecuteSyncOnReplicationGroup() (*types. return resp, err } +// SetRPOOnReplicationGroup on the ConsistencyGroup. +func (rcg *ReplicationConsistencyGroup) SetRPOOnReplicationGroup(param types.SetRPOReplicationConsistencyGroup) error { + defer TimeSpent("SetRPOOnReplicationGroup", time.Now()) + + uri := "/api/instances/ReplicationConsistencyGroup::" + rcg.ReplicationConsistencyGroup.ID + "/action/ModifyReplicationConsistencyGroupRpo" + + err := rcg.client.getJSONWithRetry(http.MethodPost, uri, param, nil) + return err +} + +// SetTargetVolumeAccessModeOnReplicationGroup on the ConsistencyGroup. +func (rcg *ReplicationConsistencyGroup) SetTargetVolumeAccessModeOnReplicationGroup(param types.SetTargetVolumeAccessModeOnReplicationGroup) error { + defer TimeSpent("SetTargetVolumeAccessModeOnReplicationGroup", time.Now()) + + uri := "/api/instances/ReplicationConsistencyGroup::" + rcg.ReplicationConsistencyGroup.ID + "/action/modifyReplicationConsistencyGroupTargetVolumeAccessMode" + + err := rcg.client.getJSONWithRetry(http.MethodPost, uri, param, nil) + return err +} + +// SetNewNameOnReplicationGroup on the ConsistencyGroup. +func (rcg *ReplicationConsistencyGroup) SetNewNameOnReplicationGroup(param types.SetNewNameOnReplicationGroup) error { + defer TimeSpent("SetNewNameOnReplicationGroup", time.Now()) + + uri := "/api/instances/ReplicationConsistencyGroup::" + rcg.ReplicationConsistencyGroup.ID + "/action/renameReplicationConsistencyGroup" + + err := rcg.client.getJSONWithRetry(http.MethodPost, uri, param, nil) + return err +} + +// ExecuteConsistentOnReplicationGroup on the ConsistencyGroup. +func (rcg *ReplicationConsistencyGroup) ExecuteConsistentOnReplicationGroup() error { + defer TimeSpent("ExecuteConsistentOnReplicationGroup", time.Now()) + + uri := "/api/instances/ReplicationConsistencyGroup::" + rcg.ReplicationConsistencyGroup.ID + "/action/setReplicationConsistencyGroupConsistent" + param := types.EmptyPayload{} + + err := rcg.client.getJSONWithRetry(http.MethodPost, uri, param, nil) + return err +} + +// ExecuteInconsistentOnReplicationGroup on the ConsistencyGroup. +func (rcg *ReplicationConsistencyGroup) ExecuteInconsistentOnReplicationGroup() error { + defer TimeSpent("ExecuteInconsistentOnReplicationGroup", time.Now()) + + uri := "/api/instances/ReplicationConsistencyGroup::" + rcg.ReplicationConsistencyGroup.ID + "/action/setReplicationConsistencyGroupInconsistent" + param := types.EmptyPayload{} + + err := rcg.client.getJSONWithRetry(http.MethodPost, uri, param, nil) + return err +} + +// ExecuteActivateOnReplicationGroup on the ConsistencyGroup. +func (rcg *ReplicationConsistencyGroup) ExecuteActivateOnReplicationGroup() error { + defer TimeSpent("ExecuteActivateOnReplicationGroup", time.Now()) + + uri := "/api/instances/ReplicationConsistencyGroup::" + rcg.ReplicationConsistencyGroup.ID + "/action/activateReplicationConsistencyGroup" + param := types.EmptyPayload{} + + err := rcg.client.getJSONWithRetry(http.MethodPost, uri, param, nil) + return err +} + +// ExecuteTerminateOnReplicationGroup on the ConsistencyGroup. +func (rcg *ReplicationConsistencyGroup) ExecuteTerminateOnReplicationGroup() error { + defer TimeSpent("ExecuteTerminateOnReplicationGroup", time.Now()) + + uri := "/api/instances/ReplicationConsistencyGroup::" + rcg.ReplicationConsistencyGroup.ID + "/action/terminateReplicationConsistencyGroup" + param := types.EmptyPayload{} + + err := rcg.client.getJSONWithRetry(http.MethodPost, uri, param, nil) + return err +} + // GetSyncStateOnReplicationGroup returns the sync status of the ReplicaitonConsistencyGroup. func (rcg *ReplicationConsistencyGroup) GetSyncStateOnReplicationGroup(syncKey string) error { defer TimeSpent("ExecuteSyncOnReplicationGroup", time.Now()) diff --git a/types/v1/replication.go b/types/v1/replication.go index 883782b..8a11f40 100644 --- a/types/v1/replication.go +++ b/types/v1/replication.go @@ -1,3 +1,21 @@ +/* + * + * Copyright © 2020-2024 Dell Inc. or its subsidiaries. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + package goscaleio // PauseMode states in which the ConsistencyGroup can be set to when Paused. @@ -14,6 +32,21 @@ type PauseReplicationConsistencyGroup struct { PauseMode string `json:"pauseMode"` } +// SetRPOReplicationConsistencyGroup defines struct for SetRPOReplicationConsistencyGroup. +type SetRPOReplicationConsistencyGroup struct { + RpoInSeconds string `json:"rpoInSeconds"` +} + +// SetTargetVolumeAccessModeOnReplicationGroup defines struct for SetTargetVolumeAccessModeOnReplicationGroup. +type SetTargetVolumeAccessModeOnReplicationGroup struct { + TargetVolumeAccessMode string `json:"targetVolumeAccessMode"` +} + +// SetNewNameOnReplicationGroup defines struct for SetNewNameOnReplicationGroup. +type SetNewNameOnReplicationGroup struct { + NewName string `json:"newName"` +} + // SynchronizationResponse defines struct for SynchronizationResponse. type SynchronizationResponse struct { SyncNowKey string `json:"syncNowKey"`