use of cz.xtf.core.openshift.OpenShift in project syndesis-qe by syndesisio.
the class CamelK method undeploy.
@Override
public void undeploy() {
// The server pod will not be present if the camel-k wasn't deployed
if (OpenShiftUtils.getAnyPod("camel.apache.org/component", "operator").isPresent()) {
// It is needed to reset-db first, otherwise server would create the integrations again
TestSupport.getInstance().resetDB();
resetState();
OpenShift oc = OpenShiftUtils.getInstance();
oc.apps().deployments().withName("camel-k-operator").delete();
oc.getLabeledPods("camel.apache.org/component", "operator").forEach(oc::deletePod);
ResourceFactory.get(Syndesis.class).changeRuntime("springboot");
}
}
use of cz.xtf.core.openshift.OpenShift in project syndesis-qe by syndesisio.
the class CommonSteps method isProjectClean.
/**
* Workaround for isProjectClean function from XTF. See issue: https://github.com/xtf-cz/xtf/issues/406
* XTF cannot be update because it uses openshift-client 4.13.0 which contains kubernetes-model 4.11.2 where CRD was moved to the `v1beta1` .
* Since Syndesis endpoints uses old kubernetes-model, the CRD is missing (`NoClassDefFoundError`)
* When we let Syndesis endpoints to bring the old kubernetes-model with itself (remove <exclude> from parent pom.xml),
* it causes undesired behaviour, e.g. portForwarding doesn't work correctly etc.
* So we need to wait with bump xtf version until the Syndesis will contains newer kubernetes-model
* <p>
* This is implementation from XTF with workaround
* To access to the protected methods, the JavaReflection API is used.
*/
private static Waiter isProjectClean() {
return new SimpleWaiter(() -> {
int crdInstances = 0;
int removableResources = 0;
try {
Method privateMethodGetCRDContextProviders = OpenShift.class.getDeclaredMethod("getCRDContextProviders", null);
privateMethodGetCRDContextProviders.setAccessible(true);
Method privateMethodListRemovableResources = OpenShift.class.getDeclaredMethod("listRemovableResources", null);
privateMethodListRemovableResources.setAccessible(true);
ServiceLoader<CustomResourceDefinitionContextProvider> cRDContextProviders = (ServiceLoader<CustomResourceDefinitionContextProvider>) privateMethodGetCRDContextProviders.invoke(OpenShift.class, null);
for (CustomResourceDefinitionContextProvider crdContextProvider : cRDContextProviders) {
try {
crdInstances += ((List) (OpenShiftUtils.getInstance().customResource(crdContextProvider.getContext()).list(OpenShiftUtils.getInstance().getNamespace()).get("items"))).size();
} catch (KubernetesClientException kce) {
// CRD might not be installed on the cluster
}
}
List<HasMetadata> removableResourcesList = (List<HasMetadata>) privateMethodListRemovableResources.invoke(OpenShiftUtils.getInstance(), null);
removableResources = removableResourcesList.size();
} catch (IllegalAccessException | InvocationTargetException | NoSuchMethodException e) {
e.printStackTrace();
}
return crdInstances == 0 & // <=1 because configMap can be there on OCP 4.7, see https://github.com/xtf-cz/xtf/issues/406
removableResources <= 1;
}, TimeUnit.MILLISECONDS, WaitingConfig.timeoutCleanup(), "Cleaning project.");
}
Aggregations