Skip to content

Commit

Permalink
Fix mock client for DNS setup
Browse files Browse the repository at this point in the history
  • Loading branch information
johscheuer committed Oct 9, 2023
1 parent e5d30c0 commit 2ae7024
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 8 deletions.
1 change: 0 additions & 1 deletion api/v1beta2/foundationdb_process_address.go
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,6 @@ func (address ProcessAddress) String() string {
sb.WriteString(net.JoinHostPort(address.MachineAddress(), strconv.Itoa(address.Port)))

flags := address.SortedFlags()

if len(flags) > 0 {
sb.WriteString(":" + strings.Join(flags, ":"))
}
Expand Down
4 changes: 2 additions & 2 deletions controllers/cluster_controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -331,8 +331,7 @@ var _ = Describe("cluster_controller", func() {

It("should update the pods", func() {
pods := &corev1.PodList{}
err = k8sClient.List(context.TODO(), pods, getListOptions(cluster)...)
Expect(err).NotTo(HaveOccurred())
Expect(k8sClient.List(context.TODO(), pods, getListOptions(cluster)...)).NotTo(HaveOccurred())
for _, pod := range pods.Items {
env := make(map[string]string)
for _, envVar := range pod.Spec.InitContainers[0].Env {
Expand All @@ -342,6 +341,7 @@ var _ = Describe("cluster_controller", func() {
}
})
})

Context("when buggifying a pod to make it crash loop", func() {
BeforeEach(func() {
cluster.Spec.Buggify.CrashLoop = []fdbv1beta2.ProcessGroupID{"storage-1"}
Expand Down
9 changes: 4 additions & 5 deletions controllers/remove_process_groups_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,7 @@ var _ = Describe("remove_process_groups", func() {
Context("validating process removal", func() {
BeforeEach(func() {
cluster = internal.CreateDefaultCluster()
err := k8sClient.Create(context.TODO(), cluster)
Expect(err).NotTo(HaveOccurred())
Expect(k8sClient.Create(context.TODO(), cluster)).NotTo(HaveOccurred())

result, err := reconcileCluster(cluster)
Expect(err).NotTo(HaveOccurred())
Expand Down Expand Up @@ -193,15 +192,15 @@ var _ = Describe("remove_process_groups", func() {
})
})

When("Removing multiple process groups", func() {
When("removing multiple process groups", func() {
var initialCnt int
var secondRemovedProcessGroup *fdbv1beta2.ProcessGroupStatus

When("the removal mode is the default zone", func() {
BeforeEach(func() {
Expect(cluster.Spec.AutomationOptions.RemovalMode).To(BeEmpty())
initialCnt = len(cluster.Status.ProcessGroups)
secondRemovedProcessGroup = cluster.Status.ProcessGroups[1]
secondRemovedProcessGroup = cluster.Status.ProcessGroups[6]
marked, processGroup := fdbv1beta2.MarkProcessGroupForRemoval(cluster.Status.ProcessGroups, secondRemovedProcessGroup.ProcessGroupID, secondRemovedProcessGroup.ProcessClass, removedProcessGroup.Addresses[0])
Expect(marked).To(BeTrue())
Expect(processGroup).To(BeNil())
Expand Down Expand Up @@ -303,7 +302,7 @@ var _ = Describe("remove_process_groups", func() {
Expect(err).NotTo(HaveOccurred())

initialCnt = len(cluster.Status.ProcessGroups)
secondRemovedProcessGroup = cluster.Status.ProcessGroups[1]
secondRemovedProcessGroup = cluster.Status.ProcessGroups[6]
marked, processGroup := fdbv1beta2.MarkProcessGroupForRemoval(cluster.Status.ProcessGroups, secondRemovedProcessGroup.ProcessGroupID, secondRemovedProcessGroup.ProcessClass, removedProcessGroup.Addresses[0])
Expect(marked).To(BeTrue())
Expect(processGroup).To(BeNil())
Expand Down
7 changes: 7 additions & 0 deletions pkg/fdbadminclient/mock/admin_client_mock.go
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,13 @@ func (client *AdminClient) GetStatus() (*fdbv1beta2.FoundationDBStatus, error) {
for _, envVar := range container.Env {
if envVar.Name == "FDB_DNS_NAME" {
locality[fdbv1beta2.FDBLocalityDNSNameKey] = envVar.Value

if client.Cluster.UseDNSInClusterFile() {
fullAddress.StringAddress = envVar.Value
}
// TODO (johscheuer): This should be set to true. This will add additional information to the
// return address and needs some additional refactoring in the mock code.
// fullAddress.FromHostname = true
}
}
}
Expand Down

0 comments on commit 2ae7024

Please sign in to comment.