steveloughran commented on code in PR #6003:
URL: https://github.com/apache/hadoop/pull/6003#discussion_r1310605905
##########
hadoop-tools/hadoop-azure/src/test/java/org/apache/hadoop/fs/azurebfs/ITestAzureBlobFileSystemAttributes.java:
##########
@@ -110,4 +86,51 @@ public void testSetGetXAttrReplace() throws Exception {
fs.setXAttr(testFile, attributeName, attributeValue2, REPLACE_FLAG);
assertArrayEquals(attributeValue2, fs.getXAttr(testFile, attributeName));
}
+
+ @Test
+ public void testGetSetXAttrOnRoot() throws Exception {
+ AzureBlobFileSystem fs = getFileSystem();
+ final Path testPath = new Path("/");
+ testGetSetXAttrHelper(fs, testPath);
+ }
+
+ private void testGetSetXAttrHelper(final AzureBlobFileSystem fs,
+ final Path testPath) throws Exception {
+
+ String attributeName1 = "user.attribute1";
+ String attributeName2 = "user.attribute2";
+ String decodedAttributeValue1 = "hi";
+ String decodedAttributeValue2 = "hello";
+ byte[] attributeValue1 =
fs.getAbfsStore().encodeAttribute(decodedAttributeValue1);
+ byte[] attributeValue2 =
fs.getAbfsStore().encodeAttribute(decodedAttributeValue2);
+
+ // Attribute not present initially
+ assertNull(fs.getXAttr(testPath, attributeName1));
+ assertNull(fs.getXAttr(testPath, attributeName2));
+
+ // Set the Attributes
+ fs.registerListener(
+ new TracingHeaderValidator(fs.getAbfsStore().getAbfsConfiguration()
+ .getClientCorrelationId(),
+ fs.getFileSystemId(), FSOperationType.SET_ATTR, true, 0));
+ fs.setXAttr(testPath, attributeName1, attributeValue1);
+
+ // Check if the attribute is retrievable
+ fs.setListenerOperation(FSOperationType.GET_ATTR);
+ byte[] rv = fs.getXAttr(testPath, attributeName1);
+ assertTrue(Arrays.equals(rv, attributeValue1));
+ assertEquals(decodedAttributeValue1,
fs.getAbfsStore().decodeAttribute(rv));
+ fs.registerListener(null);
+
+ // Set the second Attribute
+ fs.setXAttr(testPath, attributeName2, attributeValue2);
+
+ // Check all the attributes present and previous Attribute not overridden
+ rv = fs.getXAttr(testPath, attributeName1);
+ assertTrue(Arrays.equals(rv, attributeValue1));
Review Comment:
same comments as above. remember i always insist on a description, and want
assertJ for anything where it makes sense. save time by doing this from the
start
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]