This repository has been archived by the owner on Apr 18, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
Test cache affinity #163
Merged
Merged
Test cache affinity #163
Changes from 3 commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -222,7 +222,9 @@ func TestPoolAffinity(t *testing.T) { | |
cidList := generateRandomCIDs(20) | ||
|
||
t.Run("selected nodes remain consistent for same cid reqs", func(t *testing.T) { | ||
ch, controlGroup := getHarnessAndControlGroup(t, nodesSize, nodesSize/2) | ||
// 80 nodes will be in the good pool. 20 will be added later with the same stats. | ||
// So, 20% of the nodes in the pool will eventually be "new nodes" that have been added later. | ||
ch, controlGroup := getHarnessAndControlGroup(t, 100, 80) | ||
_, _ = ch.Caboose.Get(ctx, cidList[0]) | ||
|
||
goodNodes := make([]*caboose.Node, 0) | ||
|
@@ -265,38 +267,32 @@ func TestPoolAffinity(t *testing.T) { | |
Size: float64(baseStatSize) * float64(10), | ||
} | ||
|
||
// variedStats := util.NodeStats{ | ||
// Start: time.Now().Add(-time.Second * 2), | ||
// Latency: float64(baseStatLatency) / (float64(10) + (1 + statVarianceFactor)), | ||
// Size: float64(baseStatSize) * float64(10) * (1 + statVarianceFactor), | ||
// } | ||
|
||
ch.RecordSuccesses(t, goodNodes, baseStats, 100) | ||
ch.RecordSuccesses(t, badNodes, baseStats, 10) | ||
|
||
ch.CaboosePool.DoRefresh() | ||
} | ||
|
||
// for _, i := range ch.CabooseAllNodes.Nodes { | ||
// fmt.Println(i.URL, i.Priority(), i.PredictedLatency) | ||
// } | ||
rerouteCount := 0 | ||
|
||
// Get the candidate nodes for a few cids from our formed cid list using | ||
// the affinity of each cid. | ||
for i := 0; i < 10; i++ { | ||
rand.New(rand.NewSource(time.Now().Unix())) | ||
idx := rand.Intn(len(cidList)) | ||
c := cidList[idx] | ||
// Get the candidate nodes for each cid in the cid list to see if it's been rerouted to a new node. | ||
for _, c := range cidList { | ||
aff := ch.Caboose.GetAffinity(ctx) | ||
if aff == "" { | ||
aff = fmt.Sprintf(blockPathPattern, c) | ||
} | ||
nodes, _ := ch.CabooseActiveNodes.GetNodes(aff, ch.Config.MaxRetrievalAttempts) | ||
|
||
// We expect that the candidate nodes are part of the "good nodes" list. | ||
assert.Contains(t, goodNodes, nodes[0]) | ||
for _, n := range badNodes { | ||
n := n | ||
if n.URL == nodes[0].URL { | ||
rerouteCount++ | ||
} | ||
} | ||
} | ||
|
||
// no more than 5 cids from the cid list of 20 should get re-routed (25%) | ||
assert.LessOrEqual(t, rerouteCount, 4) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. should this be 5, rather than 4? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done. |
||
}) | ||
} | ||
|
||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should 'reroute' be incremented when this doesn't match?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe reroute is meant to keep track of how often caboose returns a new joining node as the candidate node to fetch a cid in which case caboose is "rerouting" where it fetches that cid from. In that case, the increment here is good imo.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah what Amean said.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We're iterating over bad nodes here.