use of io.fabric8.arquillian.kubernetes.Session in project fabric8 by fabric8io.
the class ConfigMaps method createConfigMapAnnotations.
private static Map<String, String> createConfigMapAnnotations(Session session, String status) {
Map<String, String> annotations = new HashMap<>();
File dir = Util.getProjectBaseDir(session);
String gitUrl = Util.findGitUrl(session, dir);
annotations.put(Annotations.Tests.SESSION_ID, session.getId());
annotations.put(Annotations.Tests.TEST_SESSION_STATUS, status);
if (Strings.isNotBlank(gitUrl)) {
annotations.put(Annotations.Builds.GIT_URL, gitUrl);
}
// lets see if there's a maven generated set of pom properties
File pomProperties = new File(dir, "target/maven-archiver/pom.properties");
if (pomProperties.isFile()) {
try {
Properties properties = new Properties();
properties.load(new FileInputStream(pomProperties));
Map<String, String> map = PropertiesHelper.toMap(properties);
for (Map.Entry<String, String> entry : map.entrySet()) {
String key = entry.getKey();
String value = entry.getValue();
if (Strings.isNotBlank(key) && Strings.isNotBlank(value)) {
annotations.put(Annotations.Project.PREFIX + key, value);
}
}
} catch (IOException e) {
session.getLogger().warn("Failed to load " + pomProperties + " file to annotate the namespace: " + e);
}
}
return annotations;
}
use of io.fabric8.arquillian.kubernetes.Session in project strimzi by strimzi.
the class ControllerIT method setup.
@Before
public void setup(TestContext context) throws Exception {
LOGGER.info("Setting up test");
Runtime.getRuntime().addShutdownHook(kafkaHook);
kafkaCluster = new KafkaCluster();
kafkaCluster.addBrokers(1);
kafkaCluster.deleteDataPriorToStartup(true);
kafkaCluster.deleteDataUponShutdown(true);
kafkaCluster.usingDirectory(Files.createTempDirectory("controller-integration-test").toFile());
kafkaCluster.startup();
kubeClient = new DefaultKubernetesClient().inNamespace(NAMESPACE);
LOGGER.info("Using namespace {}", NAMESPACE);
Map<String, String> m = new HashMap();
m.put(Config.KAFKA_BOOTSTRAP_SERVERS.key, kafkaCluster.brokerList());
m.put(Config.ZOOKEEPER_CONNECT.key, "localhost:" + zkPort(kafkaCluster));
m.put(Config.NAMESPACE.key, NAMESPACE);
session = new Session(kubeClient, new Config(m));
Async async = context.async();
vertx.deployVerticle(session, ar -> {
if (ar.succeeded()) {
deploymentId = ar.result();
adminClient = session.adminClient;
topicsConfigWatcher = session.topicConfigsWatcher;
topicWatcher = session.topicWatcher;
topicsWatcher = session.topicsWatcher;
async.complete();
} else {
context.fail("Failed to deploy session");
}
});
async.await();
waitFor(context, () -> this.topicsWatcher.started(), timeout, "Topics watcher not started");
waitFor(context, () -> this.topicsConfigWatcher.started(), timeout, "Topic configs watcher not started");
waitFor(context, () -> this.topicWatcher.started(), timeout, "Topic watcher not started");
// We can't delete events, so record the events which exist at the start of the test
// and then waitForEvents() can ignore those
preExistingEvents = kubeClient.events().inNamespace(NAMESPACE).withLabels(cmPredicate.labels()).list().getItems().stream().map(evt -> evt.getMetadata().getUid()).collect(Collectors.toSet());
LOGGER.info("Finished setting up test");
}
use of io.fabric8.arquillian.kubernetes.Session in project strimzi by strimzi.
the class Main method deploy.
private void deploy(Config config) {
DefaultKubernetesClient kubeClient = new DefaultKubernetesClient();
Vertx vertx = Vertx.vertx();
Session session = new Session(kubeClient, config);
vertx.deployVerticle(session, ar -> {
if (ar.succeeded()) {
LOGGER.info("Session deployed");
} else {
LOGGER.error("Error deploying Session", ar.cause());
}
});
}
use of io.fabric8.arquillian.kubernetes.Session in project vertx-openshift-it by cescoffier.
the class WebSessionIT method initialize.
@BeforeClass
public static void initialize() throws IOException {
initializeServiceAccount();
SortedMap<String, File> dependencies = new TreeMap<>();
dependencies.put("A-WebSession", 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 web-session 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);
}));
clusterWebSessionHelper = new OpenShiftHelper(client, APPLICATION_NAME);
}
use of io.fabric8.arquillian.kubernetes.Session in project vertx-openshift-it by cescoffier.
the class WebSessionIT method testClusteredWebSession.
@Test
public void testClusteredWebSession() throws Exception {
HttpClient httpClient = vertx.createHttpClient();
AtomicReference<Map.Entry<String, String>> cookie = new AtomicReference<>();
int loops = 30;
for (int i = 0; i < loops; i++) {
String key = getKey(i);
String value = getValue(i);
URL url = Kube.urlForRoute(client.routes().withName(APPLICATION_NAME).get(), "/web-session/" + key);
CountDownLatch latch = new CountDownLatch(1);
HttpClientRequest request = httpClient.putAbs(url.toString());
Optional.ofNullable(cookie.get()).ifPresent(c -> request.headers().add("cookie", c.getKey() + "=" + c.getValue()));
request.handler(resp -> {
resp.cookies().stream().map(c -> c.split("=", 2)).map(split -> new SimpleImmutableEntry<>(split[0], split[1].split(";")[0])).filter(entry -> "vertx-web.session".equals(entry.getKey())).forEach(cookie::set);
latch.countDown();
}).exceptionHandler(t -> {
t.printStackTrace();
latch.countDown();
}).end(value);
latch.await(1, TimeUnit.MINUTES);
// Give some time to the replication operation
TimeUnit.SECONDS.sleep(1);
}
scaleTo(2);
// Give some time to the rebalancing process
TimeUnit.SECONDS.sleep(10);
assertNotNull("No session cookie", cookie.get());
for (int i = 0; i < loops; i++) {
String key = getKey(i);
String value = getValue(i);
URL url = Kube.urlForRoute(client.routes().withName(APPLICATION_NAME).get(), "/web-session/" + key);
given().cookie(cookie.get().getKey(), cookie.get().getValue()).when().get(url).then().assertThat().statusCode(200).body(equalTo(value));
}
}
Aggregations