Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Metro volume configure/end #131

Merged
merged 27 commits into from
Sep 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
df14afd
updating modules
lukeatdell Aug 27, 2024
844aac5
add int and unit tests for metro vol
lukeatdell Aug 28, 2024
c51be70
adding comments to tests
lukeatdell Aug 28, 2024
1383a8e
fixing volume group unit test
lukeatdell Aug 28, 2024
5723c94
refactor volume_test to use test suite
lukeatdell Aug 28, 2024
197667f
adding configure_metro action to volumes
lukeatdell Aug 28, 2024
18c49d2
defining volume endpoint actions as const
lukeatdell Aug 29, 2024
ab45eb2
adding comments to new components
lukeatdell Aug 29, 2024
264b156
correcting formatting
lukeatdell Aug 29, 2024
ca27fc2
update copyright
lukeatdell Aug 29, 2024
c82b8c5
add failnow if env is missing
lukeatdell Aug 29, 2024
6078b4e
updating env example with more info
lukeatdell Aug 29, 2024
2040b00
migrate create and delete vol to common.go
lukeatdell Aug 30, 2024
5e4c45e
adding int tests for ending metro vol
lukeatdell Aug 30, 2024
b3ffc45
adding end-metro implementation.
lukeatdell Aug 30, 2024
a2383f7
add -shuffle option to int tests to promote more meaningful testing.
lukeatdell Sep 3, 2024
0c4eeb0
update copyright
lukeatdell Sep 3, 2024
ef41976
refactor metro volume suite to find a metro volume automatically
lukeatdell Sep 4, 2024
0778366
adding end metro volume unit test
lukeatdell Sep 4, 2024
18d94a6
improve metrics test error handling
lukeatdell Sep 4, 2024
0a8ccd1
add session type to replication session struct
lukeatdell Sep 4, 2024
439775b
update copyright
lukeatdell Sep 4, 2024
54056ce
gosec errors
lukeatdell Sep 4, 2024
b340d44
update client mocks with new methods
lukeatdell Sep 5, 2024
9ad7995
update CODEOWNERS
lukeatdell Sep 5, 2024
c68bf33
PR Comments: santhoshatdell
lukeatdell Sep 5, 2024
c542ff3
update and tidy go modules
lukeatdell Sep 5, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 6 additions & 20 deletions .github/CODEOWNERS
Original file line number Diff line number Diff line change
Expand Up @@ -7,26 +7,12 @@
# be requested for review when someone opens a pull request.
# order is alphabetical for easier maintenance.
#
# Abhilash Muralidhara (abhi16394)
# Adarsh Kumar Yadav (adarsh-dell)
# Akshay Saini (AkshaySainiDell)
# Boya Murthy (boyamurthy)
# Christian Coffield (ChristianAtDell, [email protected])
# Utkarsh Dubey (delldubey)
# Francis Nijay (francis-nijay)
# Tarandeep Singh Gill (gilltaran)
# Harish P (harishp8889)
# Harshita Pandey (harshitap26)
# Vinutha Kini (kenivi1)
# Niranjan N (niranjan-n1)
# Prasanna Muthukumaraswamy (prablr79)
# Santhosh Lakshmanan (santhoshatdell, [email protected])
# Satya Narayana (satyakonduri)
# Santhosh Shekarappa (santhoshhs10)
# Yamunadevi Shanmugam (shanmydell)
# Surya Prakash Gupta (suryagupta4)
# Sushma T S (tssushma)
# Don Khan (donatwork)
# Luke Lau (lukeatdell)
# Santhosh Lakshmanan (santhoshatdell)



# for all files:
* @adarsh-dell @AkshaySainiDell @boyamurthy @ChristianAtDell @delldubey @francis-nijay @gilltaran @harishp8889 @harshitap26 @kenivi1 @niranjan-n1 @prablr79 @santhoshatdell @satyakonduri @santhoshhs10 @shanmydell @suryagupta4 @tssushma
# for all files
* @abhi16394 @adarsh-dell @AkshaySainiDell @donatwork @lukeatdell @santhoshatdell
5 changes: 3 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,9 @@ unit-test:
go test -v -coverprofile=c.out $(unit_test_paths)

int-test:
go test -timeout 600s -v -coverprofile=c.out -coverpkg github.com/dell/gopowerstore \
$(integration_tests_path)
source $(integration_tests_path)/GOPOWERSTORE_TEST.env \
&& \
go test -timeout 600s -shuffle=on -v -coverprofile=c.out -coverpkg github.com/dell/gopowerstore $(integration_tests_path)

