use of org.guvnor.ala.openshift.config.OpenShiftProviderConfig in project kie-wb-common by kiegroup.
the class OpenShiftProviderConfigConverterTest method testToDomain.
@Test
public void testToDomain() {
Map<String, Object> values = new HashMap<>();
values.put(KUBERNETES_MAIN.inputKey(), MAIN_URL_VALUE);
values.put(KUBERNETES_AUTH_BASIC_USERNAME.inputKey(), USER_VALUE);
values.put(KUBERNETES_AUTH_BASIC_PASSWORD.inputKey(), PASSWORD_VALUE);
ProviderConfiguration configuration = new ProviderConfiguration(PROVIDER_NAME_VALUE, values);
OpenShiftProviderConfig result = converter.toDomain(configuration);
assertNotNull(result);
assertEquals(PROVIDER_NAME_VALUE, result.getName());
assertEquals(MAIN_URL_VALUE, result.getKubernetesMain());
assertEquals(USER_VALUE, result.getKubernetesAuthBasicUsername());
assertEquals(PASSWORD_VALUE, result.getKubernetesAuthBasicPassword());
}
use of org.guvnor.ala.openshift.config.OpenShiftProviderConfig in project kie-wb-common by kiegroup.
the class OpenShiftExecutorTest method testPipelineAndLifecycle.
/**
* Tests the ALA pipeline and runtime lifecycle.
*
* If running via command line, the properties are already set in the pom.xml file.
* If running in an IDE, set these properties in your debug configuration VM arguments.
* On Eclipse, Run / Debug Configurations... / Arguments / VM arguments:
* -Dsun.net.spi.nameservice.provider.1=dns,OpenShiftNameService
* -Dsun.net.spi.nameservice.provider.2=default
* -Dorg.guvnor.ala.openshift.access.OpenShiftClientListener.postCreate=org.guvnor.ala.openshift.dns.OpenShiftNameServiceClientListener
* -Dorg.guvnor.ala.openshift.dns.OpenShiftNameServiceClientListener.routerHost=10.34.75.115
*
* @throws Exception
*/
@Test
public void testPipelineAndLifecycle() throws Exception {
final RuntimeRegistry runtimeRegistry = new InMemoryRuntimeRegistry();
final OpenShiftAccessInterface openshiftAccessInterface = new OpenShiftAccessInterfaceImpl();
final Pipeline pipe = PipelineFactory.newBuilder().addConfigStage("OpenShift Provider Config", new OpenShiftProviderConfig() {
}).addConfigStage("OpenShift Runtime Config", new ContextAwareOpenShiftRuntimeExecConfig()).buildAs("my pipe");
final OpenShiftRuntimeExecExecutor<OpenShiftRuntimeExecConfig> openshiftRuntimeExecExecutor = new OpenShiftRuntimeExecExecutor<>(runtimeRegistry, openshiftAccessInterface);
final PipelineExecutor executor = new PipelineExecutor(asList(new OpenShiftProviderConfigExecutor(runtimeRegistry), openshiftRuntimeExecExecutor));
final String pvrName = getClass().getSimpleName();
final String prjName = createProjectName("tpal1");
final String appName = "myapp";
final String svcName = appName + "-execserv";
final String kieServerUser = "executionUser";
final String kieServerPwd = "execution1!";
String templateParams = new OpenShiftParameters().param("APPLICATION_NAME", appName).param("IMAGE_STREAM_NAMESPACE", prjName).param("KIE_ADMIN_PWD", "admin1!").param("KIE_SERVER_USER", kieServerUser).param("KIE_SERVER_PWD", kieServerPwd).param("MAVEN_REPO_URL", "http://repository.jboss.org/nexus/content/groups/public/").toString();
Input input = new Input() {
{
/*
// build properties
put(GitConfig.ORIGIN, "https://github.com/jboss-openshift/openshift-quickstarts");
put(GitConfig.REPO_NAME, "openshift-quickstarts");
put(GitConfig.BRANCH, "main");
put(GitConfig.CREATE_REPO, "true");
put(GitConfig.OUT_DIR, workDir.getAbsolutePath());
put(MavenProjectConfig.PROJECT_DIR, "decisionserver/hellorules");
*/
// provider properties
put(KUBERNETES_MAIN.inputKey(), "https://ce-os-rhel-main.usersys.redhat.com:8443");
put(KUBERNETES_AUTH_BASIC_USERNAME.inputKey(), "admin");
put(KUBERNETES_AUTH_BASIC_PASSWORD.inputKey(), "admin");
put(PROVIDER_NAME.inputKey(), pvrName);
// runtime properties
put(APPLICATION_NAME.inputKey(), appName);
// put(KIE_SERVER_CONTAINER_DEPLOYMENT.inputKey(), "decisionserver-hellorules=org.openshift.quickstarts:decisionserver-hellorules:1.4.0.Final");
put(PROJECT_NAME.inputKey(), prjName);
put(RESOURCE_SECRETS_URI.inputKey(), getUri("bpmsuite-app-secret.json"));
put(RESOURCE_STREAMS_URI.inputKey(), getUri("bpmsuite-image-streams.json"));
put(RESOURCE_TEMPLATE_PARAM_VALUES.inputKey(), templateParams);
put(RESOURCE_TEMPLATE_URI.inputKey(), getUri("bpmsuite70-execserv.json"));
put(SERVICE_NAME.inputKey(), svcName);
}
};
executor.execute(input, pipe, (Runtime b) -> System.out.println(b));
OpenShiftRuntimeManager runtimeManager = new OpenShiftRuntimeManager(runtimeRegistry, openshiftAccessInterface);
OpenShiftRuntime openshiftRuntime = getRuntime(runtimeRegistry, runtimeManager, null, true);
assertEquals(OpenShiftRuntimeState.READY, openshiftRuntime.getState().getState());
// This step would normally be done by guvnor, but since we don't have guvnor in this test, we
// include a standalone Nexus repo in the json configuration and deploy the binary to it here.
// new OpenShiftMavenDeployer(workDir, appName, prjName).deploy(buildRegistry);
runtimeManager.start(openshiftRuntime);
openshiftRuntime = getRuntime(runtimeRegistry, runtimeManager, openshiftRuntime, true);
assertEquals(OpenShiftRuntimeState.RUNNING, openshiftRuntime.getState().getState());
RuntimeEndpoint runtimeEndpoint = openshiftRuntime.getEndpoint();
assertTrue(runtimeEndpoint instanceof OpenShiftRuntimeEndpoint);
OpenShiftRuntimeEndpoint openshiftRuntimeEndpoint = (OpenShiftRuntimeEndpoint) runtimeEndpoint;
String kieServerHost = openshiftRuntimeEndpoint.getHost();
if (OpenShiftNameService.isHostRegistered(kieServerHost)) {
String kieServerUrl = new StringBuilder().append(openshiftRuntimeEndpoint.getProtocol()).append("://").append(kieServerHost).append("/services/rest/server").toString();
if (checkConnection(kieServerUrl)) {
KieServicesConfiguration kieServicesConfig = KieServicesFactory.newRestConfiguration(kieServerUrl, kieServerUser, kieServerPwd);
KieServicesClient kieServicesClient = KieServicesFactory.newKieServicesClient(kieServicesConfig);
ServiceResponse<KieServerInfo> serverInfoResponse = kieServicesClient.getServerInfo();
assertEquals(ServiceResponse.ResponseType.SUCCESS, serverInfoResponse.getType());
}
}
runtimeManager.stop(openshiftRuntime);
openshiftRuntime = getRuntime(runtimeRegistry, runtimeManager, openshiftRuntime, true);
assertEquals(OpenShiftRuntimeState.READY, openshiftRuntime.getState().getState());
openshiftRuntimeExecExecutor.destroy(openshiftRuntime);
openshiftRuntime = getRuntime(runtimeRegistry, runtimeManager, openshiftRuntime, false);
assertNull(openshiftRuntime);
openshiftAccessInterface.dispose();
}
use of org.guvnor.ala.openshift.config.OpenShiftProviderConfig in project kie-wb-common by kiegroup.
the class OpenShiftProviderConfigExecutor method apply.
@Override
public Optional<OpenShiftProvider> apply(final OpenShiftProviderConfig openshiftProviderConfig) {
if (openshiftProviderConfig.getName() == null || openshiftProviderConfig.getName().isEmpty()) {
throw new ProvisioningException("No name was provided for the OpenShiftProviderConfig.getName() " + "configuration parameter. You might probably have to properly set " + "the pipeline input parameter: " + ProviderConfig.PROVIDER_NAME);
}
Provider provider = runtimeRegistry.getProvider(openshiftProviderConfig.getName());
OpenShiftProvider openshiftProvider;
if (provider != null) {
if (!(provider instanceof OpenShiftProvider)) {
throw new ProvisioningException("The provider: " + openshiftProviderConfig.getName() + " must be an instance of " + OpenShiftProviderConfig.class + " but is: " + provider.getClass());
} else {
openshiftProvider = (OpenShiftProvider) provider;
}
} else {
openshiftProvider = new OpenShiftProviderImpl(openshiftProviderConfig.getName(), openshiftProviderConfig);
runtimeRegistry.registerProvider(openshiftProvider);
}
return Optional.of(openshiftProvider);
}
use of org.guvnor.ala.openshift.config.OpenShiftProviderConfig in project kie-wb-common by kiegroup.
the class OpenShiftProviderConfigConverterTest method testToModel.
@Test
public void testToModel() {
OpenShiftProviderConfig config = mock(OpenShiftProviderConfig.class);
when(config.getName()).thenReturn(PROVIDER_NAME_VALUE);
when(config.getKubernetesMain()).thenReturn(MAIN_URL_VALUE);
when(config.getKubernetesAuthBasicUsername()).thenReturn(USER_VALUE);
when(config.getKubernetesAuthBasicPassword()).thenReturn(PASSWORD_VALUE);
ProviderConfiguration result = converter.toModel(config);
assertNotNull(result);
assertEquals(PROVIDER_NAME_VALUE, result.getId());
assertEquals(MAIN_URL_VALUE, result.getValues().get(KUBERNETES_MAIN.inputKey()));
assertEquals(USER_VALUE, result.getValues().get(KUBERNETES_AUTH_BASIC_USERNAME.inputKey()));
assertEquals(PASSWORD_VALUE, result.getValues().get(KUBERNETES_AUTH_BASIC_PASSWORD.inputKey()));
}
Aggregations