use of com.facebook.buck.artifact_cache.ArtifactCache in project buck by facebook.
the class ServedCacheIntegrationTest method fullStackIntegrationTest.
@Test
public void fullStackIntegrationTest() throws Exception {
webServer = new WebServer(/* port */
0, projectFilesystem, "/static/", MAPPER);
webServer.updateAndStartIfNeeded(ArtifactCaches.newServedCache(createMockLocalConfig("[cache]", "dir = test-cache", "serve_local_cache = true", "served_local_cache_mode = readonly"), projectFilesystem));
ArtifactCache serverBackedCache = createArtifactCache(createMockLocalConfig("[cache]", "mode = dir,http", "two_level_cache_enabled=true", "two_level_cache_minimum_size=0b", "dir = server-backed-dir-cache", String.format("http_url = http://127.0.0.1:%d/", webServer.getPort().get())));
ArtifactCache serverBackedDirCache = createArtifactCache(createMockLocalConfig("[cache]", "mode = dir", "dir = server-backed-dir-cache"));
assertFalse(containsKey(serverBackedDirCache, A_FILE_RULE_KEY));
assertTrue(containsKey(serverBackedCache, A_FILE_RULE_KEY));
// The previous call should have propagated the key into the dir-cache.
assertTrue(containsKey(serverBackedDirCache, A_FILE_RULE_KEY));
RuleKey ruleKey = new RuleKey("00111222333444");
ImmutableMap<String, String> metadata = ImmutableMap.of("some key", "some value");
Path originalDataPath = tmpDir.newFile();
String data = "you won't believe this!";
projectFilesystem.writeContentsToPath(data, originalDataPath);
assertFalse(containsKey(serverBackedCache, ruleKey));
serverBackedCache.store(ArtifactInfo.builder().addRuleKeys(ruleKey).setMetadata(metadata).build(), BorrowablePath.borrowablePath(originalDataPath)).get();
assertTrue(containsKey(serverBackedCache, ruleKey));
assertTrue(containsKey(serverBackedDirCache, ruleKey));
}
Aggregations