Skip to content

Commit

Permalink
Get Specific Replication Pair (#133)
Browse files Browse the repository at this point in the history
  • Loading branch information
doriac11 authored Oct 9, 2024
1 parent f5a89ca commit bc4527e
Show file tree
Hide file tree
Showing 2 changed files with 79 additions and 2 deletions.
31 changes: 29 additions & 2 deletions inttests/replication_test.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
*
* Copyright © 2020 Dell Inc. or its subsidiaries. All Rights Reserved.
* 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.
Expand All @@ -15,7 +15,6 @@
* limitations under the License.
*
*/

package inttests

import (
Expand Down Expand Up @@ -327,6 +326,34 @@ func TestQueryReplicationPairs(t *testing.T) {
}
}

// Query Specific Replication Pair
func TestQueryReplicationPair(t *testing.T) {
if C2 == nil {
t.Skip("no client connection to replication target system")
}

pair, err := C.GetReplicationPair(rep.pair.ReplicaitonPair.ID)
assert.Nil(t, err)
assert.NotNil(t, pair)
}

// Pause and Resume Replication Pair
func TestPauseAndResumeReplicationPair(t *testing.T) {
if C2 == nil {
t.Skip("no client connection to replication target system")
}

// Pause
pairP, err := C.PausePairInitialCopy(rep.pair.ReplicaitonPair.ID)
assert.Nil(t, err)
assert.NotNil(t, pairP)

// Resume
pairR, err := C.ResumePairInitialCopy(rep.pair.ReplicaitonPair.ID)
assert.Nil(t, err)
assert.NotNil(t, pairR)
}

// Query Replication Pair Statistics
func TestQueryReplicationPairsStatistics(t *testing.T) {
if C2 == nil {
Expand Down
50 changes: 50 additions & 0 deletions replication.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,20 @@
/*
* 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

import (
Expand Down Expand Up @@ -212,6 +229,39 @@ func (c *Client) GetAllReplicationPairs() ([]*types.ReplicationPair, error) {
return pairs, err
}

// GetReplicationPair returns a specific replication pair on the system.
func (c *Client) GetReplicationPair(id string) (*types.ReplicationPair, error) {
defer TimeSpent("GetReplicationPair", time.Now())

path := "/api/instances/ReplicationPair::" + id

var pair *types.ReplicationPair
err := c.getJSONWithRetry(http.MethodGet, path, nil, &pair)
return pair, err
}

// PausePairInitialCopy pauses the initial copy of the replication pair.
func (c *Client) PausePairInitialCopy(id string) (*types.ReplicationPair, error) {
defer TimeSpent("PausePairInitialCopy", time.Now())

path := "/api/instances/ReplicationPair::" + id + "/action/pausePairInitialCopy"

var pair *types.ReplicationPair
err := c.getJSONWithRetry(http.MethodPost, path, types.EmptyPayload{}, &pair)
return pair, err
}

// ResumePairInitialCopy resumes the initial copy of the replication pair.
func (c *Client) ResumePairInitialCopy(id string) (*types.ReplicationPair, error) {
defer TimeSpent("ResumePairInitialCopy", time.Now())

path := "/api/instances/ReplicationPair::" + id + "/action/resumePairInitialCopy"

var pair *types.ReplicationPair
err := c.getJSONWithRetry(http.MethodPost, path, types.EmptyPayload{}, &pair)
return pair, err
}

// GetReplicationPairs returns a list of replication pairs associated to the rcg.
func (rcg *ReplicationConsistencyGroup) GetReplicationPairs() ([]*types.ReplicationPair, error) {
defer TimeSpent("GetReplicationPairs", time.Now())
Expand Down

0 comments on commit bc4527e

Please sign in to comment.