Skip to content

Commit

Permalink
Prevent Director sort tests from leaking between each other
Browse files Browse the repository at this point in the history
  • Loading branch information
jhiemstrawisc committed Oct 1, 2024
1 parent 9f1cf8d commit 3d28f0f
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions director/sort_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,10 @@ var yamlMockup string

func TestCheckOverrides(t *testing.T) {
viper.Reset()
t.Cleanup(func() {
viper.Reset()
geoIPOverrides = nil
})

// We'll also check that our logging feature responsibly reports
// what Pelican is telling the user.
Expand Down Expand Up @@ -138,8 +142,6 @@ func TestCheckOverrides(t *testing.T) {
require.Equal(t, expectedCoordinate.Lat, coordinate.Lat)
require.Equal(t, expectedCoordinate.Long, coordinate.Long)
})

viper.Reset()
}

func TestSortServerAdsByTopo(t *testing.T) {
Expand Down Expand Up @@ -192,6 +194,7 @@ func TestSortServerAds(t *testing.T) {
viper.Reset()
t.Cleanup(func() {
viper.Reset()
geoIPOverrides = nil
})

// A random IP that should geo-resolve to roughly the same location as the Madison server
Expand Down Expand Up @@ -443,6 +446,8 @@ func TestAssignRandBoundedCoord(t *testing.T) {
}

func TestGetClientLatLong(t *testing.T) {
// The cache may be populated from previous tests. Wipe it out and start fresh.
clientIpCache.DeleteAll()
t.Run("invalid-ip", func(t *testing.T) {
// Capture the log and check that the correct error is logged
logOutput := &(bytes.Buffer{})
Expand Down

0 comments on commit 3d28f0f

Please sign in to comment.