-
Notifications
You must be signed in to change notification settings - Fork 115
/
dnsname.go
77 lines (65 loc) · 2.56 KB
/
dnsname.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
package cloudingress
import (
"context"
"log"
"time"
"github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
viper "github.com/openshift/osde2e/pkg/common/concurrentviper"
"github.com/openshift/osde2e/pkg/common/config"
"github.com/openshift/osde2e/pkg/common/helper"
"github.com/openshift/osde2e/pkg/common/label"
"github.com/openshift/osde2e/pkg/common/providers/rosaprovider"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/runtime/schema"
)
// tests
var _ = ginkgo.Describe("[Suite: informing] "+TestPrefix, label.Informing, func() {
ginkgo.BeforeEach(func() {
if viper.GetBool(rosaprovider.STS) {
ginkgo.Skip("STS does not support CIO")
}
if viper.GetBool(config.Hypershift) {
ginkgo.Skip("Cloud Ingress Operator is not supported on HyperShift")
}
})
h := helper.New()
var dnsnameOriginal string
// How long to wait for IngressController changes
pollingDuration := 120 * time.Second
ginkgo.Context("publishingstrategy-dnsname", func() {
ginkgo.It("IngressController should be patched when update dnsname", func(ctx context.Context) {
ingress1, _ := getingressController(ctx, h, "default")
dnsnameOriginal = string(ingress1.Spec.Domain)
log.Print(" the Domain name \n", dnsnameOriginal)
updateDnsName(ctx, h, "foo")
ingress, _ := getingressController(ctx, h, "default")
log.Print(" The new Generation is \n", ingress.Generation)
}, pollingDuration.Seconds())
ginkgo.It("IngressController should be patched when return to the original dnsname", func(ctx context.Context) {
updateDnsName(ctx, h, dnsnameOriginal)
ingress, _ := getingressController(ctx, h, "default")
Expect(string(ingress.Spec.Domain)).To(Equal(dnsnameOriginal))
}, pollingDuration.Seconds())
})
})
func updateDnsName(ctx context.Context, h *helper.H, newName string) {
var err error
PublishingStrategyInstance, ps := getPublishingStrategy(ctx, h)
AppIngress := PublishingStrategyInstance.Spec.ApplicationIngress
for i, v := range AppIngress {
if v.Default {
AppIngress[i].DNSName = newName
}
}
PublishingStrategyInstance.Spec.ApplicationIngress = AppIngress
ps.Object, err = runtime.DefaultUnstructuredConverter.ToUnstructured(&PublishingStrategyInstance)
Expect(err).NotTo(HaveOccurred())
// Update the publishingstrategy
ps, err = h.Dynamic().
Resource(schema.GroupVersionResource{Group: "cloudingress.managed.openshift.io", Version: "v1alpha1", Resource: "publishingstrategies"}).
Namespace(OperatorNamespace).
Update(ctx, ps, metav1.UpdateOptions{})
Expect(err).NotTo(HaveOccurred())
}