|
| 1 | +import { operatorNamespaces, operatorSubscriptions } from '../../constants'; |
| 2 | +import { |
| 3 | + createKnativeEventingUsingCLI, |
| 4 | + createKnativeKafkaUsingCLI, |
| 5 | + createKnativeServingUsingCLI, |
| 6 | +} from './knativeSubscriptions'; |
| 7 | + |
| 8 | +// export const checkRedHatIntegrationCamelKOperatorStatus = (retries: number = 5) => { |
| 9 | +// const namespace = operatorNamespaces.RedHatIntegrationCamelK; |
| 10 | +// const resourceName = 'camel-k-operator'; |
| 11 | +// if (retries === 0) { |
| 12 | +// throw new Error('Failed to install Red Hat Camel K Operator - Pod timeout'); |
| 13 | +// } else { |
| 14 | +// cy.exec( |
| 15 | +// `oc wait --for=condition=ready pod -l name=${resourceName} -n ${namespace} --timeout=300s`, |
| 16 | +// { |
| 17 | +// failOnNonZeroExit: false, |
| 18 | +// }, |
| 19 | +// ).then(function (result) { |
| 20 | +// if (result.stdout.includes('condition met')) { |
| 21 | +// cy.log(`Success: ${result.stdout}`); |
| 22 | +// } else { |
| 23 | +// cy.log(result.stderr); |
| 24 | +// cy.wait(30000); |
| 25 | +// checkRedHatIntegrationCamelKOperatorStatus(retries - 1); |
| 26 | +// } |
| 27 | +// }); |
| 28 | +// } |
| 29 | +// }; |
| 30 | + |
| 31 | +// export const checkWebterminalOperatorStatus = (retries: number = 5) => { |
| 32 | +// const namespace = operatorNamespaces.WebTerminalOperator; |
| 33 | +// const resourceName = 'web-terminal-controller'; |
| 34 | +// if (retries === 0) { |
| 35 | +// throw new Error('Failed to install Webterminal Operator - Pod timeout'); |
| 36 | +// } else { |
| 37 | +// cy.exec( |
| 38 | +// `oc wait --for=condition=ready pod -l app.kubernetes.io/name=${resourceName} -n ${namespace} --timeout=300s`, |
| 39 | +// { |
| 40 | +// failOnNonZeroExit: false, |
| 41 | +// }, |
| 42 | +// ).then(function (result) { |
| 43 | +// if (result.stdout.includes('condition met')) { |
| 44 | +// cy.log(`Success: ${result.stdout}`); |
| 45 | +// } else { |
| 46 | +// cy.log(result.stderr); |
| 47 | +// cy.wait(30000); |
| 48 | +// checkWebterminalOperatorStatus(retries - 1); |
| 49 | +// } |
| 50 | +// }); |
| 51 | +// } |
| 52 | +// }; |
| 53 | + |
| 54 | +// export const checkDevWorkspaceOperatorStatus = (retries: number = 5) => { |
| 55 | +// const namespace = operatorNamespaces.DevWorkspaceOperator; |
| 56 | +// const controllerResourceName = 'devworkspace-controller'; |
| 57 | +// const serverResourceName = 'devworkspace-webhook-server'; |
| 58 | + |
| 59 | +// if (retries === 0) { |
| 60 | +// throw new Error('Failed to install devworkspace operator - Pod timeout'); |
| 61 | +// } else { |
| 62 | +// cy.exec( |
| 63 | +// `oc wait --for=condition=ready pod -l app.kubernetes.io/name=${controllerResourceName} -n ${namespace} --timeout=300s`, |
| 64 | +// { |
| 65 | +// failOnNonZeroExit: false, |
| 66 | +// }, |
| 67 | +// ).then(function (result) { |
| 68 | +// if (result.stdout.includes('condition met')) { |
| 69 | +// cy.log(`Success: ${result.stdout}`); |
| 70 | +// } else { |
| 71 | +// cy.log(result.stderr); |
| 72 | +// cy.wait(30000); |
| 73 | +// checkDevWorkspaceOperatorStatus(retries - 1); |
| 74 | +// } |
| 75 | +// }); |
| 76 | +// cy.exec( |
| 77 | +// `oc wait --for=condition=ready pod -l app.kubernetes.io/name=${serverResourceName} -n ${namespace} --timeout=300s`, |
| 78 | +// { |
| 79 | +// failOnNonZeroExit: false, |
| 80 | +// }, |
| 81 | +// ).then(function (result) { |
| 82 | +// if (result.stdout.includes('condition met')) { |
| 83 | +// cy.log(`Success: ${result.stdout}`); |
| 84 | +// } else { |
| 85 | +// cy.log(result.stderr); |
| 86 | +// cy.wait(30000); |
| 87 | +// checkDevWorkspaceOperatorStatus(retries - 1); |
| 88 | +// } |
| 89 | +// }); |
| 90 | +// } |
| 91 | +// }; |
| 92 | + |
| 93 | +// export const checkShipwrightOperatorStatus = (retries: number = 5) => { |
| 94 | +// const namespace = operatorNamespaces.ShipwrightOperator; |
| 95 | +// const resourceName = operatorSubscriptions.ShipwrightOperator; |
| 96 | +// if (retries === 0) { |
| 97 | +// throw new Error('Failed to install Shipwright Operator - Pod timeout'); |
| 98 | +// } else { |
| 99 | +// cy.exec( |
| 100 | +// `oc wait --for=condition=ready pod -l app=${resourceName} -n ${namespace} --timeout=300s`, |
| 101 | +// { |
| 102 | +// failOnNonZeroExit: false, |
| 103 | +// }, |
| 104 | +// ).then(function (result) { |
| 105 | +// if (result.stdout.includes('condition met')) { |
| 106 | +// cy.log(`Success: ${result.stdout}`); |
| 107 | +// } else { |
| 108 | +// cy.log(result.stderr); |
| 109 | +// cy.wait(30000); |
| 110 | +// checkShipwrightOperatorStatus(retries - 1); |
| 111 | +// } |
| 112 | +// }); |
| 113 | +// } |
| 114 | +// }; |
| 115 | + |
| 116 | +// export const checkBuildsForOpenshiftOperatorStatus = (retries: number = 5) => { |
| 117 | +// const namespace = operatorNamespaces.BuildsForOpenshiftOperator; |
| 118 | +// const resourceName = operatorSubscriptions.BuildsForOpenshiftOperator; |
| 119 | +// if (retries === 0) { |
| 120 | +// throw new Error('Failed to install Builds for Openshift Operator - Pod timeout'); |
| 121 | +// } else { |
| 122 | +// cy.exec( |
| 123 | +// `oc wait --for=condition=ready pod -l app=${resourceName} -n ${namespace} --timeout=300s`, |
| 124 | +// { |
| 125 | +// failOnNonZeroExit: false, |
| 126 | +// }, |
| 127 | +// ).then(function (result) { |
| 128 | +// if (result.stdout.includes('condition met')) { |
| 129 | +// cy.log(`Success: ${result.stdout}`); |
| 130 | +// } else { |
| 131 | +// cy.log(result.stderr); |
| 132 | +// cy.wait(30000); |
| 133 | +// checkBuildsForOpenshiftOperatorStatus(retries - 1); |
| 134 | +// } |
| 135 | +// }); |
| 136 | +// } |
| 137 | +// }; |
| 138 | + |
| 139 | +export const checkPipelineOperatorStatus = (retries = 5) => { |
| 140 | + const namespace = operatorNamespaces.PipelinesOperator; |
| 141 | + const resourceName = operatorSubscriptions.PipelinesOperator; |
| 142 | + if (retries === 0) { |
| 143 | + throw new Error('Failed to install Pipelines Operator - Pod timeout'); |
| 144 | + } else { |
| 145 | + cy.exec( |
| 146 | + `oc wait --for=condition=ready pod -l app=${resourceName} -n ${namespace} --timeout=300s`, |
| 147 | + { |
| 148 | + failOnNonZeroExit: false, |
| 149 | + }, |
| 150 | + ).then(function (result) { |
| 151 | + if (result.stdout.includes('condition met')) { |
| 152 | + cy.log(`Success: ${result.stdout}`); |
| 153 | + } else { |
| 154 | + cy.log(result.stderr); |
| 155 | + // eslint-disable-next-line cypress/no-unnecessary-waiting |
| 156 | + cy.wait(30000); |
| 157 | + checkPipelineOperatorStatus(retries - 1); |
| 158 | + } |
| 159 | + }); |
| 160 | + } |
| 161 | +}; |
| 162 | + |
| 163 | +export const checkKnativeOperatorStatus = () => { |
| 164 | + const checkInstanceStatus = ( |
| 165 | + resourceName: string, |
| 166 | + instanceName: string, |
| 167 | + namespace: string, |
| 168 | + ) => { |
| 169 | + cy.exec( |
| 170 | + `oc wait ${resourceName} --for=condition=Ready --timeout=2m -n ${namespace} ${instanceName}`, |
| 171 | + { |
| 172 | + failOnNonZeroExit: false, |
| 173 | + }, |
| 174 | + ).then(function (result) { |
| 175 | + if (result.stdout.includes('condition met')) { |
| 176 | + cy.log(result.stdout); |
| 177 | + } else if (resourceName === 'KnativeServing') { |
| 178 | + createKnativeServingUsingCLI(); |
| 179 | + } else if (resourceName === 'KnativeEventing') { |
| 180 | + createKnativeEventingUsingCLI(); |
| 181 | + } else if (resourceName === 'KnativeKafka') { |
| 182 | + createKnativeKafkaUsingCLI(); |
| 183 | + } |
| 184 | + }); |
| 185 | + }; |
| 186 | + const checkKnativeServingStatus = () => { |
| 187 | + const namespace = 'knative-serving'; |
| 188 | + const instanceName = 'knative-serving'; |
| 189 | + const resourceName = 'KnativeServing'; |
| 190 | + checkInstanceStatus(resourceName, instanceName, namespace); |
| 191 | + }; |
| 192 | + |
| 193 | + const checkKnativeEventingStatus = () => { |
| 194 | + const namespace = 'knative-eventing'; |
| 195 | + const instanceName = 'knative-eventing'; |
| 196 | + const resourceName = 'KnativeEventing'; |
| 197 | + checkInstanceStatus(resourceName, instanceName, namespace); |
| 198 | + }; |
| 199 | + |
| 200 | + const checkKnativeKafkaStatus = () => { |
| 201 | + const namespace = 'knative-eventing'; |
| 202 | + const instanceName = 'knative-kafka'; |
| 203 | + const resourceName = 'KnativeKafka'; |
| 204 | + checkInstanceStatus(resourceName, instanceName, namespace); |
| 205 | + }; |
| 206 | + |
| 207 | + checkKnativeServingStatus(); |
| 208 | + checkKnativeEventingStatus(); |
| 209 | + checkKnativeKafkaStatus(); |
| 210 | +}; |
0 commit comments