/** * Tests that when we have multiple file systems created/destroyed * metrics from each are published correctly. * @throws Exception */ @Test public void testMetricsAcrossFileSystems() throws Exception { AzureBlobStorageTestAccount a1, a2, a3; a1 = AzureBlobStorageTestAccount.createMock(); assertEquals(0, getFilesCreated(a1)); a2 = AzureBlobStorageTestAccount.createMock(); assertEquals(0, getFilesCreated(a2)); a1.getFileSystem().create(new Path("/foo")).close(); a1.getFileSystem().create(new Path("/bar")).close(); a2.getFileSystem().create(new Path("/baz")).close(); assertEquals(0, getFilesCreated(a1)); assertEquals(0, getFilesCreated(a2)); a1.closeFileSystem(); // Causes the file system to close, which publishes metrics a2.closeFileSystem(); assertEquals(2, getFilesCreated(a1)); assertEquals(1, getFilesCreated(a2)); a3 = AzureBlobStorageTestAccount.createMock(); assertEquals(0, getFilesCreated(a3)); a3.closeFileSystem(); assertEquals(0, getFilesCreated(a3)); }
@Test public void testSkipMetricsCollection() throws Exception { AzureBlobStorageTestAccount a; a = AzureBlobStorageTestAccount.createMock(); a.getFileSystem().getConf().setBoolean( NativeAzureFileSystem.SKIP_AZURE_METRICS_PROPERTY_NAME, true); a.getFileSystem().create(new Path("/foo")).close(); a.closeFileSystem(); // Causes the file system to close, which publishes metrics assertEquals(0, getFilesCreated(a)); }
@Before public void setUp() throws Exception { testAccount = AzureBlobStorageTestAccount.create(); if (testAccount != null) { fs = testAccount.getFileSystem(); } assumeNotNull(testAccount); }
private static int getFilesCreated(AzureBlobStorageTestAccount testAccount) { return testAccount.getLatestMetricValue(WASB_FILES_CREATED, 0).intValue(); }