Skip to content

Commit

Permalink
Add new test cases. (#204)
Browse files Browse the repository at this point in the history
Signed-off-by: GitHub <[email protected]>
  • Loading branch information
xuezhaojun authored Jun 27, 2024
1 parent 9fba329 commit ac07a46
Showing 1 changed file with 60 additions and 1 deletion.
61 changes: 60 additions & 1 deletion pkg/proxyagent/agent/agent_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -811,8 +811,67 @@ func TestNewAgentAddon(t *testing.T) {
enableKubeApiProxy: true,
verifyManifests: func(t *testing.T, manifests []runtime.Object) {
assert.Len(t, manifests, len(expectedManifestNames))
expectedManifestNames[5] = "addon-test"
newexpectedManifestNames := []string{}
newexpectedManifestNames = append(newexpectedManifestNames, expectedManifestNames...)
newexpectedManifestNames[5] = "addon-test"
assert.ElementsMatch(t, newexpectedManifestNames, manifestNames(manifests))
},
},
{
name: "with addon deployment config using customized variables",
cluster: newCluster(clusterName, true),
addon: func() *addonv1alpha1.ManagedClusterAddOn {
addOn := newAddOn(addOnName, clusterName)
addOn.Status.ConfigReferences = []addonv1alpha1.ConfigReference{
newManagedProxyConfigReference(managedProxyConfigName),
newAddOndDeploymentConfigReference(addOndDeployConfigName, clusterName),
}
return addOn
}(),
managedProxyConfig: newManagedProxyConfig(managedProxyConfigName, proxyv1alpha1.EntryPointTypePortForward),
addOndDeploymentConfigs: []runtime.Object{
func() *addonv1alpha1.AddOnDeploymentConfig {
config := newAddOnDeploymentConfig(addOndDeployConfigName, clusterName)
config.Spec.CustomizedVariables = []addonv1alpha1.CustomizedVariable{
{
Name: "replicas",
Value: "10",
},
}
return config
}(),
},
v1CSRSupported: true,
enableKubeApiProxy: true,
verifyManifests: func(t *testing.T, manifests []runtime.Object) {
assert.Len(t, manifests, len(expectedManifestNames))
assert.ElementsMatch(t, expectedManifestNames, manifestNames(manifests))
agentDeploy := getAgentDeployment(manifests)
assert.NotNil(t, agentDeploy)
assert.Equal(t, int32(10), *agentDeploy.Spec.Replicas)
},
},
{
name: "with addon deployment config using a customized serviceDomain",
cluster: newCluster(clusterName, true),
addon: func() *addonv1alpha1.ManagedClusterAddOn {
addOn := newAddOn(addOnName, clusterName)
addOn.Status.ConfigReferences = []addonv1alpha1.ConfigReference{
newManagedProxyConfigReference(managedProxyConfigName),
newAddOndDeploymentConfigReference(addOndDeployConfigName, clusterName),
}
return addOn
}(),
managedProxyConfig: newManagedProxyConfig(managedProxyConfigName, proxyv1alpha1.EntryPointTypePortForward),
addOndDeploymentConfigs: []runtime.Object{newAddOnDeploymentConfigWithCustomizedServiceDomain(addOndDeployConfigName, clusterName, "svc.test.com")},
v1CSRSupported: true,
enableKubeApiProxy: true,
verifyManifests: func(t *testing.T, manifests []runtime.Object) {
assert.Len(t, manifests, len(expectedManifestNames))
assert.ElementsMatch(t, expectedManifestNames, manifestNames(manifests))
externalNameService := getKubeAPIServerExternalNameService(manifests)
assert.NotNil(t, externalNameService)
assert.Equal(t, "kubernetes.default.svc.test.com", externalNameService.Spec.ExternalName)
},
},
}
Expand Down

0 comments on commit ac07a46

Please sign in to comment.