use of com.yahoo.config.provision.ApplicationId in project vespa by vespa-engine.
the class IdentityDocumentGeneratorTest method generates_valid_identity_document.
@Test
public void generates_valid_identity_document() throws Exception {
String hostname = "x.y.com";
ApplicationId appid = ApplicationId.from(TenantName.from("tenant"), ApplicationName.from("application"), InstanceName.from("default"));
Allocation allocation = new Allocation(appid, ClusterMembership.from("container/default/0/0", Version.fromString("1.2.3")), Generation.inital(), false);
Node n = Node.create("ostkid", ImmutableSet.of("127.0.0.1"), new HashSet<>(), hostname, Optional.empty(), new MockNodeFlavors().getFlavorOrThrow("default"), NodeType.tenant).with(allocation);
NodeRepository nodeRepository = mock(NodeRepository.class);
when(nodeRepository.getNode(eq(hostname))).thenReturn(Optional.of(n));
AutoGeneratedKeyProvider keyProvider = new AutoGeneratedKeyProvider();
String dnsSuffix = "vespa.dns.suffix";
AthenzProviderServiceConfig config = getAthenzProviderConfig("domain", "service", dnsSuffix, ZONE);
IdentityDocumentGenerator identityDocumentGenerator = new IdentityDocumentGenerator(config, nodeRepository, ZONE, keyProvider);
SignedIdentityDocument signedIdentityDocument = identityDocumentGenerator.generateSignedIdentityDocument(hostname);
// Verify attributes
assertEquals(hostname, signedIdentityDocument.identityDocument.instanceHostname);
String environment = "dev";
String region = "us-north-1";
String expectedZoneDnsSuffix = environment + "-" + region + "." + dnsSuffix;
assertEquals(expectedZoneDnsSuffix, signedIdentityDocument.dnsSuffix);
ProviderUniqueId expectedProviderUniqueId = new ProviderUniqueId("tenant", "application", environment, region, "default", "default", 0);
assertEquals(expectedProviderUniqueId, signedIdentityDocument.identityDocument.providerUniqueId);
// Validate signature
assertTrue("Message", InstanceValidator.isSignatureValid(keyProvider.getPublicKey(0), signedIdentityDocument.rawIdentityDocument, signedIdentityDocument.signature));
}
use of com.yahoo.config.provision.ApplicationId in project vespa by vespa-engine.
the class ApplicationRepository method verifyTenantAndApplication.
public Tenant verifyTenantAndApplication(ApplicationId applicationId) {
TenantName tenantName = applicationId.tenant();
if (!tenants.checkThatTenantExists(tenantName)) {
throw new IllegalArgumentException("Tenant " + tenantName + " was not found.");
}
Tenant tenant = tenants.getTenant(tenantName);
List<ApplicationId> applicationIds = listApplicationIds(tenant);
if (!applicationIds.contains(applicationId)) {
throw new IllegalArgumentException("No such application id: " + applicationId);
}
return tenant;
}
use of com.yahoo.config.provision.ApplicationId in project vespa by vespa-engine.
the class ApplicationRepository method redeployAllApplications.
void redeployAllApplications() throws InterruptedException {
ExecutorService executor = Executors.newFixedThreadPool(configserverConfig.numParallelTenantLoaders(), new DaemonThreadFactory("redeploy apps"));
// Keep track of deployment per application
Map<ApplicationId, Future<?>> futures = new HashMap<>();
tenants.getAllTenants().forEach(tenant -> listApplicationIds(tenant).forEach(appId -> deployFromLocalActive(appId).ifPresent(deployment -> futures.put(appId, executor.submit(deployment::activate)))));
for (Map.Entry<ApplicationId, Future<?>> f : futures.entrySet()) {
try {
f.getValue().get();
} catch (ExecutionException e) {
throw new RuntimeException("Redeploying of " + f.getKey() + " failed", e);
}
}
executor.shutdown();
// Timeout should never happen
executor.awaitTermination(365, TimeUnit.DAYS);
}
use of com.yahoo.config.provision.ApplicationId in project vespa by vespa-engine.
the class SessionZooKeeperClientTest method assertApplicationIdParse.
private void assertApplicationIdParse(String sessionId, String idString, String expectedIdString) {
SessionZooKeeperClient zkc = createSessionZKClient(sessionId);
String path = "/" + sessionId + "/" + SessionZooKeeperClient.APPLICATION_ID_PATH;
configCurator.putData(path, idString);
ApplicationId zkId = zkc.readApplicationId();
assertThat(zkId.serializedForm(), is(expectedIdString));
}
use of com.yahoo.config.provision.ApplicationId in project vespa by vespa-engine.
the class SessionZooKeeperClientTest method require_that_application_id_is_read_from_zk.
@Test
public void require_that_application_id_is_read_from_zk() {
ApplicationId id = new ApplicationId.Builder().tenant("tenant").applicationName("bar").instanceName("quux").build();
String idNoVersion = id.serializedForm();
assertApplicationIdParse("3", idNoVersion, idNoVersion);
}
Aggregations