@Test(expected = KubernetesClientException.class) public void testCreateInvalidService() throws Exception { // create an invalid Service Service bogusServ = new Service(); bogusServ.setId("xxxxxx"); getClient().createService(bogusServ); }
@Test public void testCreateService() throws Exception { if (log.isDebugEnabled()) { log.debug("Creating a Service Proxy: " + serv); } getClient().createService(serv); assertNotNull(getClient().getService(serv.getId())); // test recreation using same id try { getClient().createService(serv); fail("Should have thrown exception"); } catch (Exception e) { // ignore } assertNotNull(getClient().getService(serv.getId())); }
private Service getService() { Service serv = new Service(); serv.setContainerPort("8379"); serv.setPort(5000); serv.setId("kubernetes-test-service"); serv.setLabels(ImmutableMap.of("name", "kubernetes-test-service-label")); serv.setName("kubernetes-test-service-name"); Selector selector = new Selector(); selector.setName(serv.getLabels().get("name")); serv.setSelector(selector); return serv; }
@Test public void testDeleteService() throws Exception { getClient().createService(serv); Status status = getClient().deleteService(serv.getId()); assertNull(getClient().getService(serv.getId())); }