Skip to content

Commit 013aa09

Browse files
Merge pull request #1388 from awgreene/test-2-apiservices
Add e2e test for multiple APIServices on a pod
2 parents f35b313 + 0a1d845 commit 013aa09

File tree

1 file changed

+123
-0
lines changed

1 file changed

+123
-0
lines changed

test/e2e/csv_e2e_test.go

Lines changed: 123 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3521,6 +3521,129 @@ func deleteLegacyAPIResources(t *testing.T, desc v1alpha1.APIServiceDescription)
35213521
require.NoError(t, err)
35223522
}
35233523

3524+
func TestMultipleAPIServicesOnSinglePod(t *testing.T) {
3525+
defer cleaner.NotifyTestComplete(t, true)
3526+
3527+
c := newKubeClient(t)
3528+
crc := newCRClient(t)
3529+
3530+
// Create the deployment that both APIServices will be deployed to.
3531+
depName := genName("hat-server")
3532+
3533+
// Define the expected mock APIService settings.
3534+
version := "v1alpha1"
3535+
apiService1Group := fmt.Sprintf("hats.%s.redhat.com", genName(""))
3536+
apiService1GroupVersion := strings.Join([]string{apiService1Group, version}, "/")
3537+
apiService1Kinds := []string{"fedora"}
3538+
apiService1Name := strings.Join([]string{version, apiService1Group}, ".")
3539+
3540+
apiService2Group := fmt.Sprintf("hats.%s.redhat.com", genName(""))
3541+
apiService2GroupVersion := strings.Join([]string{apiService2Group, version}, "/")
3542+
apiService2Kinds := []string{"fez"}
3543+
apiService2Name := strings.Join([]string{version, apiService2Group}, ".")
3544+
3545+
// Create the deployment spec with the two APIServices.
3546+
mockGroupVersionKinds := []mockGroupVersionKind{
3547+
mockGroupVersionKind{
3548+
depName,
3549+
apiService1GroupVersion,
3550+
apiService1Kinds,
3551+
5443,
3552+
},
3553+
mockGroupVersionKind{
3554+
depName,
3555+
apiService2GroupVersion,
3556+
apiService2Kinds,
3557+
5444,
3558+
},
3559+
}
3560+
depSpec := newMockExtServerDeployment(depName, mockGroupVersionKinds)
3561+
3562+
// Create the CSV.
3563+
strategy := v1alpha1.StrategyDetailsDeployment{
3564+
DeploymentSpecs: []v1alpha1.StrategyDeploymentSpec{
3565+
{
3566+
Name: depName,
3567+
Spec: depSpec,
3568+
},
3569+
},
3570+
}
3571+
3572+
// Update the owned APIServices two include the two APIServices.
3573+
owned := []v1alpha1.APIServiceDescription{
3574+
v1alpha1.APIServiceDescription{
3575+
Name: apiService1Name,
3576+
Group: apiService1Group,
3577+
Version: version,
3578+
Kind: apiService1Kinds[0],
3579+
DeploymentName: depName,
3580+
ContainerPort: int32(5443),
3581+
DisplayName: apiService1Kinds[0],
3582+
Description: fmt.Sprintf("A %s", apiService1Kinds[0]),
3583+
},
3584+
v1alpha1.APIServiceDescription{
3585+
Name: apiService2Name,
3586+
Group: apiService2Group,
3587+
Version: version,
3588+
Kind: apiService2Kinds[0],
3589+
DeploymentName: depName,
3590+
ContainerPort: int32(5444),
3591+
DisplayName: apiService2Kinds[0],
3592+
Description: fmt.Sprintf("A %s", apiService2Kinds[0]),
3593+
},
3594+
}
3595+
3596+
csv := v1alpha1.ClusterServiceVersion{
3597+
Spec: v1alpha1.ClusterServiceVersionSpec{
3598+
MinKubeVersion: "0.0.0",
3599+
InstallModes: []v1alpha1.InstallMode{
3600+
{
3601+
Type: v1alpha1.InstallModeTypeOwnNamespace,
3602+
Supported: true,
3603+
},
3604+
{
3605+
Type: v1alpha1.InstallModeTypeSingleNamespace,
3606+
Supported: true,
3607+
},
3608+
{
3609+
Type: v1alpha1.InstallModeTypeMultiNamespace,
3610+
Supported: true,
3611+
},
3612+
{
3613+
Type: v1alpha1.InstallModeTypeAllNamespaces,
3614+
Supported: true,
3615+
},
3616+
},
3617+
InstallStrategy: v1alpha1.NamedInstallStrategy{
3618+
StrategyName: v1alpha1.InstallStrategyNameDeployment,
3619+
StrategySpec: strategy,
3620+
},
3621+
APIServiceDefinitions: v1alpha1.APIServiceDefinitions{
3622+
Owned: owned,
3623+
},
3624+
},
3625+
}
3626+
csv.SetName("csv-hat-1")
3627+
csv.SetNamespace(testNamespace)
3628+
3629+
// Create the APIService CSV
3630+
cleanupCSV, err := createCSV(t, c, crc, csv, testNamespace, false, false)
3631+
require.NoError(t, err)
3632+
defer cleanupCSV()
3633+
3634+
_, err = fetchCSV(t, crc, csv.Name, testNamespace, csvSucceededChecker)
3635+
require.NoError(t, err)
3636+
3637+
// Check that the APIService caBundles are equal
3638+
apiService1, err := c.GetAPIService(apiService1Name)
3639+
require.NoError(t, err)
3640+
3641+
apiService2, err := c.GetAPIService(apiService2Name)
3642+
require.NoError(t, err)
3643+
3644+
require.Equal(t, apiService1.Spec.CABundle, apiService2.Spec.CABundle)
3645+
}
3646+
35243647
func createLegacyAPIResources(t *testing.T, csv *v1alpha1.ClusterServiceVersion, desc v1alpha1.APIServiceDescription) {
35253648
c := newKubeClient(t)
35263649

0 commit comments

Comments
 (0)