use of io.fabric8.arquillian.kubernetes.Session in project fabric8 by fabric8io.
the class Util method waitUntilWeCanDestroyNamespace.
protected static void waitUntilWeCanDestroyNamespace(Session session) {
final Logger log = session.getLogger();
String confirmDestroy = Systems.getEnvVarOrSystemProperty(Constants.NAMESPACE_CLEANUP_CONFIRM_ENABLED, "false");
if (Objects.equal(confirmDestroy, "true")) {
showErrorsBeforePause(session);
System.out.println();
System.out.println("Waiting to destroy the namespace.");
System.out.println("Please type: [Q] to terminate the namespace.");
while (true) {
try {
int ch = System.in.read();
if (ch < 0 || ch == 'Q') {
System.out.println("\nStopping...");
break;
} else {
System.out.println("Found character: " + Character.toString((char) ch));
}
} catch (IOException e) {
log.warn("Failed to read from input. " + e);
break;
}
}
} else {
String timeoutText = Systems.getEnvVarOrSystemProperty(Constants.NAMESPACE_CLEANUP_TIMEOUT, "0");
Long timeout = null;
if (Strings.isNotBlank(timeoutText)) {
try {
timeout = Long.parseLong(timeoutText);
} catch (NumberFormatException e) {
log.warn("Failed to parse timeout value '" + timeoutText + "' for $Constants.NAMESPACE_CLEANUP_TIMEOUT. " + e);
}
}
if (timeout != null && timeout > 0L) {
showErrorsBeforePause(session);
System.out.println();
System.out.println("Sleeping for " + timeout + " seconds until destroying the namespace");
try {
Thread.sleep(timeout * 1000);
} catch (InterruptedException e) {
log.info("Interupted sleeping to GC the namespace: " + e);
}
}
}
System.out.println("Now destroying the Fabric8 Arquillian test case namespace");
}
use of io.fabric8.arquillian.kubernetes.Session in project fabric8 by fabric8io.
the class DependencyResolverTest method testResolutionOfPomWithNoDeps.
@Test
public void testResolutionOfPomWithNoDeps() throws IOException {
Session session = new Session("test-session", "test-session-123", new AnsiLogger());
DependencyResolver resolver = new DependencyResolver(DependencyResolver.class.getResource("/test-pom.xml").getFile(), true);
Assert.assertTrue(resolver.resolve(session).isEmpty());
}
use of io.fabric8.arquillian.kubernetes.Session in project fabric8 by fabric8io.
the class SessionListener method generateSecrets.
private Set<Secret> generateSecrets(KubernetesClient client, Session session, ObjectMeta meta) {
Set<Secret> secrets = new HashSet<>();
Map<String, String> annotations = meta.getAnnotations();
if (annotations != null && !annotations.isEmpty()) {
for (Map.Entry<String, String> entry : annotations.entrySet()) {
String key = entry.getKey();
String value = entry.getValue();
if (SecretKeys.isSecretKey(key)) {
SecretKeys keyType = SecretKeys.fromValue(key);
for (String name : Secrets.getNames(value)) {
Map<String, String> data = new HashMap<>();
Secret secret = null;
try {
secret = client.secrets().inNamespace(session.getNamespace()).withName(name).get();
} catch (Exception e) {
// ignore - probably doesn't exist
}
if (secret == null) {
for (String c : Secrets.getContents(value, name)) {
data.put(c, keyType.generate());
}
secret = client.secrets().inNamespace(session.getNamespace()).createNew().withNewMetadata().withName(name).endMetadata().withData(data).done();
secrets.add(secret);
}
}
}
}
}
return secrets;
}
use of io.fabric8.arquillian.kubernetes.Session in project fabric8 by fabric8io.
the class SuiteListener method start.
public void start(@Observes(precedence = 100) BeforeSuite event, Configuration configuration, Logger logger) {
session = new Session(configuration.getSessionId(), configuration.getNamespace(), logger);
session.init();
sessionProducer.set(session);
controlEvent.fire(new Start(session));
}
use of io.fabric8.arquillian.kubernetes.Session in project fabric8 by fabric8io.
the class SuiteListener method stop.
public void stop(@Observes(precedence = -100) AfterSuite event, Logger logger) {
controlEvent.fire(new Stop(session));
session.destroy();
}
Aggregations