Skip to content

Commit

Permalink
Test for ConnId operation timeouts (MID-4773)
Browse files Browse the repository at this point in the history
  • Loading branch information
semancik committed Oct 15, 2018
1 parent ce12af6 commit 615db51
Show file tree
Hide file tree
Showing 24 changed files with 611 additions and 160 deletions.
Expand Up @@ -24,6 +24,7 @@
import org.identityconnectors.framework.common.exceptions.ConnectorIOException;
import org.identityconnectors.framework.common.exceptions.InvalidAttributeValueException;
import org.identityconnectors.framework.common.exceptions.InvalidPasswordException;
import org.identityconnectors.framework.common.exceptions.OperationTimeoutException;
import org.identityconnectors.framework.common.exceptions.UnknownUidException;
import org.identityconnectors.framework.common.objects.*;

Expand Down Expand Up @@ -291,6 +292,8 @@ public Uid create(final ObjectClass objectClass, final Set<Attribute> createAttr
throw new InvalidAttributeValueException(e);
} catch (ConflictException e) {
throw new AlreadyExistsException(e);
} catch (InterruptedException e) {
throw new OperationTimeoutException(e);
}

String id;
Expand Down Expand Up @@ -377,6 +380,9 @@ public void delete(final ObjectClass objectClass, final Uid uid, final Operation
} catch (ConflictException e) {
log.info("delete::exception "+e);
throw new AlreadyExistsException(e);
} catch (InterruptedException e) {
log.info("delete::exception "+e);
throw new OperationTimeoutException(e);
}

log.info("delete::end");
Expand Down Expand Up @@ -492,6 +498,8 @@ private ObjectClassInfo createAccountObjectClass(boolean supportsActivation) thr
throw new ConnectorIOException(e.getMessage(), e);
} catch (IllegalArgumentException e) {
throw new ConnectorException(e.getMessage(), e);
} catch (InterruptedException e) {
throw new OperationTimeoutException(e);
} // DO NOT catch IllegalStateException, let it pass

ObjectClassInfoBuilder objClassBuilder = createCommonObjectClassBuilder(getAccountObjectClassName(), dummyAccountObjectClass, supportsActivation);
Expand Down Expand Up @@ -680,13 +688,16 @@ public void executeQuery(ObjectClass objectClass, Filter query, ResultsHandler h
} catch (ConflictException e) {
log.info("executeQuery::exception "+e);
throw new AlreadyExistsException(e);
} catch (InterruptedException e) {
log.info("executeQuery::exception "+e);
throw new OperationTimeoutException(e);
}

log.info("executeQuery::end");
}

