@@ -2,7 +2,12 @@ import {
2
2
DEFAULT_SAVE_BUTTON_TIMEOUT ,
3
3
HOST_REGISTRATION_TIMEOUT ,
4
4
VALIDATE_CHANGES_TIMEOUT ,
5
+ HOSTS_DISCOVERY_TIMEOUT ,
6
+ HOST_DISCOVERY_TIMEOUT ,
5
7
} from './constants' ;
8
+
9
+ import { makeApiCall , clusterIdFromUrl } from './common' ;
10
+
6
11
import { DNS_DOMAIN_NAME , NUM_MASTERS , NUM_WORKERS } from './variables' ;
7
12
8
13
export const hostDetailSelector = ( shiftedRowIndex : number , label : string ) =>
@@ -78,6 +83,40 @@ export const waitForHostTablePopulation = (
78
83
} ) ;
79
84
} ;
80
85
86
+ export const waitForHostsSubnet = ( cy : Cypress . cy ) => {
87
+ // wait until hosts subnet populated in the cluster details
88
+ cy . get ( '#form-input-hostSubnet-field' )
89
+ . find ( 'option' , { timeout : HOST_DISCOVERY_TIMEOUT } )
90
+ . should ( ( $els ) => {
91
+ expect ( $els . length ) . to . be . gt ( 0 ) ;
92
+ } )
93
+ . and ( ( $els ) => {
94
+ expect ( $els [ 0 ] ) . not . to . have . text ( 'No subnets available' ) ;
95
+ } ) ;
96
+ } ;
97
+
98
+ export const waitForHostsToBeReady = (
99
+ cy : Cypress . cy ,
100
+ numMasters = NUM_MASTERS ,
101
+ numWorkers = NUM_WORKERS ,
102
+ ) => {
103
+ // wait until hosts are getting to pending input state
104
+ for ( let i = 2 ; i <= numMasters + numWorkers + 1 ; i ++ ) {
105
+ cy . contains ( hostDetailSelector ( i , 'Status' ) , 'Ready' , {
106
+ timeout : HOSTS_DISCOVERY_TIMEOUT ,
107
+ } ) ;
108
+ }
109
+ } ;
110
+
111
+ export const setClusterSubnetCidr = ( cy : Cypress . cy ) => {
112
+ // select the first subnet from list
113
+ cy . get ( '#form-input-hostSubnet-field' )
114
+ . find ( 'option' )
115
+ . then ( ( $els ) => $els . get ( 1 ) . setAttribute ( 'selected' , 'selected' ) )
116
+ . parent ( )
117
+ . trigger ( 'change' ) ;
118
+ } ;
119
+
81
120
export const setHostsRole = (
82
121
cy : Cypress . cy ,
83
122
masterHostnamePrefix : string ,
@@ -100,3 +139,117 @@ export const setHostsRole = (
100
139
cy . get ( `ul[aria-labelledby=${ toggleSelector } ] > li#worker` ) . click ( ) ;
101
140
}
102
141
} ;
142
+
143
+ export const getDhcpVipState = ( cy : Cypress . cy ) => {
144
+ return new Cypress . Promise ( ( resolve , reject ) => {
145
+ clusterIdFromUrl ( cy ) . then ( ( id ) => {
146
+ const readDhcpAllocation = ( response ) => {
147
+ resolve ( response . body . vip_dhcp_allocation ) ;
148
+ } ;
149
+
150
+ makeApiCall ( `/api/assisted-install/v1/clusters/${ id } ` , 'GET' , readDhcpAllocation ) ;
151
+ } ) ;
152
+ } ) ;
153
+ } ;
154
+
155
+ export const disableDhcpVip = ( cy : Cypress . cy , apiVip = null , ingressVip = null ) => {
156
+ getDhcpVipState ( cy ) . then ( ( state ) => {
157
+ if ( state ) {
158
+ cy . get ( '#form-input-vipDhcpAllocation-field' ) . click ( ) ;
159
+ }
160
+ } ) ;
161
+
162
+ if ( apiVip ) {
163
+ cy . get ( '#form-input-apiVip-field' ) . clear ( ) ;
164
+ cy . get ( '#form-input-apiVip-field' ) . type ( apiVip ) ;
165
+ }
166
+ if ( ingressVip ) {
167
+ cy . get ( '#form-input-ingressVip-field' ) . clear ( ) ;
168
+ cy . get ( '#form-input-ingressVip-field' ) . type ( ingressVip ) ;
169
+ }
170
+ } ;
171
+
172
+ export const enableDhcpVip = ( cy : Cypress . cy ) => {
173
+ getDhcpVipState ( cy ) . then ( ( state ) => {
174
+ if ( ! state ) {
175
+ cy . get ( '#form-input-vipDhcpAllocation-field' ) . click ( ) ;
176
+ }
177
+ } ) ;
178
+ } ;
179
+
180
+ export const getAdvancedNetworkingState = ( cy : Cypress . cy ) => {
181
+ return new Cypress . Promise ( ( resolve , reject ) => {
182
+ clusterIdFromUrl ( cy ) . then ( ( id ) => {
183
+ const advancedNetworkingState = ( response ) => {
184
+ // the advanced networking checkbox in the GUI is off when the
185
+ // settings are the following hardcoded values:
186
+ // clusterCidr = 10.128.0.0/14
187
+ // networkPrefix = 23
188
+ // serviceCidr = 172.30.0.0/16
189
+ if (
190
+ response . body . service_network_cidr == '172.30.0.0/16' &&
191
+ response . body . cluster_network_cidr == '10.128.0.0/14' &&
192
+ response . body . cluster_network_host_prefix == '23'
193
+ ) {
194
+ resolve ( false ) ;
195
+ } else {
196
+ resolve ( true ) ; // GUI shows advanced networking enabled
197
+ }
198
+ } ;
199
+
200
+ makeApiCall ( `/api/assisted-install/v1/clusters/${ id } ` , 'GET' , advancedNetworkingState ) ;
201
+ } ) ;
202
+ } ) ;
203
+ } ;
204
+
205
+ export const enableAdvancedNetworking = (
206
+ cy : Cypress . cy ,
207
+ clusterCidr = null ,
208
+ networkPrefix = null ,
209
+ serviceCidr = null ,
210
+ ) => {
211
+ getAdvancedNetworkingState ( cy ) . then ( ( state ) => {
212
+ if ( ! state ) {
213
+ cy . get ( '#useAdvancedNetworking' ) . click ( ) ;
214
+ cy . get ( '#useAdvancedNetworking' ) . should ( 'have.prop' , 'checked' ) ;
215
+ }
216
+ } ) ;
217
+ cy . get ( '#form-input-serviceNetworkCidr-field' ) . click ( ) ; // just to scroll to it
218
+ cy . get ( '#form-input-clusterNetworkCidr-field' ) . should ( 'be.visible' ) ;
219
+ cy . get ( '#form-input-clusterNetworkHostPrefix-field' ) . should ( 'be.visible' ) ;
220
+ cy . get ( '#form-input-serviceNetworkCidr-field' ) . should ( 'be.visible' ) ;
221
+
222
+ if ( clusterCidr ) {
223
+ cy . get ( '#form-input-clusterNetworkCidr-field' ) . clear ( ) ;
224
+ cy . get ( '#form-input-clusterNetworkCidr-field' ) . type ( clusterCidr ) ;
225
+ }
226
+
227
+ if ( serviceCidr ) {
228
+ cy . get ( '#form-input-serviceNetworkCidr-field' ) . clear ( ) ;
229
+ cy . get ( '#form-input-serviceNetworkCidr-field' ) . type ( serviceCidr ) ;
230
+ }
231
+
232
+ if ( networkPrefix ) {
233
+ cy . get ( '#form-input-clusterNetworkHostPrefix-field' ) . clear ( ) ;
234
+ cy . get ( '#form-input-clusterNetworkHostPrefix-field' ) . type ( networkPrefix ) ;
235
+ }
236
+ } ;
237
+
238
+ export const getDomains = ( cy : Cypress . cy ) => {
239
+ return new Cypress . Promise ( ( resolve , reject ) => {
240
+ const readDomains = ( response ) => {
241
+ resolve ( response . body [ 0 ] . provider ) ;
242
+ } ;
243
+
244
+ makeApiCall ( `/api/assisted-install/v1/domains` , 'GET' , readDomains ) ;
245
+ } ) ;
246
+ } ;
247
+
248
+ export const enableRoute53 = ( cy : Cypress . cy ) => {
249
+ cy . get ( '#form-input-useRedHatDnsService-field' ) . click ( ) ;
250
+ getDomains ( cy ) . then ( ( provider ) => {
251
+ if ( provider ) {
252
+ cy . get ( '#form-input-baseDnsDomain-field' ) . contains ( provider ) ;
253
+ }
254
+ } ) ;
255
+ } ;
0 commit comments