Skip to content
This repository has been archived by the owner on Apr 18, 2024. It is now read-only.

Commit

Permalink
stabilize dynamics tests
Browse files Browse the repository at this point in the history
  • Loading branch information
willscott committed Sep 4, 2023
1 parent a23963d commit 7375178
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 21 deletions.
11 changes: 3 additions & 8 deletions node_heap.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,14 +53,9 @@ func (nh *NodeHeap) TopN(n int) []*Node {
m := make([]*Node, 0, n)
nh.lk.RLock()
defer nh.lk.RUnlock()
for i := 0; i < n; i++ {
node := heap.Pop(nh)
if n, ok := node.(*Node); ok {
m = append(m, n)
}
}
for _, n := range m {
heap.Push(nh, n)
for i := 0; i < n && i < len(nh.Nodes); i++ {
node := nh.Nodes[i]
m = append(m, node)
}
return m
}
Expand Down
13 changes: 6 additions & 7 deletions pool_dynamics_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,7 @@ import (
)

const (
nodesSize = 6
nodesPoolSize = caboose.PoolConsiderationCount
nodesSize = 6
)

/*
Expand All @@ -41,7 +40,7 @@ func TestPoolDynamics(t *testing.T) {
// This test ensures that when the pool is intialized, it should converge to a set
// of nodes that have stats vs a set of nodes that don't have any stats.
t.Run("pool converges to good nodes vs nodes with no stats", func(t *testing.T) {
ch, controlGroup := getHarnessAndControlGroup(t, nodesSize, nodesPoolSize)
ch, controlGroup := getHarnessAndControlGroup(t, nodesSize, nodesSize/2)
ch.FetchAndAssertSuccess(t, ctx, testCid)

goodNodes := make([]*caboose.Node, 0)
Expand Down Expand Up @@ -96,13 +95,13 @@ func TestPoolDynamics(t *testing.T) {
fmt.Println("Final Node Pool", np)

for _, n := range ch.CabooseAllNodes.Nodes {
fmt.Println("Node", n.URL, "Priority", n.Priority(), "Rate", n.Rate())
fmt.Println("Node", n.URL, "Priority", n.Priority(), "Rate", n.Rate(), "samples ", len(n.Samples.PeekAll()))
}

})

t.Run("pool converges to good nodes vs nodes with worse stats", func(t *testing.T) {
ch, controlGroup := getHarnessAndControlGroup(t, nodesSize, nodesPoolSize)
ch, controlGroup := getHarnessAndControlGroup(t, nodesSize, nodesSize/2)

goodNodes := make([]*caboose.Node, 0)
badNodes := make([]*caboose.Node, 0)
Expand Down Expand Up @@ -142,7 +141,7 @@ func TestPoolDynamics(t *testing.T) {
// When new nodes join, if they start consistently performing better than the nodes in the current pool,
// then those nodes should replace the nodes in the current pool.
t.Run("pool converges to new nodes that are better than the current pool", func(t *testing.T) {
ch, controlGroup := getHarnessAndControlGroup(t, nodesSize, nodesPoolSize)
ch, controlGroup := getHarnessAndControlGroup(t, nodesSize, nodesSize/2)
goodNodes := make([]*caboose.Node, 0)
badNodes := make([]*caboose.Node, 0)

Expand Down Expand Up @@ -188,7 +187,7 @@ func TestPoolDynamics(t *testing.T) {
// If the current active main pool starts failing, the pool should converge to
// to nodes that are not failing.
t.Run("pool converges to other nodes if the current ones start failing", func(t *testing.T) {
ch, controlGroup := getHarnessAndControlGroup(t, nodesSize, nodesPoolSize)
ch, controlGroup := getHarnessAndControlGroup(t, nodesSize, nodesSize/2)
goodNodes := make([]*caboose.Node, 0)
badNodes := make([]*caboose.Node, 0)

Expand Down
7 changes: 1 addition & 6 deletions pool_tier_promotion.go
Original file line number Diff line number Diff line change
@@ -1,17 +1,12 @@
package caboose

import "fmt"

const (
PoolConsiderationCount = 3
PoolConsiderationCount = 30
activationThreshold = 0
)

func updateActiveNodes(active *NodeRing, all *NodeHeap) error {
candidates := all.TopN(PoolConsiderationCount)
for _, c := range(candidates) {
fmt.Println("Candidates", c.URL, c.PredictedThroughput)
}
added := 0
for _, c := range candidates {
if active.Contains(c) {
Expand Down

0 comments on commit 7375178

Please sign in to comment.