private <T extends DummyObject> void search(ObjectClass objectClass, Filter query, ResultsHandler handler, OperationOptions options,
Lister<T> lister, Getter<T> nameGetter, Getter<T> idGetter, Converter<T> converter, Consumer<T> recorder) throws ConnectException, FileNotFoundException, SchemaViolationException, ConflictException {
Lister<T> lister, Getter<T> nameGetter, Getter<T> idGetter, Converter<T> converter, Consumer<T> recorder) throws ConnectException, FileNotFoundException, SchemaViolationException, ConflictException, InterruptedException {
Collection<String> attributesToGet = getAttrsToGet(options);
log.ok("attributesToGet={0}", attributesToGet);

Expand Down Expand Up @@ -846,12 +857,12 @@ private boolean isEqualsFilter(Filter icfFilter, String icfAttrname) {

@FunctionalInterface
interface Lister<T> {
Collection<T> list() throws ConnectException, FileNotFoundException, SchemaViolationException, ConflictException;
Collection<T> list() throws ConnectException, FileNotFoundException, SchemaViolationException, ConflictException, InterruptedException;
}

@FunctionalInterface
interface Getter<T> {
T get(String id) throws ConnectException, FileNotFoundException, SchemaViolationException, ConflictException;
T get(String id) throws ConnectException, FileNotFoundException, SchemaViolationException, ConflictException, InterruptedException;
}

@FunctionalInterface
Expand Down Expand Up @@ -1110,6 +1121,9 @@ public void sync(ObjectClass objectClass, SyncToken token, SyncResultsHandler ha
} catch (ConflictException e) {
log.info("sync::exception "+e);
throw new AlreadyExistsException(e);
} catch (InterruptedException e) {
log.info("sync::exception "+e);
throw new OperationTimeoutException(e);
}

log.info("sync::end");
Expand Down Expand Up @@ -1281,6 +1295,9 @@ private ConnectorObject convertToConnectorObject(DummyAccount account, Collectio
} catch (ConflictException e) {
log.error(e, e.getMessage());
throw new AlreadyExistsException(e);
} catch (InterruptedException e) {
log.error(e, e.getMessage());
throw new OperationTimeoutException(e);
}

ConnectorObjectBuilder builder = createConnectorObjectBuilderCommon(account, objectClass, attributesToGet, true);
Expand Down Expand Up @@ -1332,7 +1349,7 @@ private ConnectorObject convertToConnectorObject(DummyOrg org, Collection<String
return builder.build();
}

private DummyAccount convertToAccount(Set<Attribute> createAttributes) throws ConnectException, FileNotFoundException, SchemaViolationException, ConflictException {
private DummyAccount convertToAccount(Set<Attribute> createAttributes) throws ConnectException, FileNotFoundException, SchemaViolationException, ConflictException, InterruptedException {
log.ok("Create attributes: {0}", createAttributes);
String userName = Utils.getMandatoryStringAttribute(createAttributes, Name.NAME);
if (configuration.getUpCaseName()) {
Expand Down Expand Up @@ -1399,7 +1416,7 @@ private DummyAccount convertToAccount(Set<Attribute> createAttributes) throws Co
return newAccount;
}

private DummyGroup convertToGroup(Set<Attribute> createAttributes) throws ConnectException, FileNotFoundException, SchemaViolationException, ConflictException {
private DummyGroup convertToGroup(Set<Attribute> createAttributes) throws ConnectException, FileNotFoundException, SchemaViolationException, ConflictException, InterruptedException {
String icfName = Utils.getMandatoryStringAttribute(createAttributes,Name.NAME);
if (configuration.getUpCaseName()) {
icfName = StringUtils.upperCase(icfName);
Expand Down Expand Up @@ -1474,6 +1491,8 @@ private DummyPrivilege convertToPriv(Set<Attribute> createAttributes) throws Con
newPriv.replaceAttributeValues(name,attr.getValue());
} catch (SchemaViolationException e) {
throw new InvalidAttributeValueException(e.getMessage(),e);
} catch (InterruptedException e) {
throw new OperationTimeoutException(e.getMessage(),e);
}
}
}
Expand Down Expand Up @@ -1507,6 +1526,8 @@ private DummyOrg convertToOrg(Set<Attribute> createAttributes) throws ConnectExc
newOrg.replaceAttributeValues(name,attr.getValue());
} catch (SchemaViolationException e) {
throw new IllegalArgumentException(e.getMessage(),e);
} catch (InterruptedException e) {
throw new OperationTimeoutException(e.getMessage(),e);
}
}
}
Expand Down Expand Up @@ -1623,7 +1644,7 @@ private boolean attributesToGetHasAttribute(Collection<String> attributesToGet,
return attributesToGet.contains(attrName);
}

protected void applyModifyMetadata(DummyObject object, OperationOptions options) throws ConnectException, FileNotFoundException, SchemaViolationException, ConflictException {
protected void applyModifyMetadata(DummyObject object, OperationOptions options) throws ConnectException, FileNotFoundException, SchemaViolationException, ConflictException, InterruptedException {
String runAsUser = options.getRunAsUser();
if (runAsUser != null) {
if (!configuration.getSupportRunAs()) {
Expand Down
Expand Up @@ -24,6 +24,7 @@
import org.identityconnectors.framework.common.exceptions.ConnectorIOException;
import org.identityconnectors.framework.common.exceptions.InvalidAttributeValueException;
import org.identityconnectors.framework.common.exceptions.InvalidPasswordException;
import org.identityconnectors.framework.common.exceptions.OperationTimeoutException;
import org.identityconnectors.framework.common.exceptions.UnknownUidException;
import org.identityconnectors.framework.common.objects.*;

Expand Down Expand Up @@ -342,6 +343,9 @@ public Set<AttributeDelta> updateDelta(final ObjectClass objectClass, final Uid
} catch (ConflictException e) {
log.info("update::exception "+e);
throw new AlreadyExistsException(e);
} catch (InterruptedException e) {
log.info("update::exception "+e);
throw new OperationTimeoutException(e);
}

log.info("update::end {0}", instanceName);
Expand Down Expand Up @@ -390,7 +394,9 @@ private <T> void applyOrdinaryAttributeDelta(DummyObject dummyObject, AttributeD
} catch (SchemaViolationException e) {
// Note: let's do the bad thing and add exception loaded by this classloader as inner exception here
// The framework should deal with it ... somehow
throw new InvalidAttributeValueException(e.getMessage(),e);
throw new InvalidAttributeValueException(e.getMessage(), e);
} catch (InterruptedException e) {
throw new OperationTimeoutException(e.getMessage(), e);
}

}
Expand Down
Expand Up @@ -23,6 +23,7 @@
import org.identityconnectors.framework.common.exceptions.ConnectorException;
import org.identityconnectors.framework.common.exceptions.ConnectorIOException;
import org.identityconnectors.framework.common.exceptions.InvalidAttributeValueException;
import org.identityconnectors.framework.common.exceptions.OperationTimeoutException;
import org.identityconnectors.framework.common.exceptions.UnknownUidException;
import org.identityconnectors.framework.common.objects.*;

Expand Down Expand Up @@ -321,6 +322,9 @@ public Uid update(ObjectClass objectClass, Uid uid, Set<Attribute> replaceAttrib
} catch (ConflictException e) {
log.info("update::exception "+e);
throw new AlreadyExistsException(e);
} catch (InterruptedException e) {
log.info("update::exception "+e);
throw new OperationTimeoutException(e);
}

log.info("update::end");
Expand Down Expand Up @@ -518,6 +522,9 @@ public Uid addAttributeValues(ObjectClass objectClass, Uid uid, Set<Attribute> v
} catch (ConflictException e) {
log.info("addAttributeValues::exception "+e);
throw new AlreadyExistsException(e);
} catch (InterruptedException e) {
log.info("addAttributeValues::exception "+e);
throw new OperationTimeoutException(e);
}

return uid;
Expand Down Expand Up @@ -698,6 +705,9 @@ public Uid removeAttributeValues(ObjectClass objectClass, Uid uid, Set<Attribute
} catch (ConflictException e) {
log.info("removeAttributeValues::exception "+e);
throw new AlreadyExistsException(e);
} catch (InterruptedException e) {
log.info("removeAttributeValues::exception "+e);
throw new OperationTimeoutException(e);
}

return uid;
Expand Down
Expand Up @@ -62,7 +62,7 @@ public void setLockout(boolean lockout) throws ConnectException, FileNotFoundExc
}

@Override
protected DummyObjectClass getObjectClass() throws ConnectException, FileNotFoundException, SchemaViolationException, ConflictException {
protected DummyObjectClass getObjectClass() throws ConnectException, FileNotFoundException, SchemaViolationException, ConflictException, InterruptedException {
return resource.getAccountObjectClass();
}

Expand Down
Expand Up @@ -41,7 +41,7 @@ public Collection<String> getMembers() {
return getAttributeValues(ATTR_MEMBERS_NAME, String.class);
}

public void addMember(String newMember) throws SchemaViolationException, ConnectException, FileNotFoundException, ConflictException {
public void addMember(String newMember) throws SchemaViolationException, ConnectException, FileNotFoundException, ConflictException, InterruptedException {
addAttributeValue(ATTR_MEMBERS_NAME, newMember);
}

Expand All @@ -53,7 +53,7 @@ public boolean containsMember(String member) {
return members.contains(member); // TODO ok? what about case ignoring scenarios?
}

public void removeMember(String newMember) throws SchemaViolationException, ConnectException, FileNotFoundException, ConflictException {
public void removeMember(String newMember) throws SchemaViolationException, ConnectException, FileNotFoundException, ConflictException, InterruptedException {
removeAttributeValue(ATTR_MEMBERS_NAME, newMember);
}

Expand Down
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2010-2017 Evolveum
* Copyright (c) 2010-2018 Evolveum
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -89,7 +89,7 @@ public Boolean isEnabled() {
return enabled;
}

public void setEnabled(Boolean enabled) throws ConnectException, FileNotFoundException, SchemaViolationException, ConflictException {
public void setEnabled(Boolean enabled) throws ConnectException, FileNotFoundException, SchemaViolationException, ConflictException, InterruptedException {
checkModifyBreak();
delayOperation();
this.enabled = enabled;
Expand All @@ -100,7 +100,7 @@ public Date getValidFrom() {
return validFrom;
}

public void setValidFrom(Date validFrom) throws ConnectException, FileNotFoundException, SchemaViolationException, ConflictException {
public void setValidFrom(Date validFrom) throws ConnectException, FileNotFoundException, SchemaViolationException, ConflictException, InterruptedException {
checkModifyBreak();
delayOperation();
this.validFrom = validFrom;
Expand All @@ -111,7 +111,7 @@ public Date getValidTo() {
return validTo;
}

public void setValidTo(Date validTo) throws ConnectException, FileNotFoundException, SchemaViolationException, ConflictException {
public void setValidTo(Date validTo) throws ConnectException, FileNotFoundException, SchemaViolationException, ConflictException, InterruptedException {
checkModifyBreak();
delayOperation();
this.validTo = validTo;
Expand Down Expand Up @@ -158,13 +158,13 @@ public String getAttributeValue(String attrName) {
return getAttributeValue(attrName,String.class);
}

public void replaceAttributeValue(String name, Object value) throws SchemaViolationException, ConnectException, FileNotFoundException, SchemaViolationException, ConflictException {
public void replaceAttributeValue(String name, Object value) throws SchemaViolationException, ConnectException, FileNotFoundException, SchemaViolationException, ConflictException, InterruptedException {
Collection<Object> values = new ArrayList<>(1);
values.add(value);
replaceAttributeValues(name, values);
}

public void replaceAttributeValues(String name, Collection<Object> values) throws SchemaViolationException, ConnectException, FileNotFoundException, SchemaViolationException, ConflictException {
public void replaceAttributeValues(String name, Collection<Object> values) throws SchemaViolationException, ConnectException, FileNotFoundException, SchemaViolationException, ConflictException, InterruptedException {
checkModifyBreak();
delayOperation();
Set<Object> currentValues = attributes.get(name);
Expand All @@ -179,7 +179,7 @@ public void replaceAttributeValues(String name, Collection<Object> values) throw
recordModify();
}

public void replaceAttributeValues(String name, Object... values) throws SchemaViolationException, ConnectException, FileNotFoundException, SchemaViolationException, ConflictException {
public void replaceAttributeValues(String name, Object... values) throws SchemaViolationException, ConnectException, FileNotFoundException, SchemaViolationException, ConflictException, InterruptedException {
checkModifyBreak();
delayOperation();
Set<Object> currentValues = attributes.get(name);
Expand All @@ -198,13 +198,13 @@ public void replaceAttributeValues(String name, Object... values) throws SchemaV
recordModify();
}

public void addAttributeValue(String name, Object value) throws SchemaViolationException, ConnectException, FileNotFoundException, SchemaViolationException, ConflictException {
public void addAttributeValue(String name, Object value) throws SchemaViolationException, ConnectException, FileNotFoundException, SchemaViolationException, ConflictException, InterruptedException {
Collection<Object> values = new ArrayList<>(1);
values.add(value);
addAttributeValues(name, values);
}

public <T> void addAttributeValues(String name, Collection<T> valuesToAdd) throws SchemaViolationException, ConnectException, FileNotFoundException, SchemaViolationException, ConflictException {
public <T> void addAttributeValues(String name, Collection<T> valuesToAdd) throws SchemaViolationException, ConnectException, FileNotFoundException, SchemaViolationException, ConflictException, InterruptedException {
checkModifyBreak();
delayOperation();
Set<Object> currentValues = attributes.get(name);
Expand All @@ -218,7 +218,7 @@ public <T> void addAttributeValues(String name, Collection<T> valuesToAdd) throw
recordModify();
}

public void addAttributeValues(String name, String... valuesToAdd) throws SchemaViolationException, ConnectException, FileNotFoundException, SchemaViolationException, ConflictException {
public void addAttributeValues(String name, String... valuesToAdd) throws SchemaViolationException, ConnectException, FileNotFoundException, SchemaViolationException, ConflictException, InterruptedException {
checkModifyBreak();
delayOperation();
Set<Object> currentValues = attributes.get(name);
Expand All @@ -232,7 +232,7 @@ public void addAttributeValues(String name, String... valuesToAdd) throws Schema
recordModify();
}

private void addAttributeValue(String attrName, Set<Object> currentValues, Object valueToAdd) throws SchemaViolationException, ConnectException, FileNotFoundException, SchemaViolationException, ConflictException {
private void addAttributeValue(String attrName, Set<Object> currentValues, Object valueToAdd) throws SchemaViolationException, ConnectException, FileNotFoundException, SchemaViolationException, ConflictException, InterruptedException {
checkModifyBreak();
delayOperation();
if (resource != null && !resource.isTolerateDuplicateValues()) {
Expand Down Expand Up @@ -265,13 +265,13 @@ private void addAttributeValue(String attrName, Set<Object> currentValues, Objec
currentValues.add(valueToAdd);
}

public void removeAttributeValue(String name, Object value) throws SchemaViolationException, ConnectException, FileNotFoundException, SchemaViolationException, ConflictException {
public void removeAttributeValue(String name, Object value) throws SchemaViolationException, ConnectException, FileNotFoundException, SchemaViolationException, ConflictException, InterruptedException {
Collection<Object> values = new ArrayList<>();
values.add(value);
removeAttributeValues(name, values);
}

public <T> void removeAttributeValues(String name, Collection<T> values) throws SchemaViolationException, ConnectException, FileNotFoundException, SchemaViolationException, ConflictException {
public <T> void removeAttributeValues(String name, Collection<T> values) throws SchemaViolationException, ConnectException, FileNotFoundException, SchemaViolationException, ConflictException, InterruptedException {
checkModifyBreak();
delayOperation();
Set<Object> currentValues = attributes.get(name);
Expand Down Expand Up @@ -403,7 +403,7 @@ private void recordModify() {
}
}

private void delayOperation() {
private void delayOperation() throws InterruptedException {
if (resource != null) {
resource.delayOperation();
}
Expand Down Expand Up @@ -454,7 +454,7 @@ public DummyAttributeDefinition getAttributeDefinition(String attrName) {
return null;
}

abstract protected DummyObjectClass getObjectClass() throws ConnectException, FileNotFoundException, SchemaViolationException, ConflictException;
abstract protected DummyObjectClass getObjectClass() throws ConnectException, FileNotFoundException, SchemaViolationException, ConflictException, InterruptedException;

abstract protected DummyObjectClass getObjectClassNoExceptions();

Expand Down

0 comments on commit 615db51

Please sign in to comment.