use of com.yahoo.athenz.zms.ServiceIdentity in project athenz by yahoo.
the class JDBCConnectionTest method testInsertServiceIdentityAllFields.
@Test
public void testInsertServiceIdentityAllFields() throws Exception {
JDBCConnection jdbcConn = new JDBCConnection(mockConn, true);
ServiceIdentity service = new ServiceIdentity().setName("my-domain.service1").setDescription("test service").setExecutable("/usr/bin64/test.sh").setGroup("users").setUser("root").setProviderEndpoint("http://server.athenzcompany.com");
Mockito.doReturn(1).when(mockPrepStmt).executeUpdate();
Mockito.when(mockResultSet.next()).thenReturn(true);
// return domain id
Mockito.when(mockResultSet.getInt(1)).thenReturn(5);
boolean requestSuccess = jdbcConn.insertServiceIdentity("my-domain", service);
assertTrue(requestSuccess);
// get domain id
Mockito.verify(mockPrepStmt, times(1)).setString(1, "my-domain");
// update service
Mockito.verify(mockPrepStmt, times(1)).setString(1, "service1");
Mockito.verify(mockPrepStmt, times(1)).setString(2, "test service");
Mockito.verify(mockPrepStmt, times(1)).setString(3, "http://server.athenzcompany.com");
Mockito.verify(mockPrepStmt, times(1)).setString(4, "/usr/bin64/test.sh");
Mockito.verify(mockPrepStmt, times(1)).setString(5, "root");
Mockito.verify(mockPrepStmt, times(1)).setString(6, "users");
Mockito.verify(mockPrepStmt, times(1)).setInt(7, 5);
jdbcConn.close();
}
use of com.yahoo.athenz.zms.ServiceIdentity in project athenz by yahoo.
the class DataStoreTest method testDeleteDomainFromCacheHosts.
@Test
public void testDeleteDomainFromCacheHosts() {
ChangeLogStore clogStore = new MockZMSFileChangeLogStore("/tmp/zts_server_unit_tests/zts_root", pkey, "0");
DataStore store = new DataStore(clogStore, null);
DataCache dataCache = new DataCache();
ServiceIdentity service = new ServiceIdentity();
service.setName("coretech.storage");
List<String> hosts = new ArrayList<>();
hosts.add("host1");
service.setHosts(hosts);
List<ServiceIdentity> services = new ArrayList<>();
dataCache.processServiceIdentity(service);
services.add(service);
DomainData domainData = new DomainData();
domainData.setServices(services);
dataCache.setDomainData(domainData);
store.addDomainToCache("coretech", dataCache);
store.deleteDomainFromCache("coretech");
HostServices hostServices = store.getHostServices("host1");
hosts = hostServices.getNames();
assertEquals(hosts.size(), 0);
}
use of com.yahoo.athenz.zms.ServiceIdentity in project athenz by yahoo.
the class DataStoreTest method testAddDomainToCacheSameHosts.
@Test
public void testAddDomainToCacheSameHosts() {
ChangeLogStore clogStore = new MockZMSFileChangeLogStore("/tmp/zts_server_unit_tests/zts_root", pkey, "0");
DataStore store = new DataStore(clogStore, null);
DataCache dataCache = new DataCache();
ServiceIdentity service = new ServiceIdentity();
service.setName("coretech.storage");
List<String> hosts = new ArrayList<>();
hosts.add("host1");
service.setHosts(hosts);
List<ServiceIdentity> services = new ArrayList<>();
services.add(service);
dataCache.processServiceIdentity(service);
DomainData domainData = new DomainData();
domainData.setServices(services);
dataCache.setDomainData(domainData);
store.addDomainToCache("coretech", dataCache);
/* same hosts - no changes */
dataCache = new DataCache();
service = new ServiceIdentity();
service.setName("coretech.storage");
hosts = new ArrayList<>();
hosts.add("host1");
service.setHosts(hosts);
services = new ArrayList<>();
services.add(service);
dataCache.processServiceIdentity(service);
domainData = new DomainData();
domainData.setServices(services);
dataCache.setDomainData(domainData);
store.addDomainToCache("coretech", dataCache);
HostServices hostServices = store.getHostServices("host1");
hosts = hostServices.getNames();
assertEquals(hosts.size(), 1);
assertTrue(hosts.contains("coretech.storage"));
}
Aggregations