-
Notifications
You must be signed in to change notification settings - Fork 138
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
CBG-695 - Support external alternate address heuristic (#4506) * CBG-695 - Support external alternate address heuristic * Pass down Cbgt logging context into alt address shims * Always use nodes listed in nodeServices for alternate address mapping * Improve logging * Invert logic - default to external host (if present) - and use internal when any given connStr host matches a default/internal network hostname.
- Loading branch information
Showing
7 changed files
with
154 additions
and
49 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
package base | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/stretchr/testify/assert" | ||
"github.com/stretchr/testify/require" | ||
) | ||
|
||
func TestGetExternalAlternateAddress(t *testing.T) { | ||
tests := []struct { | ||
name string | ||
dest string | ||
altAddrMap map[string]string | ||
expectedDest string | ||
}{ | ||
{ | ||
name: "no alts", | ||
dest: "node1.cbs.example.org:1234", | ||
expectedDest: "node1.cbs.example.org:1234", | ||
}, | ||
{ | ||
name: "non-matching alt", | ||
dest: "node1.cbs.example.org:1234", | ||
altAddrMap: map[string]string{ | ||
"node9.cbs.example.org": "10.10.10.9:5678", | ||
}, | ||
expectedDest: "node1.cbs.example.org:1234", | ||
}, | ||
{ | ||
name: "matching alt, alt connect URL", | ||
dest: "node1.cbs.example.org:1234", | ||
altAddrMap: map[string]string{ | ||
"node1.cbs.example.org": "10.10.10.1:5678", | ||
}, | ||
expectedDest: "10.10.10.1:5678", | ||
}, | ||
{ | ||
name: "matching alt multiple", | ||
dest: "node2.cbs.example.org:1234", | ||
altAddrMap: map[string]string{ | ||
"node1.cbs.example.org": "10.10.10.1:5678", | ||
"node2.cbs.example.org": "10.10.10.2:5678", | ||
"node3.cbs.example.org": "10.10.10.3:5678", | ||
}, | ||
expectedDest: "10.10.10.2:5678", | ||
}, | ||
} | ||
|
||
for _, test := range tests { | ||
t.Run(test.name, func(t *testing.T) { | ||
newDest, err := getExternalAlternateAddress(nil, test.altAddrMap, test.dest) | ||
require.NoError(t, err) | ||
assert.Equal(t, test.expectedDest, newDest) | ||
}) | ||
} | ||
} |
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
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
Oops, something went wrong.