Skip to content

Commit

Permalink
multitenancy fix
Browse files Browse the repository at this point in the history
  • Loading branch information
aaha97 committed Sep 26, 2024
1 parent 281229c commit 79919c3
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 33 deletions.
58 changes: 33 additions & 25 deletions tests/multitenancytests/multitenancy_infrasetting_evh_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)

func tearDownTestForIngress(t *testing.T) {
integrationtest.DelSVC(t, "default", "avisvc")
integrationtest.DelEP(t, "default", "avisvc")
func tearDownTestForIngress(t *testing.T, svcName string) {
integrationtest.DelSVC(t, "default", svcName)
integrationtest.DelEP(t, "default", svcName)
}

func verifyEvhNodeDeletionFromVsNode(g *gomega.WithT, modelName string, parentVSKey, evhVsKey cache.NamespaceName) {
Expand Down Expand Up @@ -66,7 +66,9 @@ func TestMultiTenancyWithNSAviInfraSettingEVH(t *testing.T) {
modelName := "admin/cluster--Shared-L7-EVH-1"
settingModelName := "nonadmin/cluster--Shared-L7-EVH-0"

ingresstests.SetUpTestForIngress(t, modelName)
svcName := objNameMap.GenerateName("avisvc")

ingresstests.SetUpTestForIngress(t, svcName, modelName)

vsKey := cache.NamespaceName{Namespace: "nonadmin", Name: "cluster--Shared-L7-EVH-0"}
evhKey := cache.NamespaceName{Namespace: "nonadmin", Name: lib.Encode("cluster--baz.com", lib.EVHVS)}
Expand All @@ -82,7 +84,7 @@ func TestMultiTenancyWithNSAviInfraSettingEVH(t *testing.T) {
Namespace: ns,
ClassName: ingClassName,
DnsNames: []string{"baz.com", "bar.com"},
ServiceName: "avisvc",
ServiceName: svcName,
TlsSecretDNS: map[string][]string{
secretName: {"baz.com"},
},
Expand All @@ -94,8 +96,8 @@ func TestMultiTenancyWithNSAviInfraSettingEVH(t *testing.T) {

secureVsName := "cluster--baz.com"
insecureVsName := "cluster--bar.com"
insecurePoolName := "cluster--default-bar.com_foo-" + ingressName + "-avisvc"
securePoolName := "cluster--default-baz.com_foo-" + ingressName + "-avisvc"
insecurePoolName := "cluster--default-bar.com_foo-" + ingressName + "-" + svcName
securePoolName := "cluster--default-baz.com_foo-" + ingressName + "-" + svcName
insecurePGName := "cluster--default-bar.com_foo-" + ingressName
securePGName := "cluster--default-baz.com_foo-" + ingressName

Expand Down Expand Up @@ -134,7 +136,7 @@ func TestMultiTenancyWithNSAviInfraSettingEVH(t *testing.T) {
integrationtest.DeleteSecret(secretName, ns)
integrationtest.RemoveAnnotateAKONamespaceWithInfraSetting(t, ns)
integrationtest.TeardownAviInfraSetting(t, settingName)
tearDownTestForIngress(t)
tearDownTestForIngress(t, svcName)
integrationtest.TeardownIngressClass(t, ingClassName)
waitAndVerify(t, ingClassName)
verifyEvhNodeDeletionFromVsNode(g, settingModelName, vsKey, evhKey)
Expand All @@ -152,7 +154,9 @@ func TestMultiTenancyWithIngressClassAviInfraSettingEVH(t *testing.T) {
secretName := objNameMap.GenerateName("my-secret")
modelName := "admin/cluster--Shared-L7-EVH-1"

ingresstests.SetUpTestForIngress(t, modelName)
svcName := objNameMap.GenerateName("avisvc")

ingresstests.SetUpTestForIngress(t, svcName, modelName)

settingModelName := "nonadmin/cluster--Shared-L7-EVH-" + settingName + "-0"
vsKey := cache.NamespaceName{Namespace: "nonadmin", Name: "cluster--Shared-L7-EVH-" + settingName + "-0"}
Expand All @@ -168,7 +172,7 @@ func TestMultiTenancyWithIngressClassAviInfraSettingEVH(t *testing.T) {
Namespace: ns,
ClassName: ingClassName,
DnsNames: []string{"baz.com", "bar.com"},
ServiceName: "avisvc",
ServiceName: svcName,
TlsSecretDNS: map[string][]string{
secretName: {"baz.com"},
},
Expand All @@ -180,8 +184,8 @@ func TestMultiTenancyWithIngressClassAviInfraSettingEVH(t *testing.T) {

secureVsName := "cluster--" + settingName + "-baz.com"
insecureVsName := "cluster--" + settingName + "-bar.com"
insecurePoolName := "cluster--" + settingName + "-default-bar.com_foo-" + ingressName + "-avisvc"
securePoolName := "cluster--" + settingName + "-default-baz.com_foo-" + ingressName + "-avisvc"
insecurePoolName := "cluster--" + settingName + "-default-bar.com_foo-" + ingressName + "-" + svcName
securePoolName := "cluster--" + settingName + "-default-baz.com_foo-" + ingressName + "-" + svcName
insecurePGName := "cluster--" + settingName + "-default-bar.com_foo-" + ingressName
securePGName := "cluster--" + settingName + "-default-baz.com_foo-" + ingressName

Expand Down Expand Up @@ -219,7 +223,7 @@ func TestMultiTenancyWithIngressClassAviInfraSettingEVH(t *testing.T) {
integrationtest.DeleteSecret(secretName, ns)
integrationtest.TeardownAviInfraSetting(t, settingName)
integrationtest.RemoveAnnotateAKONamespaceWithInfraSetting(t, ns)
tearDownTestForIngress(t)
tearDownTestForIngress(t, svcName)
integrationtest.TeardownIngressClass(t, ingClassName)
waitAndVerify(t, ingClassName)
verifyEvhNodeDeletionFromVsNode(g, settingModelName, vsKey, evhKey)
Expand All @@ -238,7 +242,9 @@ func TestMultiTenancyWithInfraSettingAdditionEVH(t *testing.T) {
modelName := "admin/cluster--Shared-L7-EVH-1"
settingModelName := "nonadmin/cluster--Shared-L7-EVH-0"

ingresstests.SetUpTestForIngress(t, modelName, settingModelName)
svcName := objNameMap.GenerateName("avisvc")

ingresstests.SetUpTestForIngress(t, svcName, modelName, settingModelName)

integrationtest.SetupIngressClass(t, ingClassName, lib.AviIngressController, "")
waitAndVerify(t, ingClassName)
Expand All @@ -249,7 +255,7 @@ func TestMultiTenancyWithInfraSettingAdditionEVH(t *testing.T) {
Namespace: ns,
ClassName: ingClassName,
DnsNames: []string{"baz.com", "bar.com"},
ServiceName: "avisvc",
ServiceName: svcName,
TlsSecretDNS: map[string][]string{
secretName: {"baz.com"},
},
Expand All @@ -261,8 +267,8 @@ func TestMultiTenancyWithInfraSettingAdditionEVH(t *testing.T) {

secureVsName := "cluster--baz.com"
insecureVsName := "cluster--bar.com"
insecurePoolName := "cluster--default-bar.com_foo-" + ingressName + "-avisvc"
securePoolName := "cluster--default-baz.com_foo-" + ingressName + "-avisvc"
insecurePoolName := "cluster--default-bar.com_foo-" + ingressName + "-" + svcName
securePoolName := "cluster--default-baz.com_foo-" + ingressName + "-" + svcName
insecurePGName := "cluster--default-bar.com_foo-" + ingressName
securePGName := "cluster--default-baz.com_foo-" + ingressName

Expand Down Expand Up @@ -339,7 +345,7 @@ func TestMultiTenancyWithInfraSettingAdditionEVH(t *testing.T) {
t.Fatalf("Couldn't DELETE the Ingress %v", err)
}
integrationtest.DeleteSecret(secretName, ns)
tearDownTestForIngress(t)
tearDownTestForIngress(t, svcName)
integrationtest.TeardownIngressClass(t, ingClassName)
waitAndVerify(t, ingClassName)
verifyPoolDeletionFromVsNode(g, modelName)
Expand All @@ -362,7 +368,9 @@ func TestMultiTenancyWithTenantDeannotationInNSEVH(t *testing.T) {
modelName := "admin/cluster--Shared-L7-EVH-1"
settingModelName := "nonadmin/cluster--Shared-L7-EVH-0"

ingresstests.SetUpTestForIngress(t, modelName)
svcName := objNameMap.GenerateName("avisvc")

ingresstests.SetUpTestForIngress(t, svcName, modelName)

vsKey := cache.NamespaceName{Namespace: "nonadmin", Name: "cluster--Shared-L7-EVH-0"}
evhKey := cache.NamespaceName{Namespace: "nonadmin", Name: lib.Encode("cluster--baz.com", lib.EVHVS)}
Expand All @@ -378,7 +386,7 @@ func TestMultiTenancyWithTenantDeannotationInNSEVH(t *testing.T) {
Namespace: ns,
ClassName: ingClassName,
DnsNames: []string{"baz.com", "bar.com"},
ServiceName: "avisvc",
ServiceName: svcName,
TlsSecretDNS: map[string][]string{
secretName: {"baz.com"},
},
Expand All @@ -390,8 +398,8 @@ func TestMultiTenancyWithTenantDeannotationInNSEVH(t *testing.T) {

secureVsName := "cluster--baz.com"
insecureVsName := "cluster--bar.com"
insecurePoolName := "cluster--default-bar.com_foo-" + ingressName + "-avisvc"
securePoolName := "cluster--default-baz.com_foo-" + ingressName + "-avisvc"
insecurePoolName := "cluster--default-bar.com_foo-" + ingressName + "-" + svcName
securePoolName := "cluster--default-baz.com_foo-" + ingressName + "-" + svcName
insecurePGName := "cluster--default-bar.com_foo-" + ingressName
securePGName := "cluster--default-baz.com_foo-" + ingressName

Expand Down Expand Up @@ -435,8 +443,8 @@ func TestMultiTenancyWithTenantDeannotationInNSEVH(t *testing.T) {

secureVsName = "cluster--baz.com"
insecureVsName = "cluster--bar.com"
insecurePoolName = "cluster--default-bar.com_foo-" + ingressName + "-avisvc"
securePoolName = "cluster--default-baz.com_foo-" + ingressName + "-avisvc"
insecurePoolName = "cluster--default-bar.com_foo-" + ingressName + "-" + svcName
securePoolName = "cluster--default-baz.com_foo-" + ingressName + "-" + svcName
insecurePGName = "cluster--default-bar.com_foo-" + ingressName
securePGName = "cluster--default-baz.com_foo-" + ingressName

Expand Down Expand Up @@ -472,7 +480,7 @@ func TestMultiTenancyWithTenantDeannotationInNSEVH(t *testing.T) {
t.Fatalf("Couldn't DELETE the Ingress %v", err)
}
integrationtest.DeleteSecret(secretName, ns)
tearDownTestForIngress(t)
tearDownTestForIngress(t, svcName)
integrationtest.TeardownIngressClass(t, ingClassName)
waitAndVerify(t, ingClassName)
integrationtest.TeardownAviInfraSetting(t, settingName)
Expand Down
23 changes: 15 additions & 8 deletions tests/multitenancytests/multitenancy_infrasetting_ingress_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,9 @@ func TestMultiTenancyWithNSAviInfraSettingForIngress(t *testing.T) {
secretName := objNameMap.GenerateName("my-secret")
modelName := "nonadmin/cluster--Shared-L7-1"

ingresstests.SetUpTestForIngress(t, modelName)
svcName := objNameMap.GenerateName("avisvc")

ingresstests.SetUpTestForIngress(t, svcName, modelName)

settingModelName := "nonadmin/cluster--Shared-L7-0"
integrationtest.SetupAviInfraSetting(t, settingName, "SMALL")
Expand All @@ -189,7 +191,7 @@ func TestMultiTenancyWithNSAviInfraSettingForIngress(t *testing.T) {
Namespace: ns,
ClassName: ingClassName,
DnsNames: []string{"baz.com", "bar.com"},
ServiceName: "avisvc",
ServiceName: svcName,
TlsSecretDNS: map[string][]string{
secretName: {"baz.com"},
},
Expand Down Expand Up @@ -255,7 +257,9 @@ func TestMultiTenancyWithIngressClassAviInfraSetting(t *testing.T) {
modelName := "nonadmin/cluster--Shared-L7-1"
nsSettingName := "ns-my-infrasetting"

ingresstests.SetUpTestForIngress(t, modelName)
svcName := objNameMap.GenerateName("avisvc")

ingresstests.SetUpTestForIngress(t, svcName, modelName)

settingModelName := "nonadmin/cluster--Shared-L7-" + settingName + "-0"
integrationtest.SetupAviInfraSetting(t, settingName, "SMALL")
Expand All @@ -272,7 +276,7 @@ func TestMultiTenancyWithIngressClassAviInfraSetting(t *testing.T) {
Namespace: ns,
ClassName: ingClassName,
DnsNames: []string{"baz.com", "bar.com"},
ServiceName: "avisvc",
ServiceName: svcName,
TlsSecretDNS: map[string][]string{
secretName: {"baz.com"},
},
Expand Down Expand Up @@ -335,7 +339,9 @@ func TestMultiTenancyWithInfraSettingAdditionForIngress(t *testing.T) {
secretName := objNameMap.GenerateName("my-secret")
modelName := "admin/cluster--Shared-L7-1"

ingresstests.SetUpTestForIngress(t, modelName)
svcName := objNameMap.GenerateName("avisvc")

ingresstests.SetUpTestForIngress(t, svcName, modelName)

integrationtest.SetupIngressClass(t, ingClassName, lib.AviIngressController, "")
waitAndVerify(t, ingClassName)
Expand All @@ -346,7 +352,7 @@ func TestMultiTenancyWithInfraSettingAdditionForIngress(t *testing.T) {
Namespace: ns,
ClassName: ingClassName,
DnsNames: []string{"baz.com", "bar.com"},
ServiceName: "avisvc",
ServiceName: svcName,
TlsSecretDNS: map[string][]string{
secretName: {"baz.com"},
},
Expand Down Expand Up @@ -448,8 +454,9 @@ func TestMultiTenancyWithTenantDeannotationInNSForIngress(t *testing.T) {
settingName := objNameMap.GenerateName("my-infrasetting")
secretName := objNameMap.GenerateName("my-secret")
modelName := "nonadmin/cluster--Shared-L7-1"
svcName := objNameMap.GenerateName("avisvc")

ingresstests.SetUpTestForIngress(t, modelName)
ingresstests.SetUpTestForIngress(t, svcName, modelName)

settingModelName := "nonadmin/cluster--Shared-L7-0"
integrationtest.SetupAviInfraSetting(t, settingName, "SMALL")
Expand All @@ -464,7 +471,7 @@ func TestMultiTenancyWithTenantDeannotationInNSForIngress(t *testing.T) {
Namespace: ns,
ClassName: ingClassName,
DnsNames: []string{"baz.com", "bar.com"},
ServiceName: "avisvc",
ServiceName: svcName,
TlsSecretDNS: map[string][]string{
secretName: {"baz.com"},
},
Expand Down

0 comments on commit 79919c3

Please sign in to comment.