Skip to content

Commit

Permalink
Updating integration tests
Browse files Browse the repository at this point in the history
  • Loading branch information
vinaygonuguntla committed Aug 4, 2022
1 parent 42e7b43 commit bf8c151
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 9 deletions.
2 changes: 2 additions & 0 deletions admiral/pkg/clusters/serviceentry.go
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,8 @@ func modifyServiceEntryForNewServiceOrPod(event admiral.EventType, env string, s
}

remoteRegistry.AdmiralCache.IdentityClusterCache.Put(sourceIdentity, rc.ClusterID, rc.ClusterID)
// workload selector cache is needed for routingPolicy's envoyFilter to match the dependency and apply to the right POD
// using service labels
workloadSelectors := GetServiceSelector(rc.ClusterID, serviceInstance)
if workloadSelectors != nil {
remoteRegistry.AdmiralCache.WorkloadSelectorCache.PutMap(sourceIdentity+rc.ClusterID, workloadSelectors)
Expand Down
13 changes: 10 additions & 3 deletions admiral/pkg/clusters/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,8 @@ type AdmiralCache struct {
GlobalTrafficCache *globalTrafficCache //The cache needs to live in the handler because it needs access to deployments
DependencyNamespaceCache *common.SidecarEgressMap
SeClusterCache *common.MapOfMaps
RoutingPolicyCache *routingPolicyCache
RoutingPolicyFilterCache *routingPolicyFilterCache
RoutingPolicyCache *routingPolicyCache
argoRolloutsEnabled bool
}

Expand All @@ -71,14 +71,21 @@ func NewRemoteRegistry(ctx context.Context, params common.AdmiralParams) *Remote
gtpCache := &globalTrafficCache{}
gtpCache.identityCache = make(map[string]*v1.GlobalTrafficPolicy)
gtpCache.mutex = &sync.Mutex{}

rpFilterCache := &routingPolicyFilterCache{}
rpFilterCache.filterCache = make(map[string]map[string]map[string]string)
rpFilterCache.mutex = &sync.Mutex{}
rpCache := &routingPolicyCache{}
rpCache.identityCache = make(map[string]*v1.RoutingPolicy)
rpCache.mutex = &sync.Mutex{}
admiralCache := &AdmiralCache{
IdentityClusterCache: common.NewMapOfMaps(),
CnameClusterCache: common.NewMapOfMaps(),
CnameDependentClusterCache: common.NewMapOfMaps(),
ClusterLocalityCache: common.NewMapOfMaps(),
IdentityDependencyCache: common.NewMapOfMaps(),
WorkloadSelectorCache: common.NewMapOfMaps(),
RoutingPolicyFilterCache: rpFilterCache,
RoutingPolicyCache: rpCache,
DependencyNamespaceCache: common.NewSidecarEgressMap(),
CnameIdentityCache: &sync.Map{},
SubsetServiceEntryIdentityCache: &sync.Map{},
Expand Down Expand Up @@ -292,7 +299,7 @@ func (r *routingPolicyFilterCache) Delete(identityEnvKey string) {
func (r RoutingPolicyHandler) Added(obj *v1.RoutingPolicy) {
if common.GetEnableRoutingPolicy() {
if common.ShouldIgnoreResource(obj.ObjectMeta) {
log.Infof(LogErrFormat, "success", "routingpolicy", obj.Name, obj.ClusterName, "Ignored the RoutingPolicy because of the annotation")
log.Infof(LogFormat, "success", "routingpolicy", obj.Name, obj.ClusterName, "Ignored the RoutingPolicy because of the annotation")
return
}
dependents := getDependents(obj, r)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,6 @@ spec:
- --sync_period
- 10s
- --argo_rollouts=true
- --envoy_filter_version
- "1.13"
name: admiral
2 changes: 1 addition & 1 deletion tests/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,6 @@ fi
./test3.sh "grpc-client" "sample" "grpc-server" $install_dir
./test4.sh "webapp" "sample"
# Testing routing policy
./test6.sh "sample" $install_dir
./test6.sh "sample" "1.13" $install_dir

./cleanup.sh $istio_version
14 changes: 9 additions & 5 deletions tests/test6.sh
Original file line number Diff line number Diff line change
@@ -1,19 +1,21 @@
#!/bin/bash

[ $# -lt 2 ] && { echo "Usage: $0 <source_ns> <install_dir>" ; exit 1; }
[ $# -lt 3 ] && { echo "Usage: $0 <source_ns> <envoy_version> <install_dir>" ; exit 1; }

deploy_and_test() {
source_ns=$1
install_dir=$2
envoy_version=$2
install_dir=$3

#Install the routing policy

kubectl apply -f $install_dir/yaml/rp.yaml -n $source_ns


sleep 15

#Test, expecting envoy filter to be present in istio-system namespace
output=($(kubectl get envoyfilters.networking.istio.io -n istio-system | grep dynamicrouting))
#Test, expecting envoy filter with correct version to be present in istio-system namespace
output=($(kubectl get envoyfilters.networking.istio.io -n istio-system | grep dynamicrouting| grep $envoy_version))


if [[ "$output" != "" ]]; then
Expand All @@ -22,13 +24,15 @@ deploy_and_test() {
else
echo "FAIL" . $output
kubectl get envoyfilters -n istio-system
kubectl get pod --all-namespaces
kubectl get dependencies --all-namespaces
return 1
fi
kubectl delete -f $install_dir/yaml/rp.yaml -n $source_ns
}

export -f deploy_and_test
timeout 90s bash -c "until deploy_and_test $1 $2 ; do sleep 2; done"
timeout 90s bash -c "until deploy_and_test $1 $2 $3; do sleep 2; done"
if [[ $? -eq 124 ]]
then
exit 1
Expand Down

0 comments on commit bf8c151

Please sign in to comment.