-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Bohdan Siryk
authored and
Bohdan Siryk
committed
Jan 23, 2024
1 parent
f0c1a68
commit 4844500
Showing
6 changed files
with
268 additions
and
57 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,182 @@ | ||
package v1beta1 | ||
|
||
import ( | ||
"testing" | ||
) | ||
|
||
func TestOpenSearchStatus_Equals(t *testing.T) { | ||
tests := map[string]struct { | ||
fields OpenSearchStatus | ||
args OpenSearchStatus | ||
want bool | ||
}{ | ||
"Equal Empty Objects": { | ||
fields: OpenSearchStatus{}, | ||
args: OpenSearchStatus{}, | ||
want: true, | ||
}, | ||
"Different LoadBalancerConnectionURL": { | ||
fields: OpenSearchStatus{LoadBalancerConnectionURL: ""}, | ||
args: OpenSearchStatus{LoadBalancerConnectionURL: "http://loadbalancer1"}, | ||
want: false, | ||
}, | ||
"Different PrivateEndpoint": { | ||
fields: OpenSearchStatus{PrivateEndpoint: ""}, | ||
args: OpenSearchStatus{PrivateEndpoint: "http://private1"}, | ||
want: false, | ||
}, | ||
"Different PublicEndpoint": { | ||
fields: OpenSearchStatus{PublicEndpoint: ""}, | ||
args: OpenSearchStatus{PublicEndpoint: "http://public1"}, | ||
want: false, | ||
}, | ||
"Different IngestNodesLoadBalancerConnectionURL": { | ||
fields: OpenSearchStatus{IngestNodesLoadBalancerConnectionURL: ""}, | ||
args: OpenSearchStatus{IngestNodesLoadBalancerConnectionURL: "http://ingest1"}, | ||
want: false, | ||
}, | ||
|
||
"Different GenericStatus ID": { | ||
fields: OpenSearchStatus{GenericStatus: GenericStatus{ID: ""}}, | ||
args: OpenSearchStatus{GenericStatus: GenericStatus{ID: "1"}}, | ||
want: false, | ||
}, | ||
"Different GenericStatus State": { | ||
fields: OpenSearchStatus{GenericStatus: GenericStatus{State: "PROVISIONING"}}, | ||
args: OpenSearchStatus{GenericStatus: GenericStatus{State: "RUNNING"}}, | ||
want: false, | ||
}, | ||
"Different GenericStatus CurrentClusterOperationStatus": { | ||
fields: OpenSearchStatus{GenericStatus: GenericStatus{CurrentClusterOperationStatus: "NO_OPERATION"}}, | ||
args: OpenSearchStatus{GenericStatus: GenericStatus{CurrentClusterOperationStatus: "OPERATION_IN_PROGRESS"}}, | ||
want: false, | ||
}, | ||
|
||
"Different DataCentre ID": { | ||
fields: OpenSearchStatus{DataCentres: []OpenSearchDataCentreStatus{{GenericDataCentreStatus: GenericDataCentreStatus{ID: ""}}}}, | ||
args: OpenSearchStatus{DataCentres: []OpenSearchDataCentreStatus{{GenericDataCentreStatus: GenericDataCentreStatus{ID: "dc1"}}}}, | ||
want: false, | ||
}, | ||
"Different DataCentre Name": { | ||
fields: OpenSearchStatus{DataCentres: []OpenSearchDataCentreStatus{{GenericDataCentreStatus: GenericDataCentreStatus{Name: ""}}}}, | ||
args: OpenSearchStatus{DataCentres: []OpenSearchDataCentreStatus{{GenericDataCentreStatus: GenericDataCentreStatus{Name: "DataCentre1"}}}}, | ||
want: false, | ||
}, | ||
"Different DataCentre Status": { | ||
fields: OpenSearchStatus{DataCentres: []OpenSearchDataCentreStatus{{GenericDataCentreStatus: GenericDataCentreStatus{Status: "PROVISIONING"}}}}, | ||
args: OpenSearchStatus{DataCentres: []OpenSearchDataCentreStatus{{GenericDataCentreStatus: GenericDataCentreStatus{Status: "RUNNING"}}}}, | ||
want: false, | ||
}, | ||
|
||
"Different Node PublicEndpoint": { | ||
fields: OpenSearchStatus{DataCentres: []OpenSearchDataCentreStatus{{Nodes: []OpenSearchNodeStatus{{PublicEndpoint: ""}}}}}, | ||
args: OpenSearchStatus{DataCentres: []OpenSearchDataCentreStatus{{Nodes: []OpenSearchNodeStatus{{PublicEndpoint: "http://public.node1"}}}}}, | ||
want: false, | ||
}, | ||
"Different Node PrivateEndpoint": { | ||
fields: OpenSearchStatus{DataCentres: []OpenSearchDataCentreStatus{{Nodes: []OpenSearchNodeStatus{{PrivateEndpoint: ""}}}}}, | ||
args: OpenSearchStatus{DataCentres: []OpenSearchDataCentreStatus{{Nodes: []OpenSearchNodeStatus{{PrivateEndpoint: "http://private.node1"}}}}}, | ||
want: false, | ||
}, | ||
"Different Node PrivateLinkConnectionURL": { | ||
fields: OpenSearchStatus{DataCentres: []OpenSearchDataCentreStatus{{Nodes: []OpenSearchNodeStatus{{PrivateLinkConnectionURL: ""}}}}}, | ||
args: OpenSearchStatus{DataCentres: []OpenSearchDataCentreStatus{{Nodes: []OpenSearchNodeStatus{{PrivateLinkConnectionURL: "http://privatelink.node1"}}}}}, | ||
want: false, | ||
}, | ||
|
||
"Different Node ID": { | ||
fields: OpenSearchStatus{DataCentres: []OpenSearchDataCentreStatus{{Nodes: []OpenSearchNodeStatus{{Node: Node{ID: "node1"}}}}}}, | ||
args: OpenSearchStatus{DataCentres: []OpenSearchDataCentreStatus{{Nodes: []OpenSearchNodeStatus{{Node: Node{ID: "node2"}}}}}}, | ||
want: false, | ||
}, | ||
"Different Node Size": { | ||
fields: OpenSearchStatus{DataCentres: []OpenSearchDataCentreStatus{{Nodes: []OpenSearchNodeStatus{{Node: Node{Size: "large"}}}}}}, | ||
args: OpenSearchStatus{DataCentres: []OpenSearchDataCentreStatus{{Nodes: []OpenSearchNodeStatus{{Node: Node{Size: "small"}}}}}}, | ||
want: false, | ||
}, | ||
"Different Node PublicAddress": { | ||
fields: OpenSearchStatus{DataCentres: []OpenSearchDataCentreStatus{{Nodes: []OpenSearchNodeStatus{{Node: Node{PublicAddress: ""}}}}}}, | ||
args: OpenSearchStatus{DataCentres: []OpenSearchDataCentreStatus{{Nodes: []OpenSearchNodeStatus{{Node: Node{PublicAddress: "192.168.1.2"}}}}}}, | ||
want: false, | ||
}, | ||
"Different Node PrivateAddress": { | ||
fields: OpenSearchStatus{DataCentres: []OpenSearchDataCentreStatus{{Nodes: []OpenSearchNodeStatus{{Node: Node{PrivateAddress: ""}}}}}}, | ||
args: OpenSearchStatus{DataCentres: []OpenSearchDataCentreStatus{{Nodes: []OpenSearchNodeStatus{{Node: Node{PrivateAddress: "10.0.0.2"}}}}}}, | ||
want: false, | ||
}, | ||
"Different Node Status": { | ||
fields: OpenSearchStatus{DataCentres: []OpenSearchDataCentreStatus{{Nodes: []OpenSearchNodeStatus{{Node: Node{Status: "PROVISIONING"}}}}}}, | ||
args: OpenSearchStatus{DataCentres: []OpenSearchDataCentreStatus{{Nodes: []OpenSearchNodeStatus{{Node: Node{Status: "RUNNING"}}}}}}, | ||
want: false, | ||
}, | ||
"Different Node Roles": { | ||
fields: OpenSearchStatus{DataCentres: []OpenSearchDataCentreStatus{{Nodes: []OpenSearchNodeStatus{{Node: Node{Roles: []string{""}}}}}}}, | ||
args: OpenSearchStatus{DataCentres: []OpenSearchDataCentreStatus{{Nodes: []OpenSearchNodeStatus{{Node: Node{Roles: []string{"MASTER"}}}}}}}, | ||
want: false, | ||
}, | ||
"Different Node Rack": { | ||
fields: OpenSearchStatus{DataCentres: []OpenSearchDataCentreStatus{{Nodes: []OpenSearchNodeStatus{{Node: Node{Rack: ""}}}}}}, | ||
args: OpenSearchStatus{DataCentres: []OpenSearchDataCentreStatus{{Nodes: []OpenSearchNodeStatus{{Node: Node{Rack: "rack1"}}}}}}, | ||
want: false, | ||
}, | ||
|
||
"Different OpenSearchNodeStatus PublicEndpoint": { | ||
fields: OpenSearchStatus{ | ||
DataCentres: []OpenSearchDataCentreStatus{ | ||
{Nodes: []OpenSearchNodeStatus{{PublicEndpoint: ""}}}, | ||
}, | ||
}, | ||
args: OpenSearchStatus{ | ||
DataCentres: []OpenSearchDataCentreStatus{ | ||
{Nodes: []OpenSearchNodeStatus{{PublicEndpoint: "http://public.node1"}}}, | ||
}, | ||
}, | ||
want: false, | ||
}, | ||
"Different OpenSearchNodeStatus PrivateEndpoint": { | ||
fields: OpenSearchStatus{ | ||
DataCentres: []OpenSearchDataCentreStatus{ | ||
{Nodes: []OpenSearchNodeStatus{{PrivateEndpoint: ""}}}, | ||
}, | ||
}, | ||
args: OpenSearchStatus{ | ||
DataCentres: []OpenSearchDataCentreStatus{ | ||
{Nodes: []OpenSearchNodeStatus{{PrivateEndpoint: "http://private.node1"}}}, | ||
}, | ||
}, | ||
want: false, | ||
}, | ||
"Different OpenSearchNodeStatus PrivateLinkConnectionURL": { | ||
fields: OpenSearchStatus{ | ||
DataCentres: []OpenSearchDataCentreStatus{ | ||
{Nodes: []OpenSearchNodeStatus{{PrivateLinkConnectionURL: ""}}}, | ||
}, | ||
}, | ||
args: OpenSearchStatus{ | ||
DataCentres: []OpenSearchDataCentreStatus{ | ||
{Nodes: []OpenSearchNodeStatus{{PrivateLinkConnectionURL: "http://privatelink.node1"}}}, | ||
}, | ||
}, | ||
want: false, | ||
}, | ||
} | ||
|
||
for name, tt := range tests { | ||
tt := tt | ||
|
||
t.Run(name, func(t *testing.T) { | ||
//t.Parallel() | ||
oss := &OpenSearchStatus{ | ||
GenericStatus: tt.fields.GenericStatus, | ||
DataCentres: tt.fields.DataCentres, | ||
LoadBalancerConnectionURL: tt.fields.LoadBalancerConnectionURL, | ||
PrivateEndpoint: tt.fields.PrivateEndpoint, | ||
PublicEndpoint: tt.fields.PublicEndpoint, | ||
IngestNodesLoadBalancerConnectionURL: tt.fields.IngestNodesLoadBalancerConnectionURL, | ||
} | ||
if got := oss.Equals(&tt.args); got != tt.want { | ||
t.Errorf("Equals() = %v, want %v", got, tt.want) | ||
} | ||
}) | ||
} | ||
} |
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