Skip to content

Commit

Permalink
fixed tests
Browse files Browse the repository at this point in the history
Signed-off-by: Shriram Sharma <[email protected]>
  • Loading branch information
shriramsharma committed Aug 9, 2024
1 parent 18133e8 commit fd4da91
Show file tree
Hide file tree
Showing 7 changed files with 15 additions and 454 deletions.
43 changes: 4 additions & 39 deletions admiral/pkg/clusters/configwriter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,16 @@ package clusters

import (
"context"
"reflect"
"strings"
"testing"

"github.com/google/go-cmp/cmp"
"github.com/google/go-cmp/cmp/cmpopts"
"github.com/istio-ecosystem/admiral/admiral/pkg/controller/common"
"github.com/istio-ecosystem/admiral/admiral/pkg/registry"
"github.com/istio-ecosystem/admiral/admiral/pkg/util"
networkingV1Alpha3 "istio.io/api/networking/v1alpha3"
"reflect"
"strings"
"testing"
)

func admiralParamsForConfigWriterTests() common.AdmiralParams {
Expand Down Expand Up @@ -63,15 +64,9 @@ func createMockServiceEntry(env string, identity string, endpointAddress string,
}

func TestGetIngressEndpoints(t *testing.T) {
<<<<<<< HEAD:admiral/pkg/registry/serviceentry_test.go
identityConfig := getSampleIdentityConfig()
expectedIngressEndpoints := []*networkingV1Alpha3.WorkloadEntry{{
Address: "a-elb.us-west-2.elb.amazonaws.com.",
=======
identityConfig := registry.GetSampleIdentityConfig()
expectedIngressEndpoints := map[string]*networkingV1Alpha3.WorkloadEntry{"cg-tax-ppd-usw2-k8s": {
Address: "internal-a96ffe9cdbb4c4d81b796cc6a37d3e1d-2123389388.us-west-2.elb.amazonaws.com.",
>>>>>>> 508caceb (MESH-5069: Operator Shards (#749)):admiral/pkg/clusters/configwriter_test.go
Locality: "us-west-2",
Ports: map[string]uint32{"http": uint32(15443)},
Labels: map[string]string{"security.istio.io/tlsMode": "istio"},
Expand Down Expand Up @@ -133,15 +128,9 @@ func TestGetServiceEntryEndpoint(t *testing.T) {
admiralParams := admiralParamsForConfigWriterTests()
common.ResetSync()
common.InitializeConfig(admiralParams)
<<<<<<< HEAD:admiral/pkg/registry/serviceentry_test.go
e2eEnv := getSampleIdentityConfigEnvironment("e2e", "ctg-taxprep-partnerdatatotax-usw2-e2e")
ingressEndpoints := []*networkingV1Alpha3.WorkloadEntry{{
Address: "a-elb.us-west-2.elb.amazonaws.com.",
=======
e2eEnv := registry.GetSampleIdentityConfigEnvironment("e2e", "ctg-taxprep-partnerdatatotax-usw2-e2e")
ingressEndpoints := map[string]*networkingV1Alpha3.WorkloadEntry{"cg-tax-ppd-usw2-k8s": {
Address: "internal-a96ffe9cdbb4c4d81b796cc6a37d3e1d-2123389388.us-west-2.elb.amazonaws.com.",
>>>>>>> 508caceb (MESH-5069: Operator Shards (#749)):admiral/pkg/clusters/configwriter_test.go
Locality: "us-west-2",
Ports: map[string]uint32{"http": uint32(15443)},
Labels: map[string]string{"security.istio.io/tlsMode": "istio"},
Expand All @@ -151,13 +140,8 @@ func TestGetServiceEntryEndpoint(t *testing.T) {
Ports: map[string]uint32{"http": uint32(15443)},
Labels: map[string]string{"security.istio.io/tlsMode": "istio"},
}}
<<<<<<< HEAD:admiral/pkg/registry/serviceentry_test.go
remoteEndpoint := []*networkingV1Alpha3.WorkloadEntry{{
Address: "a-elb.us-west-2.elb.amazonaws.com.",
=======
remoteEndpoint := &networkingV1Alpha3.WorkloadEntry{
Address: "internal-a1cbfde75adbe1fed9763495dfd07960-2123389388.us-west-2.elb.amazonaws.com.",
>>>>>>> 508caceb (MESH-5069: Operator Shards (#749)):admiral/pkg/clusters/configwriter_test.go
Locality: "us-west-2",
Ports: map[string]uint32{"http": uint32(15443)},
Labels: map[string]string{"security.istio.io/tlsMode": "istio", "type": "rollout"},
Expand All @@ -184,33 +168,19 @@ func TestGetServiceEntryEndpoint(t *testing.T) {
"Then the constructed endpoint should be a remote endpoint",
identityConfigEnvironment: e2eEnv,
ingressEndpoints: ingressEndpoints,
<<<<<<< HEAD:admiral/pkg/registry/serviceentry_test.go
operatorCluster: "cg-tax-ppd-usw2-k8s",
sourceCluster: "apigw-cx-ppd-usw2-k8s",
remoteEndpointAddress: "a-elb.us-west-2.elb.amazonaws.com.",
expectedSEEndpoints: remoteEndpoint,
=======
clientCluster: "cg-tax-ppd-usw2-k8s",
serverCluster: "apigw-cx-ppd-usw2-k8s",
expectedSEEndpoint: remoteEndpoint,
>>>>>>> 508caceb (MESH-5069: Operator Shards (#749)):admiral/pkg/clusters/configwriter_test.go
},
{
name: "Given an IdentityConfigEnvironment and ingressEndpoint, " +
"When the client cluster is the same as the server cluster" +
"Then the constructed endpoint should be a local endpoint",
identityConfigEnvironment: e2eEnv,
ingressEndpoints: ingressEndpoints,
<<<<<<< HEAD:admiral/pkg/registry/serviceentry_test.go
operatorCluster: "cg-tax-ppd-usw2-k8s",
sourceCluster: "cg-tax-ppd-usw2-k8s",
remoteEndpointAddress: "a-elb.us-west-2.elb.amazonaws.com.",
expectedSEEndpoints: localEndpoint,
=======
clientCluster: "cg-tax-ppd-usw2-k8s",
serverCluster: "cg-tax-ppd-usw2-k8s",
expectedSEEndpoint: localEndpoint,
>>>>>>> 508caceb (MESH-5069: Operator Shards (#749)):admiral/pkg/clusters/configwriter_test.go
},
}
for _, c := range testCases {
Expand All @@ -228,10 +198,6 @@ func TestGetServiceEntryEndpoint(t *testing.T) {
}
}

<<<<<<< HEAD:admiral/pkg/registry/serviceentry_test.go
func TestBuildServiceEntriesFromIdentityConfig(t *testing.T) {

=======
func TestGetExportTo(t *testing.T) {
admiralParams := admiralParamsForConfigWriterTests()
common.ResetSync()
Expand Down Expand Up @@ -320,5 +286,4 @@ func TestBuildServiceEntriesFromIdentityConfig(t *testing.T) {
}
})
}
>>>>>>> 508caceb (MESH-5069: Operator Shards (#749)):admiral/pkg/clusters/configwriter_test.go
}
206 changes: 0 additions & 206 deletions admiral/pkg/controller/admiral/dependencyproxy.go

This file was deleted.

4 changes: 4 additions & 0 deletions admiral/pkg/controller/secret/resolver/defaultresolver.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ func (r DefaultResolver) FetchKubeConfig(secretName string, kubeConfig []byte) (
type DefaultResolver struct {
}

func (r DefaultResolver) DeleteClusterFromCache(clusterName string) error {
return nil
}

func NewDefaultResolver() (SecretResolver, error) {
resolver := DefaultResolver{}
return resolver, nil
Expand Down
1 change: 1 addition & 0 deletions admiral/pkg/controller/secret/resolver/resolver.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@ package resolver

type SecretResolver interface {
FetchKubeConfig(secretName string, kubeConfig []byte) ([]byte, error)
DeleteClusterFromCache(clusterName string) error
}
8 changes: 4 additions & 4 deletions admiral/pkg/controller/secret/secretcontroller.go
Original file line number Diff line number Diff line change
Expand Up @@ -355,10 +355,10 @@ func (c *Controller) deleteMemberCluster(secretName string) {
log.Errorf("error during cluster delete: %s %v", clusterID, err)
}
delete(c.Cs.RemoteClusters, clusterID)
resolver, ok := c.secretResolver.(resolver.IDPSResolver)
if ok {
log.Infof("Deleting kubeconfig from cache for secret: %s", clusterID)
resolver.KubeConfigCache.Delete(clusterID)
log.Infof("Deleting kubeconfig from cache for secret: %s", clusterID)
err = c.secretResolver.DeleteClusterFromCache(clusterID)
if err != nil {
log.Errorf("error deleting cluster from cache: %s %v", clusterID, err)
}
}
}
Expand Down
Loading

0 comments on commit fd4da91

Please sign in to comment.