-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(component/network): latency checks to global edge/DERP servers (…
…using tailscale) (#125) * feat(component/network): latency checks to global edge/DERP servers (using tailscale) Signed-off-by: Gyuho Lee <gyuhox@gmail.com> * use min timeout Signed-off-by: Gyuho Lee <gyuhox@gmail.com> * update Signed-off-by: Gyuho Lee <gyuhox@gmail.com> * log Signed-off-by: Gyuho Lee <gyuhox@gmail.com> * skip Signed-off-by: Gyuho Lee <gyuhox@gmail.com> * check Signed-off-by: Gyuho Lee <gyuhox@gmail.com> * update, move packages to latency Signed-off-by: Gyuho Lee <gyuhox@gmail.com> * fix Signed-off-by: Gyuho Lee <gyuhox@gmail.com> * rename aws region, remove asn Signed-off-by: Gyuho Lee <gyuhox@gmail.com> * dallas us-east-1 Signed-off-by: Gyuho Lee <gyuhox@gmail.com> * renamed to region code Signed-off-by: Gyuho Lee <gyuhox@gmail.com> --------- Signed-off-by: Gyuho Lee <gyuhox@gmail.com>
- Loading branch information
Showing
25 changed files
with
1,432 additions
and
856 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
package latency_test | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/leptonai/gpud/components/network/latency" | ||
pkg_latency "github.com/leptonai/gpud/pkg/latency" | ||
) | ||
|
||
func TestStatesHealthyEvaluation(t *testing.T) { | ||
tests := []struct { | ||
name string | ||
latencies pkg_latency.Latencies | ||
globalThreshold int64 | ||
expectedHealthyStatus bool | ||
}{ | ||
{ | ||
name: "All latencies below threshold", | ||
latencies: pkg_latency.Latencies{ | ||
{LatencyMilliseconds: 50, RegionName: "region1"}, | ||
{LatencyMilliseconds: 60, RegionName: "region2"}, | ||
}, | ||
globalThreshold: 100, | ||
expectedHealthyStatus: true, | ||
}, | ||
{ | ||
name: "Some latencies above threshold", | ||
latencies: pkg_latency.Latencies{ | ||
{LatencyMilliseconds: 150, RegionName: "region1"}, | ||
{LatencyMilliseconds: 60, RegionName: "region2"}, | ||
}, | ||
globalThreshold: 100, | ||
expectedHealthyStatus: true, | ||
}, | ||
{ | ||
name: "All latencies above threshold", | ||
latencies: pkg_latency.Latencies{ | ||
{LatencyMilliseconds: 150, RegionName: "region1"}, | ||
{LatencyMilliseconds: 160, RegionName: "region2"}, | ||
}, | ||
globalThreshold: 100, | ||
expectedHealthyStatus: false, | ||
}, | ||
{ | ||
name: "No threshold set", | ||
latencies: pkg_latency.Latencies{ | ||
{LatencyMilliseconds: 150, RegionName: "region1"}, | ||
{LatencyMilliseconds: 160, RegionName: "region2"}, | ||
}, | ||
globalThreshold: 0, | ||
expectedHealthyStatus: true, | ||
}, | ||
} | ||
|
||
for _, tt := range tests { | ||
t.Run(tt.name, func(t *testing.T) { | ||
output := &latency.Output{ | ||
EgressLatencies: tt.latencies, | ||
} | ||
cfg := latency.Config{ | ||
GlobalMillisecondThreshold: tt.globalThreshold, | ||
} | ||
|
||
states, err := output.States(cfg) | ||
if err != nil { | ||
t.Fatalf("unexpected error: %v", err) | ||
} | ||
|
||
if len(states) != 1 { | ||
t.Fatalf("expected 1 state, got %d", len(states)) | ||
} | ||
|
||
if states[0].Healthy != tt.expectedHealthyStatus { | ||
t.Errorf("expected healthy status to be %v, got %v", tt.expectedHealthyStatus, states[0].Healthy) | ||
} | ||
}) | ||
} | ||
} |
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.