gocover:
go tool cover -html=c.out
Expand Down
8 changes: 4 additions & 4 deletions api/api.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
*
* Copyright © 2020-2023 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 Down Expand Up @@ -122,7 +122,7 @@ type ClientIMPL struct {
username string
password string
httpClient *http.Client
defaultTimeout uint64
defaultTimeout int64
donatwork marked this conversation as resolved.
Show resolved Hide resolved
requestIDKey ContextKey
customHTTPHeaders http.Header
logger Logger
Expand All @@ -133,7 +133,7 @@ type ClientIMPL struct {

// New creates and initialize API client
func New(apiURL string, username string,
password string, insecure bool, defaultTimeout, rateLimit uint64, requestIDKey ContextKey,
password string, insecure bool, defaultTimeout int64, rateLimit int, requestIDKey ContextKey,
) (*ClientIMPL, error) {
debug, _ = strconv.ParseBool(os.Getenv("GOPOWERSTORE_DEBUG"))
if apiURL == "" || username == "" || password == "" {
Expand Down Expand Up @@ -164,7 +164,7 @@ func New(apiURL string, username string,
log.Print("Session management is enabled.")
}

throttle := NewTimeoutSemaphore(int(defaultTimeout), int(rateLimit), &defaultLogger{})
throttle := NewTimeoutSemaphore(defaultTimeout, rateLimit, &defaultLogger{})

clientImpl := &ClientIMPL{
apiURL: apiURL,
Expand Down
8 changes: 4 additions & 4 deletions api/api_test.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
*
* Copyright © 2020-2022 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 Down Expand Up @@ -71,8 +71,8 @@ func TestNew(t *testing.T) {
url := "test_url"
user := "admin"
password := "password"
timeout := uint64(120)
limit := uint64(1000)
timeout := int64(120)
limit := int(1000)
var err error
var c *ClientIMPL
c, err = New(url, user, password, false, timeout, limit, key)
Expand All @@ -86,7 +86,7 @@ func TestNew(t *testing.T) {
}

func testClient(t *testing.T, apiURL string) *ClientIMPL {
c, err := New(apiURL, "admin", "password", false, uint64(10), uint64(1000), "key")
c, err := New(apiURL, "admin", "password", false, int64(10), int(1000), "key")
if err != nil {
t.FailNow()
}
Expand Down
4 changes: 2 additions & 2 deletions api/throttling.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
*
* Copyright © 2021-2022 Dell Inc. or its subsidiaries. All Rights Reserved.
* Copyright © 2021-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 Down Expand Up @@ -42,7 +42,7 @@ type TimeoutSemaphore struct {
Logger Logger
}

func NewTimeoutSemaphore(timeout, rateLimit int, logger Logger) *TimeoutSemaphore {
func NewTimeoutSemaphore(timeout int64, rateLimit int, logger Logger) *TimeoutSemaphore {
log := logger

if log == nil {
Expand Down
4 changes: 3 additions & 1 deletion client.go
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,8 @@ type Client interface {
GetVolumeGroupSnapshots(ctx context.Context) ([]VolumeGroup, error)
GetVolumeGroupSnapshotByName(ctx context.Context, snapName string) (VolumeGroup, error)
GetMaxVolumeSize(ctx context.Context) (int64, error)
ConfigureMetroVolume(ctx context.Context, id string, config *MetroConfig) (resp MetroSessionResponse, err error)
EndMetroVolume(ctx context.Context, id string, options *EndMetroVolumeOptions) (resp EmptyResponse, err error)
}

// ClientIMPL provides basic API client implementation
Expand Down Expand Up @@ -261,7 +263,7 @@ func NewClient() (Client, error) {
if err == nil {
options.SetInsecure(insecure)
}
httpTimeout, err := strconv.ParseUint(os.Getenv(HTTPTimeoutEnv), 10, 64)
httpTimeout, err := strconv.ParseInt(os.Getenv(HTTPTimeoutEnv), 10, 64)

if err == nil {
options.SetDefaultTimeout(httpTimeout)
Expand Down
14 changes: 7 additions & 7 deletions client_options.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
*
* Copyright © 2020-2022 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 Down Expand Up @@ -38,8 +38,8 @@ func NewClientOptions() *ClientOptions {
// ClientOptions struct provide additional options for api client configuration
type ClientOptions struct {
insecure *bool // skip https cert check
defaultTimeout *uint64
rateLimit *uint64
defaultTimeout *int64
rateLimit *int
// define field name in context which will be used for tracing
requestIDKey *api.ContextKey
}
Expand All @@ -53,15 +53,15 @@ func (co *ClientOptions) Insecure() bool {
}

// DefaultTimeout returns http client default timeout
func (co *ClientOptions) DefaultTimeout() uint64 {
func (co *ClientOptions) DefaultTimeout() int64 {
if co.defaultTimeout == nil {
return clientOptionsDefaultTimeout
}
return *co.defaultTimeout
}

// RateLimit returns http client rate limit
func (co *ClientOptions) RateLimit() uint64 {
func (co *ClientOptions) RateLimit() int {
if co.rateLimit == nil {
return clientOptionsDefaultRateLimit
}
Expand All @@ -83,13 +83,13 @@ func (co *ClientOptions) SetInsecure(value bool) *ClientOptions {
}

// SetDefaultTimeout sets default http client timeout value
func (co *ClientOptions) SetDefaultTimeout(value uint64) *ClientOptions {
func (co *ClientOptions) SetDefaultTimeout(value int64) *ClientOptions {
co.defaultTimeout = &value
return co
}

// SetRateLimit returns http client rate limit
func (co *ClientOptions) SetRateLimit(value uint64) *ClientOptions {
func (co *ClientOptions) SetRateLimit(value int) *ClientOptions {
co.rateLimit = &value
return co
}
Expand Down
4 changes: 2 additions & 2 deletions client_options_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 Down Expand Up @@ -32,7 +32,7 @@ func TestClientOptions_Insecure(t *testing.T) {

func TestClientOptions_DefaultTimeout(t *testing.T) {
co := NewClientOptions()
value := uint64(120)
value := int64(120)
co.SetDefaultTimeout(value)
assert.Equal(t, value, co.DefaultTimeout())
}
Expand Down
37 changes: 35 additions & 2 deletions cluster_types.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
*
* Copyright © 2021-2022 Dell Inc. or its subsidiaries. All Rights Reserved.
* Copyright © 2021-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 Down Expand Up @@ -29,13 +29,46 @@ type RemoteSystem struct {
SerialNumber string `json:"serial_number,omitempty"`
// Management IP address of the remote system instance
ManagementAddress string `json:"management_address,omitempty"`
// Possible data connection states of a remote system
DataConnectionState string `json:"data_connection_state,omitempty"`
// List of supported remote protection capabilities
Capabilities []string `json:"capabilities,omitempty"`
}

// Fields returns fields which must be requested to fill struct
func (r *RemoteSystem) Fields() []string {
return []string{"id", "name", "description", "serial_number", "management_address"}
return []string{"id", "name", "description", "serial_number", "management_address", "data_connection_state", "capabilities"}
}

type DataConnectStateEnum string

// List of possible data connection states for a RemoteSystem
const (
ConnStateOK DataConnectStateEnum = "OK"
ConnStatePartialDataConnLoss DataConnectStateEnum = "Partial_Data_Connection_Loss"
ConnStateCompleteDataConnLoss DataConnectStateEnum = "Complete_Data_Connection_Loss"
ConnStateNotAvailable DataConnectStateEnum = "Status_Not_Available"
ConnStateNoTargetsDiscovered DataConnectStateEnum = "No_Targets_Discovered"
ConnStateInitializing DataConnectStateEnum = "Initializing"
ConnStateUnstable DataConnectStateEnum = "Data_Connection_Unstable"
)

type RemoteCapabilitiesEnum string

// List of possible remote protection capabilities for a remote system
const (
AsyncBlock RemoteCapabilitiesEnum = "Asynchronous_Block_Replication"
SyncBlock RemoteCapabilitiesEnum = "Synchronous_Block_Replication"
AsyncFile RemoteCapabilitiesEnum = "Asynchronous_File_Replication"
AsyncVvol RemoteCapabilitiesEnum = "Asynchronous_Vvol_Replication"
BlockNonDisruptiveImport RemoteCapabilitiesEnum = "Block_Nondisruptive_Import"
BlockAgentlessImport RemoteCapabilitiesEnum = "Block_Agentless_Import"
FileImport RemoteCapabilitiesEnum = "File_Import"
BlockMetro RemoteCapabilitiesEnum = "Block_Metro_Active_Active"
RemoteBackup RemoteCapabilitiesEnum = "Remote_Backup"
SyncFile RemoteCapabilitiesEnum = "Synchronous_File_Replication"
)

// Cluster details about the cluster
type Cluster struct {
// Unique identifier of the cluster.
Expand Down
20 changes: 10 additions & 10 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,25 +1,25 @@
module github.com/dell/gopowerstore

go 1.22
go 1.23

require (
github.com/go-openapi/strfmt v0.21.2
github.com/go-openapi/strfmt v0.23.0
github.com/jarcoal/httpmock v1.2.0
github.com/joho/godotenv v1.4.0
github.com/joho/godotenv v1.5.1
github.com/sirupsen/logrus v1.9.3
github.com/stretchr/testify v1.7.1
github.com/stretchr/testify v1.9.0
)

require (
github.com/asaskevich/govalidator v0.0.0-20210307081110-f21760c49a8d // indirect
github.com/asaskevich/govalidator v0.0.0-20230301143203-a9d515a09cc2 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/go-openapi/errors v0.20.2 // indirect
github.com/go-stack/stack v1.8.1 // indirect
github.com/go-openapi/errors v0.22.0 // indirect
github.com/google/uuid v1.6.0 // indirect
github.com/mitchellh/mapstructure v1.5.0 // indirect
github.com/oklog/ulid v1.3.1 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/stretchr/objx v0.4.0 // indirect
go.mongodb.org/mongo-driver v1.9.1 // indirect
golang.org/x/sys v0.1.0 // indirect
github.com/stretchr/objx v0.5.2 // indirect
go.mongodb.org/mongo-driver v1.16.1 // indirect
golang.org/x/sys v0.25.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
)
Loading