mirror of
https://github.com/slackhq/nebula.git
synced 2025-12-05 18:20:48 -08:00
Some checks are pending
gofmt / Run gofmt (push) Waiting to run
smoke-extra / Run extra smoke tests (push) Waiting to run
smoke / Run multi node smoke test (push) Waiting to run
Build and test / Build all and test on ubuntu-linux (push) Waiting to run
Build and test / Build and test on linux with boringcrypto (push) Waiting to run
Build and test / Build and test on linux with pkcs11 (push) Waiting to run
Build and test / Build and test on ${{ matrix.os }} (macos-latest) (push) Waiting to run
Build and test / Build and test on ${{ matrix.os }} (windows-latest) (push) Waiting to run
34 lines
1 KiB
Go
34 lines
1 KiB
Go
package routing
|
|
|
|
import (
|
|
"net/netip"
|
|
"testing"
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
)
|
|
|
|
func TestRebalance3_2Split(t *testing.T) {
|
|
gateways := []Gateway{}
|
|
|
|
gateways = append(gateways, Gateway{addr: netip.Addr{}, weight: 10})
|
|
gateways = append(gateways, Gateway{addr: netip.Addr{}, weight: 5})
|
|
|
|
CalculateBucketsForGateways(gateways)
|
|
|
|
assert.Equal(t, 1431655764, gateways[0].bucketUpperBound) // INT_MAX/3*2
|
|
assert.Equal(t, 2147483647, gateways[1].bucketUpperBound) // INT_MAX
|
|
}
|
|
|
|
func TestRebalanceEqualSplit(t *testing.T) {
|
|
gateways := []Gateway{}
|
|
|
|
gateways = append(gateways, Gateway{addr: netip.Addr{}, weight: 1})
|
|
gateways = append(gateways, Gateway{addr: netip.Addr{}, weight: 1})
|
|
gateways = append(gateways, Gateway{addr: netip.Addr{}, weight: 1})
|
|
|
|
CalculateBucketsForGateways(gateways)
|
|
|
|
assert.Equal(t, 715827882, gateways[0].bucketUpperBound) // INT_MAX/3
|
|
assert.Equal(t, 1431655764, gateways[1].bucketUpperBound) // INT_MAX/3*2
|
|
assert.Equal(t, 2147483647, gateways[2].bucketUpperBound) // INT_MAX
|
|
}
|