HDDS-1917. TestOzoneRpcClientAbstract is failing.
Signed-off-by: Anu Engineer <aengineer@apache.org>
This commit is contained in:
parent
cb390dff87
commit
3cff73aff4
@ -26,6 +26,7 @@
|
|||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.Optional;
|
||||||
import java.util.TreeMap;
|
import java.util.TreeMap;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
import java.util.concurrent.CountDownLatch;
|
import java.util.concurrent.CountDownLatch;
|
||||||
@ -2456,31 +2457,30 @@ private void validateOzoneAccessAcl(OzoneObj ozObj) throws IOException {
|
|||||||
ACLType.READ_ACL, ACCESS);
|
ACLType.READ_ACL, ACCESS);
|
||||||
// Verify that operation successful.
|
// Verify that operation successful.
|
||||||
assertTrue(store.addAcl(ozObj, newAcl));
|
assertTrue(store.addAcl(ozObj, newAcl));
|
||||||
List<OzoneAcl> acls = store.getAcl(ozObj);
|
|
||||||
|
|
||||||
assertTrue(acls.size() == expectedAcls.size());
|
assertEquals(expectedAcls.size(), store.getAcl(ozObj).size());
|
||||||
boolean aclVerified = false;
|
final Optional<OzoneAcl> readAcl = store.getAcl(ozObj).stream()
|
||||||
for(OzoneAcl acl: acls) {
|
.filter(acl -> acl.getName().equals(newAcl.getName())
|
||||||
if(acl.getName().equals(newAcl.getName())) {
|
&& acl.getType().equals(newAcl.getType()))
|
||||||
assertTrue(acl.getAclList().contains(ACLType.READ_ACL));
|
.findFirst();
|
||||||
aclVerified = true;
|
assertTrue("New acl expected but not found.", readAcl.isPresent());
|
||||||
}
|
assertTrue("READ_ACL should exist in current acls:"
|
||||||
}
|
+ readAcl.get(),
|
||||||
assertTrue("New acl expected but not found.", aclVerified);
|
readAcl.get().getAclList().contains(ACLType.READ_ACL));
|
||||||
aclVerified = false;
|
|
||||||
|
|
||||||
// Case:2 Remove newly added acl permission.
|
// Case:2 Remove newly added acl permission.
|
||||||
assertTrue(store.removeAcl(ozObj, newAcl));
|
assertTrue(store.removeAcl(ozObj, newAcl));
|
||||||
acls = store.getAcl(ozObj);
|
|
||||||
assertTrue(acls.size() == expectedAcls.size());
|
assertEquals(expectedAcls.size(), store.getAcl(ozObj).size());
|
||||||
for(OzoneAcl acl: acls) {
|
final Optional<OzoneAcl> nonReadAcl = store.getAcl(ozObj).stream()
|
||||||
if(acl.getName().equals(newAcl.getName())) {
|
.filter(acl -> acl.getName().equals(newAcl.getName())
|
||||||
assertFalse("READ_ACL should not exist in current acls:" +
|
&& acl.getType().equals(newAcl.getType()))
|
||||||
acls, acl.getAclList().contains(ACLType.READ_ACL));
|
.findFirst();
|
||||||
aclVerified = true;
|
assertTrue("New acl expected but not found.", nonReadAcl.isPresent());
|
||||||
}
|
assertFalse("READ_ACL should not exist in current acls:"
|
||||||
}
|
+ nonReadAcl.get(),
|
||||||
assertTrue("New acl expected but not found.", aclVerified);
|
nonReadAcl.get().getAclList().contains(ACLType.READ_ACL));
|
||||||
} else {
|
} else {
|
||||||
fail("Default acl should not be empty.");
|
fail("Default acl should not be empty.");
|
||||||
}
|
}
|
||||||
@ -2493,17 +2493,17 @@ private void validateOzoneAccessAcl(OzoneObj ozObj) throws IOException {
|
|||||||
store.removeAcl(ozObj, a);
|
store.removeAcl(ozObj, a);
|
||||||
}
|
}
|
||||||
List<OzoneAcl> newAcls = store.getAcl(ozObj);
|
List<OzoneAcl> newAcls = store.getAcl(ozObj);
|
||||||
assertTrue(newAcls.size() == 0);
|
assertEquals(0, newAcls.size());
|
||||||
|
|
||||||
// Add acl's and then call getAcl.
|
// Add acl's and then call getAcl.
|
||||||
int aclCount = 0;
|
int aclCount = 0;
|
||||||
for (OzoneAcl a : expectedAcls) {
|
for (OzoneAcl a : expectedAcls) {
|
||||||
aclCount++;
|
aclCount++;
|
||||||
assertTrue(store.addAcl(ozObj, a));
|
assertTrue(store.addAcl(ozObj, a));
|
||||||
assertTrue(store.getAcl(ozObj).size() == aclCount);
|
assertEquals(aclCount, store.getAcl(ozObj).size());
|
||||||
}
|
}
|
||||||
newAcls = store.getAcl(ozObj);
|
newAcls = store.getAcl(ozObj);
|
||||||
assertTrue(newAcls.size() == expectedAcls.size());
|
assertEquals(expectedAcls.size(), newAcls.size());
|
||||||
List<OzoneAcl> finalNewAcls = newAcls;
|
List<OzoneAcl> finalNewAcls = newAcls;
|
||||||
expectedAcls.forEach(a -> assertTrue(finalNewAcls.contains(a)));
|
expectedAcls.forEach(a -> assertTrue(finalNewAcls.contains(a)));
|
||||||
|
|
||||||
@ -2514,7 +2514,7 @@ private void validateOzoneAccessAcl(OzoneObj ozObj) throws IOException {
|
|||||||
ACLType.ALL, ACCESS);
|
ACLType.ALL, ACCESS);
|
||||||
store.setAcl(ozObj, Arrays.asList(ua, ug));
|
store.setAcl(ozObj, Arrays.asList(ua, ug));
|
||||||
newAcls = store.getAcl(ozObj);
|
newAcls = store.getAcl(ozObj);
|
||||||
assertTrue(newAcls.size() == 2);
|
assertEquals(2, newAcls.size());
|
||||||
assertTrue(newAcls.contains(ua));
|
assertTrue(newAcls.contains(ua));
|
||||||
assertTrue(newAcls.contains(ug));
|
assertTrue(newAcls.contains(ug));
|
||||||
}
|
}
|
||||||
|
@ -77,6 +77,7 @@
|
|||||||
import org.apache.hadoop.ozone.om.helpers.OpenKeySession;
|
import org.apache.hadoop.ozone.om.helpers.OpenKeySession;
|
||||||
import org.apache.hadoop.ozone.om.helpers.OzoneFSUtils;
|
import org.apache.hadoop.ozone.om.helpers.OzoneFSUtils;
|
||||||
import org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.OzoneAclInfo;
|
import org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.OzoneAclInfo;
|
||||||
|
import org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.OzoneAclInfo.OzoneAclType;
|
||||||
import org.apache.hadoop.ozone.security.OzoneBlockTokenSecretManager;
|
import org.apache.hadoop.ozone.security.OzoneBlockTokenSecretManager;
|
||||||
import org.apache.hadoop.ozone.security.acl.OzoneObj;
|
import org.apache.hadoop.ozone.security.acl.OzoneObj;
|
||||||
import org.apache.hadoop.ozone.security.acl.RequestContext;
|
import org.apache.hadoop.ozone.security.acl.RequestContext;
|
||||||
@ -1406,7 +1407,8 @@ public boolean addAcl(OzoneObj obj, OzoneAcl acl) throws IOException {
|
|||||||
List<OzoneAclInfo> newAcls = new ArrayList<>(keyInfo.getAcls());
|
List<OzoneAclInfo> newAcls = new ArrayList<>(keyInfo.getAcls());
|
||||||
OzoneAclInfo newAcl = null;
|
OzoneAclInfo newAcl = null;
|
||||||
for(OzoneAclInfo a: keyInfo.getAcls()) {
|
for(OzoneAclInfo a: keyInfo.getAcls()) {
|
||||||
if(a.getName().equals(acl.getName())) {
|
if (a.getName().equals(acl.getName()) &&
|
||||||
|
a.getType().equals(OzoneAclType.valueOf(acl.getType().name()))) {
|
||||||
BitSet currentAcls = BitSet.valueOf(a.getRights().toByteArray());
|
BitSet currentAcls = BitSet.valueOf(a.getRights().toByteArray());
|
||||||
currentAcls.or(acl.getAclBitSet());
|
currentAcls.or(acl.getAclBitSet());
|
||||||
|
|
||||||
@ -1483,7 +1485,8 @@ public boolean removeAcl(OzoneObj obj, OzoneAcl acl) throws IOException {
|
|||||||
} else {
|
} else {
|
||||||
// Acl to be removed might be a subset of existing acls.
|
// Acl to be removed might be a subset of existing acls.
|
||||||
for(OzoneAclInfo a: keyInfo.getAcls()) {
|
for(OzoneAclInfo a: keyInfo.getAcls()) {
|
||||||
if(a.getName().equals(acl.getName())) {
|
if (a.getName().equals(acl.getName()) &&
|
||||||
|
a.getType().equals(OzoneAclType.valueOf(acl.getType().name()))) {
|
||||||
BitSet currentAcls = BitSet.valueOf(a.getRights().toByteArray());
|
BitSet currentAcls = BitSet.valueOf(a.getRights().toByteArray());
|
||||||
acl.getAclBitSet().xor(currentAcls);
|
acl.getAclBitSet().xor(currentAcls);
|
||||||
currentAcls.and(acl.getAclBitSet());
|
currentAcls.and(acl.getAclBitSet());
|
||||||
|
Loading…
Reference in New Issue
Block a user