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

Add tests back #143

Merged
Merged
Changes from all commits
Commits
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
83 changes: 83 additions & 0 deletions internal/app/mapper/mapper_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -580,6 +580,30 @@ var negativeTests = []TableEntry{
getDiscoveryRequest(),
},
},
{
Description: "RequestNodeMatch with node region regex does not match",
Parameters: []interface{}{
getRequestNodeLocality(getRegexMatch(noderegion+"\\d"), getExactMatch(nodezone), getExactMatch(nodesubzone)),
getResultStringFragment(),
getDiscoveryRequest(),
},
},
{
Description: "RequestNodeMatch with node zone regex does not match",
Parameters: []interface{}{
getRequestNodeLocality(getExactMatch(noderegion), getRegexMatch("zon[A-Z]"), getExactMatch(nodesubzone)),
getResultStringFragment(),
getDiscoveryRequest(),
},
},
{
Description: "RequestNodeMatch with node subzone regex does not match",
Parameters: []interface{}{
getRequestNodeLocality(getExactMatch(noderegion), getExactMatch(nodezone), getRegexMatch(nodesubzone+"\\B")),
getResultStringFragment(),
getDiscoveryRequest(),
},
},
{
Description: "RequestNodeMatch with exact match request node id mismatch",
Parameters: []interface{}{
Expand Down Expand Up @@ -636,6 +660,32 @@ var negativeTests = []TableEntry{
getDiscoveryRequestWithNode(getNode(nodeid, nodecluster, noderegion, nodezone, "mismatch")),
},
},

{
Description: "RequestNodeMatch with regex match request node region mismatch",
Parameters: []interface{}{
getRequestNodeLocality(getRegexMatch(noderegion), getExactMatch(nodezone), getExactMatch(nodesubzone)),
getResultStringFragment(),
getDiscoveryRequestWithNode(getNode(nodeid, nodecluster, "mismatch", nodezone, nodesubzone)),
},
},
{
Description: "RequestNodeMatch with regex match request node zone mismatch",
Parameters: []interface{}{
getRequestNodeLocality(getExactMatch(noderegion), getRegexMatch(nodezone), getExactMatch(nodesubzone)),
getResultStringFragment(),
getDiscoveryRequestWithNode(getNode(nodeid, nodecluster, noderegion, "mismatch", nodesubzone)),
},
},
{
Description: "RequestNodeMatch with regex match request node subzone mismatch",
Parameters: []interface{}{
getRequestNodeLocality(getExactMatch(noderegion), getExactMatch(nodezone), getRegexMatch(nodesubzone)),
getResultStringFragment(),
getDiscoveryRequestWithNode(getNode(nodeid, nodecluster, noderegion, nodezone, "mismatch")),
},
},

{
Description: "AndMatch RequestNodeMatch does not match first predicate",
Parameters: []interface{}{
Expand Down Expand Up @@ -884,6 +934,39 @@ var emptyFragmentErrorCases = []TableEntry{
"MatchPredicate Node field cannot be empty",
},
},
{
Description: "empty node region in request predicate",
Parameters: []interface{}{
getRequestNodeClusterExactMatch(nodecluster),
getResultRequestNodeLocalityFragment(&aggregationv1.ResultPredicate_LocalityResultAction{
RegionAction: getExactAction(),
}),
getDiscoveryRequestWithNode(getNode(nodeid, nodecluster, "", nodezone, nodesubzone)),
"RequestNodeFragment exact match resulted in an empty fragment",
},
},
{
Description: "empty node zone in request predicate",
Parameters: []interface{}{
getRequestNodeClusterExactMatch(nodecluster),
getResultRequestNodeLocalityFragment(&aggregationv1.ResultPredicate_LocalityResultAction{
ZoneAction: getExactAction(),
}),
getDiscoveryRequestWithNode(getNode(nodeid, nodecluster, noderegion, "", nodesubzone)),
"RequestNodeFragment exact match resulted in an empty fragment",
},
},
{
Description: "empty node subzone in request predicate",
Parameters: []interface{}{
getRequestNodeClusterExactMatch(nodecluster),
getResultRequestNodeLocalityFragment(&aggregationv1.ResultPredicate_LocalityResultAction{
SubzoneAction: getExactAction(),
}),
getDiscoveryRequestWithNode(getNode(nodeid, nodecluster, noderegion, nodezone, "")),
"RequestNodeFragment exact match resulted in an empty fragment",
},
},
{
Description: "empty node id in response action",
Parameters: []interface{}{
Expand Down