use of io.fabric8.openshift.api.model.Template in project syndesis-qe by syndesisio.
the class SyndesisTemplate method deploy.
public static void deploy() {
OpenShiftUtils.getInstance().cleanAndAssert();
// get & create restricted SA
OpenShiftUtils.getInstance().createServiceAccount(getSupportSA());
// get token from SA `oc secrets get-token` && wait until created to prevent 404
TestUtils.waitForEvent(Optional::isPresent, () -> OpenShiftUtils.getInstance().getSecrets().stream().filter(s -> s.getMetadata().getName().startsWith("syndesis-oauth-client-token")).findFirst(), TimeUnit.MINUTES, 2, TimeUnit.SECONDS, 5);
Secret secret = OpenShiftUtils.getInstance().getSecrets().stream().filter(s -> s.getMetadata().getName().startsWith("syndesis-oauth-client-token")).findFirst().get();
// token is Base64 encoded by default
String oauthTokenEncoded = secret.getData().get("token");
byte[] oauthTokenBytes = Base64.decodeBase64(oauthTokenEncoded);
String oauthToken = new String(oauthTokenBytes);
// get the template
Template template = getTemplate();
// set params
Map<String, String> templateParams = new HashMap<>();
templateParams.put("ROUTE_HOSTNAME", TestConfiguration.openShiftNamespace() + "." + TestConfiguration.syndesisUrlSuffix());
templateParams.put("OPENSHIFT_MASTER", TestConfiguration.openShiftUrl());
templateParams.put("OPENSHIFT_PROJECT", TestConfiguration.openShiftNamespace());
templateParams.put("OPENSHIFT_OAUTH_CLIENT_SECRET", oauthToken);
templateParams.put("TEST_SUPPORT_ENABLED", "true");
// process & create
KubernetesList processedTemplate = OpenShiftUtils.getInstance().recreateAndProcessTemplate(template, templateParams);
OpenShiftUtils.getInstance().createResources(processedTemplate);
OpenShiftUtils.createRestRoute(TestConfiguration.openShiftNamespace(), TestConfiguration.syndesisUrlSuffix());
// TODO: there's a bug in openshift-client, we need to initialize manually
OpenShiftUtils.client().roleBindings().createOrReplaceWithNew().withNewMetadata().withName("syndesis:editors").endMetadata().withNewRoleRef().withName("edit").endRoleRef().addNewSubject().withKind("ServiceAccount").withName(Component.SERVER.getName()).withNamespace(TestConfiguration.openShiftNamespace()).endSubject().addToUserNames(String.format("system:serviceaccount:%s:%s", TestConfiguration.openShiftNamespace(), Component.SERVER.getName())).done();
}
use of io.fabric8.openshift.api.model.Template in project vertx-openshift-it by cescoffier.
the class CountersIT method initialize.
@BeforeClass
public static void initialize() throws IOException {
initializeServiceAccount();
SortedMap<String, File> dependencies = new TreeMap<>();
dependencies.put("A-Counters", new File("../" + APPLICATION_NAME + "/target/classes/META-INF/fabric8/openshift.yml"));
dependencies.forEach((name, template) -> Ensure.ensureThat(String.format("template file %s can be deployed", template), () -> deploymentAssistant.deploy(name, template)));
Ensure.ensureThat("The counters app is up and running", () -> await().atMost(5, TimeUnit.MINUTES).catchUncaughtExceptions().untilAsserted(() -> {
Service service = client.services().withName(APPLICATION_NAME).get();
Assertions.assertThat(service).isNotNull();
route = client.routes().withName(APPLICATION_NAME).get();
Assertions.assertThat(route).isNotNull();
get(Kube.urlForRoute(route, "/health")).then().statusCode(200);
}));
clusterCountersHelper = new OpenShiftHelper(client, APPLICATION_NAME);
}
use of io.fabric8.openshift.api.model.Template in project vertx-openshift-it by cescoffier.
the class EventBusIT method initialize.
@BeforeClass
public static void initialize() throws IOException {
initializeServiceAccount();
SortedMap<String, File> dependencies = new TreeMap<>();
dependencies.put("A-EventBus", new File("../" + APPLICATION_NAME + "/target/classes/META-INF/fabric8/openshift.yml"));
dependencies.forEach((name, template) -> Ensure.ensureThat(String.format("template file %s can be deployed", template), () -> deploymentAssistant.deploy(name, template)));
Ensure.ensureThat("The event-bus app is up and running", () -> await().atMost(5, TimeUnit.MINUTES).catchUncaughtExceptions().untilAsserted(() -> {
Service service = client.services().withName(APPLICATION_NAME).get();
Assertions.assertThat(service).isNotNull();
route = client.routes().withName(APPLICATION_NAME).get();
Assertions.assertThat(route).isNotNull();
get(Kube.urlForRoute(route, "/health")).then().statusCode(200);
}));
clusterEventBusHelper = new OpenShiftHelper(client, APPLICATION_NAME);
}
use of io.fabric8.openshift.api.model.Template in project vertx-openshift-it by cescoffier.
the class LocksIT method initialize.
@BeforeClass
public static void initialize() throws IOException {
initializeServiceAccount();
SortedMap<String, File> dependencies = new TreeMap<>();
dependencies.put("A-Locks", new File("../" + APPLICATION_NAME + "/target/classes/META-INF/fabric8/openshift.yml"));
dependencies.forEach((name, template) -> Ensure.ensureThat(String.format("template file %s can be deployed", template), () -> deploymentAssistant.deploy(name, template)));
Ensure.ensureThat("The locks app is up and running", () -> await().atMost(5, TimeUnit.MINUTES).catchUncaughtExceptions().untilAsserted(() -> {
Service service = client.services().withName(APPLICATION_NAME).get();
Assertions.assertThat(service).isNotNull();
route = client.routes().withName(APPLICATION_NAME).get();
Assertions.assertThat(route).isNotNull();
get(Kube.urlForRoute(route, "/health")).then().statusCode(200);
}));
clusterLocksHelper = new OpenShiftHelper(client, APPLICATION_NAME);
}
use of io.fabric8.openshift.api.model.Template in project vertx-openshift-it by cescoffier.
the class AsyncMapRollingUpdateIT method initialize.
@BeforeClass
public static void initialize() throws IOException {
initializeServiceAccount();
SortedMap<String, File> dependencies = new TreeMap<>();
dependencies.put("A-RUAsyncMap", new File("../" + APPLICATION_NAME + "/target/classes/META-INF/fabric8/openshift.yml"));
dependencies.forEach((name, template) -> Ensure.ensureThat(String.format("template file %s can be deployed", template), () -> deploymentAssistant.deploy(name, template)));
Ensure.ensureThat("The asyncmap app is up and running", () -> await().atMost(5, TimeUnit.MINUTES).catchUncaughtExceptions().untilAsserted(() -> {
Service service = client.services().withName(APPLICATION_NAME).get();
Assertions.assertThat(service).isNotNull();
route = client.routes().withName(APPLICATION_NAME).get();
Assertions.assertThat(route).isNotNull();
get(Kube.urlForRoute(route, "/ready")).then().statusCode(200);
}));
clusterRuAsyncMapHelper = new OpenShiftHelper(client, APPLICATION_NAME);
}
Aggregations