Skip to content

Add consistent hash load balancing e2e testing #242

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Jun 9, 2022
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions test/e2e/metaprotocol/metaprotocol_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -145,3 +145,27 @@ func testAttributeMatch(matchPattern string, t *testing.T) {
}
}
}

func TestConsistentHashLb(t *testing.T) {
util.WaitForDeploymentsReady("metaprotocol", 10*time.Minute, "")
util.KubeApply("metaprotocol", "testdata/consistent-hash-lb/destinationrule.yaml", "")
util.KubeApply("metaprotocol", "testdata/consistent-hash-lb/metarouter-sample.yaml", "")
log.Info("Waiting for rules to propagate ...")
time.Sleep(1 * time.Minute)
consumerPod, _ := util.GetPodName("metaprotocol", "app=dubbo-sample-consumer", "")
var v1, v2 int
for i := 0; i < 10; i++ {
dubboResponse, _ := util.PodExec("metaprotocol", consumerPod, "dubbo-sample-consumer",
"curl -s 127.0.0.1:9009/hello", false, "")
log.Info(dubboResponse)
if strings.Contains(dubboResponse, "response from dubbo-sample-provider-v1") {
v1++
}
if strings.Contains(dubboResponse, "response from dubbo-sample-provider-v2") {
v2++
}
}
if !(v1 == 10 || v2 == 10) {
t.Errorf("consistent hash lb failed, v1:v2 want: 0:10 or 10:0, got %d:%d", v1, v2)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
---
apiVersion: networking.istio.io/v1alpha3
kind: DestinationRule
metadata:
name: dubbo-sample-provider
spec:
host: org.apache.dubbo.samples.basic.api.demoservice
subsets:
- name: sample
labels:
app: dubbo-sample-provider
trafficPolicy:
loadBalancer:
consistentHash:
httpHeaderName: method

Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
---
apiVersion: metaprotocol.aeraki.io/v1alpha1
kind: MetaRouter
metadata:
name: test-metaprotocol-route
spec:
hosts:
- org.apache.dubbo.samples.basic.api.demoservice
routes:
- name: sample
route:
- destination:
host: org.apache.dubbo.samples.basic.api.demoservice
subset: sample