Skip to content

Commit ac07a46

Browse files
authored
Add new test cases. (#204)
Signed-off-by: GitHub <noreply@github.com>
1 parent 9fba329 commit ac07a46

File tree

1 file changed

+60
-1
lines changed

1 file changed

+60
-1
lines changed

pkg/proxyagent/agent/agent_test.go

+60-1
Original file line numberDiff line numberDiff line change
@@ -811,8 +811,67 @@ func TestNewAgentAddon(t *testing.T) {
811811
enableKubeApiProxy: true,
812812
verifyManifests: func(t *testing.T, manifests []runtime.Object) {
813813
assert.Len(t, manifests, len(expectedManifestNames))
814-
expectedManifestNames[5] = "addon-test"
814+
newexpectedManifestNames := []string{}
815+
newexpectedManifestNames = append(newexpectedManifestNames, expectedManifestNames...)
816+
newexpectedManifestNames[5] = "addon-test"
817+
assert.ElementsMatch(t, newexpectedManifestNames, manifestNames(manifests))
818+
},
819+
},
820+
{
821+
name: "with addon deployment config using customized variables",
822+
cluster: newCluster(clusterName, true),
823+
addon: func() *addonv1alpha1.ManagedClusterAddOn {
824+
addOn := newAddOn(addOnName, clusterName)
825+
addOn.Status.ConfigReferences = []addonv1alpha1.ConfigReference{
826+
newManagedProxyConfigReference(managedProxyConfigName),
827+
newAddOndDeploymentConfigReference(addOndDeployConfigName, clusterName),
828+
}
829+
return addOn
830+
}(),
831+
managedProxyConfig: newManagedProxyConfig(managedProxyConfigName, proxyv1alpha1.EntryPointTypePortForward),
832+
addOndDeploymentConfigs: []runtime.Object{
833+
func() *addonv1alpha1.AddOnDeploymentConfig {
834+
config := newAddOnDeploymentConfig(addOndDeployConfigName, clusterName)
835+
config.Spec.CustomizedVariables = []addonv1alpha1.CustomizedVariable{
836+
{
837+
Name: "replicas",
838+
Value: "10",
839+
},
840+
}
841+
return config
842+
}(),
843+
},
844+
v1CSRSupported: true,
845+
enableKubeApiProxy: true,
846+
verifyManifests: func(t *testing.T, manifests []runtime.Object) {
847+
assert.Len(t, manifests, len(expectedManifestNames))
815848
assert.ElementsMatch(t, expectedManifestNames, manifestNames(manifests))
849+
agentDeploy := getAgentDeployment(manifests)
850+
assert.NotNil(t, agentDeploy)
851+
assert.Equal(t, int32(10), *agentDeploy.Spec.Replicas)
852+
},
853+
},
854+
{
855+
name: "with addon deployment config using a customized serviceDomain",
856+
cluster: newCluster(clusterName, true),
857+
addon: func() *addonv1alpha1.ManagedClusterAddOn {
858+
addOn := newAddOn(addOnName, clusterName)
859+
addOn.Status.ConfigReferences = []addonv1alpha1.ConfigReference{
860+
newManagedProxyConfigReference(managedProxyConfigName),
861+
newAddOndDeploymentConfigReference(addOndDeployConfigName, clusterName),
862+
}
863+
return addOn
864+
}(),
865+
managedProxyConfig: newManagedProxyConfig(managedProxyConfigName, proxyv1alpha1.EntryPointTypePortForward),
866+
addOndDeploymentConfigs: []runtime.Object{newAddOnDeploymentConfigWithCustomizedServiceDomain(addOndDeployConfigName, clusterName, "svc.test.com")},
867+
v1CSRSupported: true,
868+
enableKubeApiProxy: true,
869+
verifyManifests: func(t *testing.T, manifests []runtime.Object) {
870+
assert.Len(t, manifests, len(expectedManifestNames))
871+
assert.ElementsMatch(t, expectedManifestNames, manifestNames(manifests))
872+
externalNameService := getKubeAPIServerExternalNameService(manifests)
873+
assert.NotNil(t, externalNameService)
874+
assert.Equal(t, "kubernetes.default.svc.test.com", externalNameService.Spec.ExternalName)
816875
},
817876
},
818877
}

0 commit comments

Comments
 (0)