Skip to content

Commit

Permalink
Remove broken test
Browse files Browse the repository at this point in the history
  • Loading branch information
na-- committed Nov 3, 2015
1 parent b5f5f31 commit b5c952c
Showing 1 changed file with 0 additions and 41 deletions.
41 changes: 0 additions & 41 deletions upstream/balancing/weighted/rendezvous/impl_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import (
"fmt"
"math"
"math/rand"
"reflect"
"testing"
"time"

Expand Down Expand Up @@ -32,43 +31,3 @@ func TestPercentageCalculations(t *testing.T) {
t.Errorf("Bucket percentages do not combine to 1: %f", totalPercent)
}
}

func TestOperations(t *testing.T) {
t.Parallel()

upstreams := testutils.GetRandomUpstreams(50, 200)
r := New()
r.Set(upstreams)

urlsToTest := rand.Intn(500)
mapping := map[string]string{}
for i := 0; i < urlsToTest; i++ {
url := testutils.GenerateMeAString(rand.Int63(), 1+rand.Int63n(50))
if res1, err := r.Get(url); err != nil {
t.Errorf("Unexpected error when getting url %s: %s", url, err)
} else if res2, err := r.Get(url); err != nil {
t.Errorf("Unexpected error when getting url %s for the second time: %s", url, err)
} else if !reflect.DeepEqual(res1, res2) {
t.Errorf("The two results for url %s are different: %#v and %#v", url, res1, res2)
} else {
mapping[url] = res1.Host
}
}

blackSheep := rand.Intn(len(upstreams))
blackSheepsHost := upstreams[blackSheep].Host
upstreams = upstreams[:blackSheep+copy(upstreams[blackSheep:], upstreams[blackSheep+1:])]
r.Set(upstreams)
for url, oldHost := range mapping {
if res, err := r.Get(url); err != nil {
t.Errorf("Unexpected error when getting url %s: %s", url, err)
} else if oldHost != blackSheepsHost && res.Host != oldHost {
t.Errorf("Expected to return the same old value %s for url %s but it returned %s",
oldHost, url, res.Host)
fmt.Printf("The black sheep was upstream #%d with host %s\n", blackSheep, blackSheepsHost)
} else if oldHost == blackSheepsHost && res.Host == oldHost {
t.Errorf("Expected to different value than the black sheep for url %s but it returned %s",
url, res.Host)
}
}
}

0 comments on commit b5c952c

Please sign in to comment.