@@ -19,6 +19,7 @@ limitations under the License.
19
19
package test
20
20
21
21
import (
22
+ "fmt"
22
23
"time"
23
24
24
25
"github.com/knative/serving/pkg/apis/serving/v1alpha1"
@@ -47,6 +48,22 @@ func WaitForRouteState(client elatyped.RouteInterface, name string, inState func
47
48
})
48
49
}
49
50
51
+ // CheckRouteState verifies the status of the Route called name from client
52
+ // is in a particular state by calling `inState` and expecting `true`.
53
+ // This is the non-polling variety of WaitForRouteState
54
+ func CheckRouteState (client elatyped.RouteInterface , name string , inState func (r * v1alpha1.Route ) (bool , error )) error {
55
+ r , err := client .Get (name , metav1.GetOptions {})
56
+ if err != nil {
57
+ return err
58
+ }
59
+ if done , err := inState (r ); err != nil {
60
+ return err
61
+ } else if ! done {
62
+ return fmt .Errorf ("route %q is not in desired state: %+v" , name , r )
63
+ }
64
+ return nil
65
+ }
66
+
50
67
// WaitForConfigurationState polls the status of the Configuration called name
51
68
// from client every interval until inState returns `true` indicating it
52
69
// is done, returns an error or timeout.
@@ -60,6 +77,22 @@ func WaitForConfigurationState(client elatyped.ConfigurationInterface, name stri
60
77
})
61
78
}
62
79
80
+ // CheckConfigurationState verifies the status of the Configuration called name from client
81
+ // is in a particular state by calling `inState` and expecting `true`.
82
+ // This is the non-polling variety of WaitForConfigurationState
83
+ func CheckConfigurationState (client elatyped.ConfigurationInterface , name string , inState func (r * v1alpha1.Configuration ) (bool , error )) error {
84
+ c , err := client .Get (name , metav1.GetOptions {})
85
+ if err != nil {
86
+ return err
87
+ }
88
+ if done , err := inState (c ); err != nil {
89
+ return err
90
+ } else if ! done {
91
+ return fmt .Errorf ("configuration %q is not in desired state: %+v" , name , c )
92
+ }
93
+ return nil
94
+ }
95
+
63
96
// WaitForRevisionState polls the status of the Revision called name
64
97
// from client every interval until inState returns `true` indicating it
65
98
// is done, returns an error or timeout.
@@ -73,6 +106,22 @@ func WaitForRevisionState(client elatyped.RevisionInterface, name string, inStat
73
106
})
74
107
}
75
108
109
+ // CheckRevisionState verifies the status of the Revision called name from client
110
+ // is in a particular state by calling `inState` and expecting `true`.
111
+ // This is the non-polling variety of WaitForRevisionState
112
+ func CheckRevisionState (client elatyped.RevisionInterface , name string , inState func (r * v1alpha1.Revision ) (bool , error )) error {
113
+ r , err := client .Get (name , metav1.GetOptions {})
114
+ if err != nil {
115
+ return err
116
+ }
117
+ if done , err := inState (r ); err != nil {
118
+ return err
119
+ } else if ! done {
120
+ return fmt .Errorf ("revision %q is not in desired state: %+v" , name , r )
121
+ }
122
+ return nil
123
+ }
124
+
76
125
// WaitForIngressState polls the status of the Ingress called name
77
126
// from client every interval until inState returns `true` indicating it
78
127
// is done, returns an error or timeout.
0 commit comments