Java Code Examples for io.fabric8.kubernetes.client.server.mock.KubernetesMockServer#init()
The following examples show how to use
io.fabric8.kubernetes.client.server.mock.KubernetesMockServer#init() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ResolveServicesByLabelsConfigAndPortOKOfflineTest.java From vxms with Apache License 2.0 | 7 votes |
public void initKubernetes() { KubernetesMockServer plainServer = new KubernetesMockServer(false); plainServer.init(); String host = plainServer.getHostName(); Integer port = plainServer.getPort(); ClassLoader classLoader = getClass().getClassLoader(); File ca = new File(classLoader.getResource("ca.crt").getFile()); File clientcert = new File(classLoader.getResource("client.crt").getFile()); File clientkey = new File(classLoader.getResource("client.key").getFile()); System.out.println("port: " + port + " host:" + host); config = new ConfigBuilder() .withMasterUrl(host + ":" + port) .withNamespace(null) .withCaCertFile(ca.getAbsolutePath()) .withClientCertFile(clientcert.getAbsolutePath()) .withClientKeyFile(clientkey.getAbsolutePath()) .build(); // client = new DefaultKubernetesClient(config); server = plainServer; }
Example 2
Source File: KubernetesMockServerTestResource.java From quarkus with Apache License 2.0 | 6 votes |
@Override public Map<String, String> start() { final Map<String, String> systemProps = new HashMap<>(); systemProps.put(Config.KUBERNETES_TRUST_CERT_SYSTEM_PROPERTY, "true"); systemProps.put(Config.KUBERNETES_AUTH_TRYKUBECONFIG_SYSTEM_PROPERTY, "false"); systemProps.put(Config.KUBERNETES_AUTH_TRYSERVICEACCOUNT_SYSTEM_PROPERTY, "false"); systemProps.put(Config.KUBERNETES_NAMESPACE_SYSTEM_PROPERTY, "test"); mockServer = new KubernetesMockServer(useHttps()); mockServer.init(); try (NamespacedKubernetesClient client = mockServer.createClient()) { systemProps.put(Config.KUBERNETES_MASTER_SYSTEM_PROPERTY, client.getConfiguration().getMasterUrl()); } configureMockServer(mockServer); return systemProps; }
Example 3
Source File: ResolveServicesByNameTest.java From vxms with Apache License 2.0 | 6 votes |
public void initKubernetes() { KubernetesMockServer plainServer = new KubernetesMockServer(false); plainServer.init(); String host = plainServer.getHostName(); Integer port = plainServer.getPort(); ClassLoader classLoader = getClass().getClassLoader(); File ca = new File(classLoader.getResource("ca.crt").getFile()); File clientcert = new File(classLoader.getResource("client.crt").getFile()); File clientkey = new File(classLoader.getResource("client.key").getFile()); System.out.println("port: " + port + " host:" + host); TestingClientConfig.config = new ConfigBuilder() .withMasterUrl(host + ":" + port) .withNamespace("default") .withCaCertFile(ca.getAbsolutePath()) .withClientCertFile(clientcert.getAbsolutePath()) .withClientKeyFile(clientkey.getAbsolutePath()) .build(); // client = new DefaultKubernetesClient(config); server = plainServer; }
Example 4
Source File: KubernetesMockTest.java From vxms with Apache License 2.0 | 6 votes |
@Before public void init() { KubernetesMockServer plainServer = new KubernetesMockServer(false); plainServer.init(); String host = plainServer.getHostName(); Integer port = plainServer.getPort(); ClassLoader classLoader = getClass().getClassLoader(); File ca = new File(classLoader.getResource("ca.crt").getFile()); File clientcert = new File(classLoader.getResource("client.crt").getFile()); File clientkey = new File(classLoader.getResource("client.key").getFile()); System.out.println("port: " + port + " host:" + host); config = new ConfigBuilder() .withMasterUrl(host + ":" + port) .withCaCertFile(ca.getAbsolutePath()) .withClientCertFile(clientcert.getAbsolutePath()) .withClientKeyFile(clientkey.getAbsolutePath()) .build(); client = new DefaultKubernetesClient(config); server = plainServer; }
Example 5
Source File: ResolveServicesByLAbelsWithPortNameTest.java From vxms with Apache License 2.0 | 6 votes |
public void initKubernetes() { KubernetesMockServer plainServer = new KubernetesMockServer(false); plainServer.init(); String host = plainServer.getHostName(); Integer port = plainServer.getPort(); ClassLoader classLoader = getClass().getClassLoader(); File ca = new File(classLoader.getResource("ca.crt").getFile()); File clientcert = new File(classLoader.getResource("client.crt").getFile()); File clientkey = new File(classLoader.getResource("client.key").getFile()); System.out.println("port: " + port + " host:" + host); TestingClientConfig.config = new ConfigBuilder() .withMasterUrl(host + ":" + port) .withNamespace("default") .withCaCertFile(ca.getAbsolutePath()) .withClientCertFile(clientcert.getAbsolutePath()) .withClientKeyFile(clientkey.getAbsolutePath()) .build(); // client = new DefaultKubernetesClient(config); server = plainServer; }
Example 6
Source File: ResolveServicesByLabelsTooManyNOKTest.java From vxms with Apache License 2.0 | 6 votes |
public void initKubernetes() { KubernetesMockServer plainServer = new KubernetesMockServer(false); plainServer.init(); String host = plainServer.getHostName(); Integer port = plainServer.getPort(); ClassLoader classLoader = getClass().getClassLoader(); File ca = new File(classLoader.getResource("ca.crt").getFile()); File clientcert = new File(classLoader.getResource("client.crt").getFile()); File clientkey = new File(classLoader.getResource("client.key").getFile()); System.out.println("port: " + port + " host:" + host); TestingClientConfig.config = new ConfigBuilder() .withMasterUrl(host + ":" + port) .withNamespace("default") .withCaCertFile(ca.getAbsolutePath()) .withClientCertFile(clientcert.getAbsolutePath()) .withClientKeyFile(clientkey.getAbsolutePath()) .build(); // client = new DefaultKubernetesClient(config); server = plainServer; }
Example 7
Source File: ResolveServicesByLabelsConfigOKTest.java From vxms with Apache License 2.0 | 6 votes |
public void initKubernetes() { KubernetesMockServer plainServer = new KubernetesMockServer(false); plainServer.init(); String host = plainServer.getHostName(); Integer port = plainServer.getPort(); ClassLoader classLoader = getClass().getClassLoader(); File ca = new File(classLoader.getResource("ca.crt").getFile()); File clientcert = new File(classLoader.getResource("client.crt").getFile()); File clientkey = new File(classLoader.getResource("client.key").getFile()); System.out.println("port: " + port + " host:" + host); TestingClientConfig.config = new ConfigBuilder() .withMasterUrl(host + ":" + port) .withNamespace("default") .withCaCertFile(ca.getAbsolutePath()) .withClientCertFile(clientcert.getAbsolutePath()) .withClientKeyFile(clientkey.getAbsolutePath()) .build(); // client = new DefaultKubernetesClient(config); server = plainServer; }
Example 8
Source File: ResolveServicesByLabelOKTest.java From vxms with Apache License 2.0 | 6 votes |
public void initKubernetes() { KubernetesMockServer plainServer = new KubernetesMockServer(false); plainServer.init(); String host = plainServer.getHostName(); Integer port = plainServer.getPort(); ClassLoader classLoader = getClass().getClassLoader(); File ca = new File(classLoader.getResource("ca.crt").getFile()); File clientcert = new File(classLoader.getResource("client.crt").getFile()); File clientkey = new File(classLoader.getResource("client.key").getFile()); System.out.println("port: " + port + " host:" + host); TestingClientConfig.config = new ConfigBuilder() .withMasterUrl(host + ":" + port) .withNamespace("default") .withCaCertFile(ca.getAbsolutePath()) .withClientCertFile(clientcert.getAbsolutePath()) .withClientKeyFile(clientkey.getAbsolutePath()) .build(); // client = new DefaultKubernetesClient(config); server = plainServer; }
Example 9
Source File: ResolveServicesByLabelsOKTest.java From vxms with Apache License 2.0 | 6 votes |
public void initKubernetes() { KubernetesMockServer plainServer = new KubernetesMockServer(false); plainServer.init(); String host = plainServer.getHostName(); Integer port = plainServer.getPort(); ClassLoader classLoader = getClass().getClassLoader(); File ca = new File(classLoader.getResource("ca.crt").getFile()); File clientcert = new File(classLoader.getResource("client.crt").getFile()); File clientkey = new File(classLoader.getResource("client.key").getFile()); System.out.println("port: " + port + " host:" + host); TestingClientConfig.config = new ConfigBuilder() .withMasterUrl(host + ":" + port) .withNamespace("default") .withCaCertFile(ca.getAbsolutePath()) .withClientCertFile(clientcert.getAbsolutePath()) .withClientKeyFile(clientkey.getAbsolutePath()) .build(); // client = new DefaultKubernetesClient(config); server = plainServer; }
Example 10
Source File: ResolveServicesByLabelWithConfigOKTest.java From vxms with Apache License 2.0 | 6 votes |
public void initKubernetes() { KubernetesMockServer plainServer = new KubernetesMockServer(false); plainServer.init(); String host = plainServer.getHostName(); Integer port = plainServer.getPort(); ClassLoader classLoader = getClass().getClassLoader(); File ca = new File(classLoader.getResource("ca.crt").getFile()); File clientcert = new File(classLoader.getResource("client.crt").getFile()); File clientkey = new File(classLoader.getResource("client.key").getFile()); System.out.println("port: " + port + " host:" + host); TestingClientConfig.config = new ConfigBuilder() .withMasterUrl(host + ":" + port) .withNamespace("default") .withCaCertFile(ca.getAbsolutePath()) .withClientCertFile(clientcert.getAbsolutePath()) .withClientKeyFile(clientkey.getAbsolutePath()) .build(); // client = new DefaultKubernetesClient(config); server = plainServer; }
Example 11
Source File: ResolveServicesByLabelWithConfigNOKTest.java From vxms with Apache License 2.0 | 6 votes |
public void initKubernetes() { KubernetesMockServer plainServer = new KubernetesMockServer(false); plainServer.init(); String host = plainServer.getHostName(); Integer port = plainServer.getPort(); ClassLoader classLoader = getClass().getClassLoader(); File ca = new File(classLoader.getResource("ca.crt").getFile()); File clientcert = new File(classLoader.getResource("client.crt").getFile()); File clientkey = new File(classLoader.getResource("client.key").getFile()); System.out.println("port: " + port + " host:" + host); TestingClientConfig.config = new ConfigBuilder() .withMasterUrl(host + ":" + port) .withNamespace("default") .withCaCertFile(ca.getAbsolutePath()) .withClientCertFile(clientcert.getAbsolutePath()) .withClientKeyFile(clientkey.getAbsolutePath()) .build(); // client = new DefaultKubernetesClient(config); server = plainServer; }
Example 12
Source File: ResolveServicesByNameWithPortNameTest.java From vxms with Apache License 2.0 | 5 votes |
public void initKubernetes(JsonObject conf) { KubernetesMockServer plainServer = new KubernetesMockServer(false); plainServer.init(); String host = plainServer.getHostName(); Integer port = plainServer.getPort(); ClassLoader classLoader = getClass().getClassLoader(); File ca = new File(classLoader.getResource("ca.crt").getFile()); File clientcert = new File(classLoader.getResource("client.crt").getFile()); File clientkey = new File(classLoader.getResource("client.key").getFile()); System.out.println("port: " + port + " host:" + host); conf.put("withMasterUrl", host + ":" + port); conf.put("withCaCertFile", ca.getAbsolutePath()); conf.put("withClientCertFile", clientcert.getAbsolutePath()); conf.put("withClientKeyFile", clientkey.getAbsolutePath()); TestingClientConfig.config = new ConfigBuilder() .withMasterUrl(host + ":" + port) .withNamespace("default") .withCaCertFile(ca.getAbsolutePath()) .withClientCertFile(clientcert.getAbsolutePath()) .withClientKeyFile(clientkey.getAbsolutePath()) .build(); // client = new DefaultKubernetesClient(config); server = plainServer; }
Example 13
Source File: ConfigMapStoreTest.java From vertx-config with Apache License 2.0 | 4 votes |
@Before public void setUp(TestContext tc) throws MalformedURLException { vertx = Vertx.vertx(); vertx.exceptionHandler(tc.exceptionHandler()); ConfigMap map1 = new ConfigMapBuilder().withMetadata(new ObjectMetaBuilder().withName("my-config-map").build()) .addToData("my-app-json", SOME_JSON) .addToData("my-app-props", SOME_PROPS) .build(); Map<String, String> data = new LinkedHashMap<>(); data.put("key", "value"); data.put("bool", "true"); data.put("count", "3"); ConfigMap map2 = new ConfigMapBuilder().withMetadata(new ObjectMetaBuilder().withName("my-config-map-2").build()) .withData(data) .build(); ConfigMap map3 = new ConfigMapBuilder().withMetadata(new ObjectMetaBuilder().withName("my-config-map-x").build()) .addToData("my-app-json", SOME_JSON) .build(); Secret secret = new SecretBuilder().withMetadata(new ObjectMetaBuilder().withName("my-secret").build()) .addToData("password", Base64.getEncoder().encodeToString("secret".getBytes(UTF_8))) .build(); server = new KubernetesMockServer(false); server.expect().get().withPath("/api/v1/namespaces/default/configmaps").andReturn(200, new ConfigMapListBuilder().addToItems(map1, map2).build()).always(); server.expect().get().withPath("/api/v1/namespaces/my-project/configmaps").andReturn(200, new ConfigMapListBuilder().addToItems(map3).build()).always(); server.expect().get().withPath("/api/v1/namespaces/default/configmaps/my-config-map") .andReturn(200, map1).always(); server.expect().get().withPath("/api/v1/namespaces/default/configmaps/my-config-map-2") .andReturn(200, map2).always(); server.expect().get().withPath("/api/v1/namespaces/my-project/configmaps/my-config-map-x") .andReturn(200, map3).always(); server.expect().get().withPath("/api/v1/namespaces/default/configmaps/my-unknown-config-map") .andReturn(500, null).always(); server.expect().get().withPath("/api/v1/namespaces/default/configmaps/my-unknown-map") .andReturn(500, null).always(); server.expect().get().withPath("/api/v1/namespaces/my-project/secrets/my-secret").andReturn(200, secret) .always(); server.init(); client = server.createClient(); port = new URL(client.getConfiguration().getMasterUrl()).getPort(); }