Skip to content

Commit

Permalink
[envtest]Cover ServiceAccount usage
Browse files Browse the repository at this point in the history
When the separate nova ServiceAccount is added in
e920ced test coverage was not added to
ensure the ServiceAccount is passed to the StatefulSets and Jobs created
by the controller. This is now added.
  • Loading branch information
gibizer committed Sep 15, 2023
1 parent 532bc7f commit 76605a1
Show file tree
Hide file tree
Showing 7 changed files with 15 additions and 5 deletions.
10 changes: 5 additions & 5 deletions test/functional/base_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ func GetDefaultNovaAPISpec(novaNames NovaNames) map[string]interface{} {
"cell0DatabaseHostname": "nova-cell0-db-hostname",
"keystoneAuthURL": "keystone-auth-url",
"containerImage": ContainerImage,
"serviceAccount": "nova",
"serviceAccount": "nova-sa",
"registeredCells": map[string]string{},
}
}
Expand Down Expand Up @@ -164,7 +164,7 @@ func GetDefaultNovaConductorSpec(cell CellNames) map[string]interface{} {
"secret": cell.InternalCellSecretName.Name,
"containerImage": ContainerImage,
"keystoneAuthURL": "keystone-auth-url",
"serviceAccount": "nova",
"serviceAccount": "nova-sa",
"customServiceConfig": "foo=bar",
}
}
Expand Down Expand Up @@ -284,7 +284,7 @@ func GetDefaultNovaSchedulerSpec(novaNames NovaNames) map[string]interface{} {
"cell0DatabaseHostname": "nova-cell0-db-hostname",
"keystoneAuthURL": "keystone-auth-url",
"containerImage": ContainerImage,
"serviceAccount": "nova",
"serviceAccount": "nova-sa",
"registeredCells": map[string]string{},
}
}
Expand Down Expand Up @@ -610,7 +610,7 @@ func GetDefaultNovaMetadataSpec(secretName types.NamespacedName) map[string]inte
"cellDatabaseHostname": "nova-cell-db-hostname",
"containerImage": ContainerImage,
"keystoneAuthURL": "keystone-auth-url",
"serviceAccount": "nova",
"serviceAccount": "nova-sa",
}
}

Expand Down Expand Up @@ -654,7 +654,7 @@ func GetDefaultNovaNoVNCProxySpec(cell CellNames) map[string]interface{} {
"cellDatabaseHostname": "nova-cell-db-hostname",
"containerImage": ContainerImage,
"keystoneAuthURL": "keystone-auth-url",
"serviceAccount": "nova",
"serviceAccount": "nova-sa",
"cellName": cell.CellName,
}
}
Expand Down
4 changes: 4 additions & 0 deletions test/functional/nova_controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -263,6 +263,10 @@ var _ = Describe("Nova controller", func() {
corev1.ConditionTrue,
)

mappingJob := th.GetJob(cell0.CellMappingJobName)
Expect(mappingJob.Spec.Template.Spec.ServiceAccountName).To(
Equal(novaNames.ServiceAccountName.Name))

th.SimulateJobSuccess(cell0.CellMappingJobName)

// TODO(bogdando): move to CellNames.MappingJob*
Expand Down
1 change: 1 addition & 0 deletions test/functional/nova_metadata_controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,7 @@ var _ = Describe("NovaMetadata controller", func() {
)

ss := th.GetStatefulSet(novaNames.MetadataStatefulSetName)
Expect(ss.Spec.Template.Spec.ServiceAccountName).To(Equal("nova-sa"))
Expect(int(*ss.Spec.Replicas)).To(Equal(1))
Expect(ss.Spec.Template.Spec.Volumes).To(HaveLen(2))
Expect(ss.Spec.Template.Spec.Containers).To(HaveLen(2))
Expand Down
1 change: 1 addition & 0 deletions test/functional/nova_novncproxy_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,7 @@ var _ = Describe("NovaNoVNCProxy controller", func() {
)

ss := th.GetStatefulSet(cell1.NoVNCProxyStatefulSetName)
Expect(ss.Spec.Template.Spec.ServiceAccountName).To(Equal("nova-sa"))
Expect(int(*ss.Spec.Replicas)).To(Equal(1))
Expect(ss.Spec.Template.Spec.Volumes).To(HaveLen(2))
Expect(ss.Spec.Template.Spec.Containers).To(HaveLen(2))
Expand Down
1 change: 1 addition & 0 deletions test/functional/nova_scheduler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,7 @@ var _ = Describe("NovaScheduler controller", func() {
)

ss := th.GetStatefulSet(novaNames.SchedulerStatefulSetName)
Expect(ss.Spec.Template.Spec.ServiceAccountName).To(Equal("nova-sa"))
Expect(int(*ss.Spec.Replicas)).To(Equal(1))
Expect(ss.Spec.Template.Spec.Volumes).To(HaveLen(1))
Expect(ss.Spec.Template.Spec.Containers).To(HaveLen(1))
Expand Down
1 change: 1 addition & 0 deletions test/functional/novaapi_controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,7 @@ var _ = Describe("NovaAPI controller", func() {
)

ss := th.GetStatefulSet(novaNames.APIStatefulSetName)
Expect(ss.Spec.Template.Spec.ServiceAccountName).To(Equal("nova-sa"))
Expect(int(*ss.Spec.Replicas)).To(Equal(1))
Expect(ss.Spec.Template.Spec.Volumes).To(HaveLen(2))
Expect(ss.Spec.Template.Spec.Containers).To(HaveLen(2))
Expand Down
2 changes: 2 additions & 0 deletions test/functional/novaconductor_controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,7 @@ var _ = Describe("NovaConductor controller", func() {
condition.DBSyncReadyRunningMessage,
)
job := th.GetJob(cell0.DBSyncJobName)
Expect(job.Spec.Template.Spec.ServiceAccountName).To(Equal("nova-sa"))
Expect(job.Spec.Template.Spec.Volumes).To(HaveLen(2))
Expect(job.Spec.Template.Spec.InitContainers).To(HaveLen(0))
Expect(job.Spec.Template.Spec.Containers).To(HaveLen(1))
Expand Down Expand Up @@ -284,6 +285,7 @@ var _ = Describe("NovaConductor controller", func() {
corev1.ConditionFalse,
)
ss := th.GetStatefulSet(cell0.ConductorStatefulSetName)
Expect(ss.Spec.Template.Spec.ServiceAccountName).To(Equal("nova-sa"))
Expect(ss.Spec.Template.Spec.Containers).To(HaveLen(1))
container := ss.Spec.Template.Spec.Containers[0]
Expect(container.LivenessProbe.Exec.Command).To(
Expand Down

0 comments on commit 76605a1

Please sign in to comment.