Skip to content
Snippets Groups Projects
Commit 665a9629 authored by watermelo's avatar watermelo
Browse files

Mod: add router tag unit tests scripts

parent 9375ede6
No related branches found
No related tags found
No related merge requests found
......@@ -36,5 +36,8 @@ xcopy /f "%zkJar%" "cluster/router/chain/zookeeper-4unittest/contrib/fatjar/"
md cluster\router\condition\zookeeper-4unittest\contrib\fatjar
xcopy /f "%zkJar%" "cluster/router/condition/zookeeper-4unittest/contrib/fatjar/"
mkdir -p cluster/router/tag/zookeeper-4unittest/contrib/fatjar
cp ${zkJar} cluster/router/tag/zookeeper-4unittest/contrib/fatjar
md metadata\report\zookeeper\zookeeper-4unittest\contrib\fatjar
xcopy /f "%zkJar%" "metadata/report/zookeeper/zookeeper-4unittest/contrib/fatjar/"
\ No newline at end of file
......@@ -221,29 +221,27 @@ func filterInvokersWithTag(invokers []protocol.Invoker, url *common.URL, invocat
if len(result) > 0 || tagRouterRule.Force {
return result
}
} else {
// dynamic tag group doesn't have any item about the requested app OR it's null after filtered by
// dynamic tag group but force=false. check static tag
filter := func(invoker protocol.Invoker) bool {
return invoker.GetUrl().GetParam(constant.Tagkey, "") == tag
}
result = filterInvoker(invokers, filter)
}
// dynamic tag group doesn't have any item about the requested app OR it's null after filtered by
// dynamic tag group but force=false. check static tag
filter := func(invoker protocol.Invoker) bool {
return invoker.GetUrl().GetParam(constant.Tagkey, "") == tag
}
result = filterInvoker(invokers, filter)
// If there's no tagged providers that can match the current tagged request. force.tag is set by default
// to false, which means it will invoke any providers without a tag unless it's explicitly disallowed.
if len(result) > 0 || isForceUseTag(url, invocation) {
return result
} else {
// FAILOVER: return all Providers without any tags.
filterAddressNotMatches := func(invoker protocol.Invoker) bool {
url := invoker.GetUrl()
return len(addresses) == 0 || !checkAddressMatch(tagRouterRule.getAddresses(), url.Ip, url.Port)
}
filterTagIsEmpty := func(invoker protocol.Invoker) bool {
return invoker.GetUrl().GetParam(constant.Tagkey, "") == ""
}
return filterInvoker(invokers, filterAddressNotMatches, filterTagIsEmpty)
}
// FAILOVER: return all Providers without any tags.
filterAddressNotMatches := func(invoker protocol.Invoker) bool {
url := invoker.GetUrl()
return len(addresses) == 0 || !checkAddressMatch(tagRouterRule.getAddresses(), url.Ip, url.Port)
}
filterTagIsEmpty := func(invoker protocol.Invoker) bool {
return invoker.GetUrl().GetParam(constant.Tagkey, "") == ""
}
return filterInvoker(invokers, filterAddressNotMatches, filterTagIsEmpty)
}
// isForceUseTag returns whether force use tag
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment