Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
gitpod-io
GitHub Repository: gitpod-io/gitpod
Path: blob/main/install/installer/pkg/components/public-api-server/deployment_test.go
2501 views
1
// Copyright (c) 2022 Gitpod GmbH. All rights reserved.
2
/// Licensed under the GNU Affero General Public License (AGPL).
3
// See License.AGPL.txt in the project root for license information.
4
5
package public_api_server
6
7
import (
8
"testing"
9
10
corev1 "k8s.io/api/core/v1"
11
"k8s.io/utils/pointer"
12
13
"github.com/stretchr/testify/require"
14
appsv1 "k8s.io/api/apps/v1"
15
)
16
17
func TestDeployment(t *testing.T) {
18
ctx := renderContextWithPublicAPI(t)
19
20
objects, err := deployment(ctx)
21
require.NoError(t, err)
22
23
require.Len(t, objects, 1, "must render only one object")
24
25
dpl := objects[0].(*appsv1.Deployment)
26
require.Len(t, dpl.Spec.Template.Spec.Containers, 2, "must render 2 containers")
27
}
28
29
func TestDeployment_ServerArguments(t *testing.T) {
30
ctx := renderContextWithPublicAPI(t)
31
32
objects, err := deployment(ctx)
33
require.NoError(t, err)
34
35
require.Len(t, objects, 1, "must render only one object")
36
37
dpl := objects[0].(*appsv1.Deployment)
38
containers := dpl.Spec.Template.Spec.Containers
39
require.Equal(t, Component, containers[0].Name)
40
41
apiContainer := containers[0]
42
require.EqualValues(t, []string{
43
"run",
44
"--config=/config.json",
45
`--json-log=true`,
46
}, apiContainer.Args)
47
48
require.Equal(t, []corev1.Volume{
49
{
50
Name: configmapVolume,
51
VolumeSource: corev1.VolumeSource{
52
ConfigMap: &corev1.ConfigMapVolumeSource{
53
LocalObjectReference: corev1.LocalObjectReference{
54
Name: Component,
55
},
56
},
57
},
58
},
59
{
60
Name: "database-config",
61
VolumeSource: corev1.VolumeSource{
62
Secret: &corev1.SecretVolumeSource{
63
SecretName: "gcp-db-creds-service-account-name",
64
},
65
},
66
},
67
{
68
Name: "ca-certificates",
69
VolumeSource: corev1.VolumeSource{
70
ConfigMap: &corev1.ConfigMapVolumeSource{
71
LocalObjectReference: corev1.LocalObjectReference{
72
Name: "gitpod-ca-bundle",
73
},
74
},
75
},
76
},
77
{
78
Name: "stripe-secret",
79
VolumeSource: corev1.VolumeSource{
80
Secret: &corev1.SecretVolumeSource{
81
SecretName: "stripe-webhook-secret",
82
Optional: pointer.Bool(true),
83
},
84
},
85
},
86
{
87
Name: "personal-access-token-signing-key",
88
VolumeSource: corev1.VolumeSource{
89
Secret: &corev1.SecretVolumeSource{
90
SecretName: "personal-access-token-signing-key",
91
Optional: pointer.Bool(true),
92
},
93
},
94
},
95
{
96
Name: "auth-pki-signing",
97
VolumeSource: corev1.VolumeSource{
98
Secret: &corev1.SecretVolumeSource{
99
SecretName: "auth-pki",
100
},
101
},
102
},
103
}, dpl.Spec.Template.Spec.Volumes, "must bind volumes")
104
}
105
106