88 o "github.com/onsi/gomega"
99 monitoringv1 "github.com/prometheus-operator/prometheus-operator/pkg/apis/monitoring/v1"
1010 prometheusoperatorv1client "github.com/prometheus-operator/prometheus-operator/pkg/client/versioned/typed/monitoring/v1"
11+ runtimeclient "sigs.k8s.io/controller-runtime/pkg/client"
12+ "sigs.k8s.io/controller-runtime/pkg/client/config"
1113
1214 "k8s.io/apimachinery/pkg/api/errors"
1315 "k8s.io/apimachinery/pkg/api/meta"
@@ -22,6 +24,7 @@ import (
2224 configv1client "github.com/openshift/client-go/config/clientset/versioned/typed/config/v1"
2325
2426 "github.com/openshift/cluster-version-operator/pkg/external"
27+ proposalv1alpha1 "github.com/openshift/cluster-version-operator/pkg/proposal/api/v1alpha1"
2528 "github.com/openshift/cluster-version-operator/test/util"
2629)
2730
@@ -31,6 +34,7 @@ var _ = g.Describe(`[Jira:"Cluster Version Operator"] cluster-version-operator`,
3134 c * rest.Config
3235 configClient * configv1client.ConfigV1Client
3336 monitoringClient * prometheusoperatorv1client.MonitoringV1Client
37+ rtClient runtimeclient.Client
3438 err error
3539
3640 ctx = context .TODO ()
@@ -46,6 +50,9 @@ var _ = g.Describe(`[Jira:"Cluster Version Operator"] cluster-version-operator`,
4650 monitoringClient , err = prometheusoperatorv1client .NewForConfig (c )
4751 o .Expect (err ).To (o .BeNil ())
4852
53+ rtClient , err = runtimeclient .New (config .GetConfigOrDie (), runtimeclient.Options {})
54+ o .Expect (err ).To (o .BeNil ())
55+
4956 util .SkipIfNotTechPreviewNoUpgrade (ctx , c )
5057 o .Expect (util .SkipIfHypershift (ctx , c )).To (o .BeNil ())
5158 o .Expect (util .SkipIfMicroshift (ctx , c )).To (o .BeNil ())
@@ -238,4 +245,31 @@ var _ = g.Describe(`[Jira:"Cluster Version Operator"] cluster-version-operator`,
238245 o .Expect (err ).NotTo (o .HaveOccurred ())
239246 }
240247 })
248+
249+ g .It ("should create proposals" , g .Label ("Serial" ), oteginkgo .Informing (), func () {
250+ o .Expect (util .SkipIfNetworkRestricted (ctx , c , util .FauxinnatiAPIURL )).To (o .BeNil ())
251+
252+ cv , err := configClient .ClusterVersions ().Get (ctx , external .DefaultClusterVersionName , metav1.GetOptions {})
253+ o .Expect (err ).NotTo (o .HaveOccurred ())
254+
255+ g .By ("Using fauxinnati as the upstream and its simple channel" )
256+ cv .Spec .Upstream = util .FauxinnatiAPIURL
257+ cv .Spec .Channel = "simple"
258+
259+ _ , err = configClient .ClusterVersions ().Update (ctx , cv , metav1.UpdateOptions {})
260+ o .Expect (err ).NotTo (o .HaveOccurred ())
261+ needRecover = true
262+
263+ // TODO: move to its own file
264+ g .By ("Checking if the proposal are created" )
265+ o .Expect (wait .PollUntilContextTimeout (ctx , 30 * time .Second , 5 * time .Minute , true , func (ctx context.Context ) (done bool , err error ) {
266+ proposals := proposalv1alpha1.ProposalList {}
267+ err = rtClient .List (ctx , & proposals , runtimeclient .InNamespace (external .DefaultCVONamespace ))
268+ o .Expect (err ).NotTo (o .HaveOccurred ())
269+ if len (proposals .Items ) == 0 {
270+ return false , nil
271+ }
272+ return true , nil
273+ })).NotTo (o .HaveOccurred (), "no conditional update risk from alert found in ClusterVersion's status" )
274+ })
241275})
0 commit comments