Skip to content

Commit

Permalink
Adapt and fix TestThresholds et al
Browse files Browse the repository at this point in the history
These tests were adapted to recent changes in counting of objects
in various synchronization situations (see the commit for MID-5406).

Also, treatment of disabled objects was fixed: the policy rule was
not quite correct and so was LDIF import of changes.
  • Loading branch information
mederly committed Mar 6, 2020
1 parent 69a9c3f commit ed8e7b8
Show file tree
Hide file tree
Showing 21 changed files with 193 additions and 137 deletions.
Expand Up @@ -5553,7 +5553,7 @@
<xsd:appinfo>
<a:displayName>AssignmentType.target</a:displayName>
<a:help>AssignmentType.target.help</a:help>
<a:objectReferenceTargetType>tns:FocusType</a:objectReferenceTargetType>
<a:objectReferenceTargetType>tns:AssignmentHolderType</a:objectReferenceTargetType>
</xsd:appinfo>
</xsd:annotation>
</xsd:element>
Expand Down
Expand Up @@ -26,6 +26,7 @@
import org.apache.commons.io.IOUtils;
import org.apache.commons.lang.ArrayUtils;
import org.apache.commons.lang.Validate;
import org.jetbrains.annotations.NotNull;
import org.opends.messages.Message;
import org.opends.messages.MessageBuilder;
import org.opends.server.config.ConfigException;
Expand Down Expand Up @@ -883,28 +884,37 @@ public ChangeRecordEntry executeLdifChange(File file) throws IOException, LDIFEx
LDIFReader ldifReader = new LDIFReader(importConfig);
ChangeRecordEntry entry = ldifReader.readChangeRecord(false);

ModifyOperation modifyOperation = getInternalConnection()
.processModify((ModifyChangeRecordEntry) entry);
return executeChangeInternal(entry);
}

@NotNull
private ChangeRecordEntry executeChangeInternal(ChangeRecordEntry entry) {
ModifyOperation modifyOperation = getInternalConnection().processModify((ModifyChangeRecordEntry) entry);

if (ResultCode.SUCCESS != modifyOperation.getResultCode()) {
throw new RuntimeException("LDAP operation error: "+modifyOperation.getResultCode()+": "+modifyOperation.getErrorMessage());
throw new RuntimeException("LDAP operation error: " + modifyOperation.getResultCode() + ": " + modifyOperation.getErrorMessage());
}
return entry;
}

public void executeLdifChanges(File file) throws IOException, LDIFException {
LDIFImportConfig importConfig = new LDIFImportConfig(file.getPath());
LDIFReader ldifReader = new LDIFReader(importConfig);
for (;;) {
ChangeRecordEntry entry = ldifReader.readChangeRecord(false);
if (entry == null) {
break;
}
executeChangeInternal(entry);
}
}

public ChangeRecordEntry executeLdifChange(String ldif) throws IOException, LDIFException {
InputStream ldifInputStream = IOUtils.toInputStream(ldif, StandardCharsets.UTF_8);
LDIFImportConfig importConfig = new LDIFImportConfig(ldifInputStream);
LDIFReader ldifReader = new LDIFReader(importConfig);
ChangeRecordEntry entry = ldifReader.readChangeRecord(false);

ModifyOperation modifyOperation = getInternalConnection()
.processModify((ModifyChangeRecordEntry) entry);

if (ResultCode.SUCCESS != modifyOperation.getResultCode()) {
throw new RuntimeException("LDAP operation error: "+modifyOperation.getResultCode()+": "+modifyOperation.getErrorMessage());
}
return entry;
return executeChangeInternal(entry);
}

public ChangeRecordEntry modifyReplace(String entryDn, String attributeName, String value) throws IOException, LDIFException {
Expand Down
Expand Up @@ -339,45 +339,25 @@ public void addToPendingAssignmentPolicyStateModifications(@NotNull AssignmentTy
pendingAssignmentPolicyStateModifications.computeIfAbsent(spec, k -> new ArrayList<>()).add(modification);
}

public boolean isAdd() {
if (ObjectDelta.isAdd(getPrimaryDelta())) {
return true;
}
if (ObjectDelta.isAdd(getSecondaryDelta())) {
return true;
}
return false;
}
public abstract boolean isAdd();

public boolean isModify() {
if (ObjectDelta.isModify(getPrimaryDelta())) {
return true;
}
if (ObjectDelta.isModify(getSecondaryDelta())) {
return true;
}
return false;
// TODO I'm not sure why isModify checks both primary and secondary deltas for focus context, while
// isAdd and isDelete care only for the primary delta.
return ObjectDelta.isModify(getPrimaryDelta()) || ObjectDelta.isModify(getSecondaryDelta());
}

public boolean isDelete() {
if (ObjectDelta.isDelete(getPrimaryDelta())) {
return true;
}
if (ObjectDelta.isDelete(getSecondaryDelta())) {
return true;
}
return false;
}
public abstract boolean isDelete();

@NotNull
public SimpleOperationName getOperation() {
if (isAdd()) {
return SimpleOperationName.ADD;
}
if (isDelete()) {
} else if (isDelete()) {
return SimpleOperationName.DELETE;
} else {
return SimpleOperationName.MODIFY;
}
return SimpleOperationName.MODIFY;
}

@NotNull
Expand Down
Expand Up @@ -102,14 +102,13 @@ public ObjectDelta<O> getProjectionWavePrimaryDelta() throws SchemaException {
}

public boolean isDelete() {
return getPrimaryDelta() != null && getPrimaryDelta().isDelete();
return ObjectDelta.isDelete(getPrimaryDelta());
}

public boolean isAdd() {
return getPrimaryDelta() != null && getPrimaryDelta().isAdd();
return ObjectDelta.isAdd(getPrimaryDelta());
}


@Override
public ObjectDelta<O> getSecondaryDelta() {
try {
Expand Down
Expand Up @@ -406,31 +406,31 @@ public void addAccountSyncDelta(ObjectDelta<ShadowType> delta) throws SchemaExce
public boolean isAdd() {
if (synchronizationPolicyDecision == SynchronizationPolicyDecision.ADD) {
return true;
} else if (synchronizationPolicyDecision != null){
} else if (synchronizationPolicyDecision != null) {
return false;
} else {
return ObjectDelta.isAdd(getPrimaryDelta()) || ObjectDelta.isAdd(getSecondaryDelta());
}
return super.isAdd();
}

public boolean isModify() {
if (synchronizationPolicyDecision == SynchronizationPolicyDecision.KEEP) {
return true;
} else if (synchronizationPolicyDecision != null) {
return false;
} else {
return super.isModify();
}
return super.isModify();
}

public boolean isDelete() {
if (synchronizationPolicyDecision == SynchronizationPolicyDecision.DELETE) {
return true;
} else if (synchronizationPolicyDecision != null) {
return false;
} else {
return ObjectDelta.isDelete(syncDelta) || ObjectDelta.isDelete(getPrimaryDelta()) || ObjectDelta.isDelete(getSecondaryDelta());
}
if (syncDelta != null && syncDelta.isDelete()) {
return true;
}
return super.isDelete();
}

public ResourceType getResource() {
Expand Down
Expand Up @@ -378,7 +378,7 @@ public void test300DeleteDummyTeaGreenAccountMancomb() throws Exception {
display("Dummy (tea green) resource", getDummyResource(RESOURCE_DUMMY_TEA_GREEN_NAME).debugDump());

// Make sure we have steady state
waitForTaskResume(TASK_LIVE_SYNC_DUMMY_TEA_GREEN_OID, false, 20000);
resumeTaskAndWaitForNextFinish(TASK_LIVE_SYNC_DUMMY_TEA_GREEN_OID, false, 20000);
waitForSyncTaskNextRun();

// THEN
Expand Down
Expand Up @@ -3519,7 +3519,7 @@ private static OperationResult getSubresult(OperationResult result, boolean chec
return result;
}

protected OperationResult waitForTaskResume(final String taskOid, final boolean checkSubresult, final int timeout) throws Exception {
protected OperationResult resumeTaskAndWaitForNextFinish(final String taskOid, final boolean checkSubresult, final int timeout) throws Exception {
final OperationResult waitResult = new OperationResult(AbstractIntegrationTest.class + ".waitForTaskResume");
Task origTask = taskManager.getTaskWithResult(taskOid, waitResult);

Expand Down Expand Up @@ -3569,7 +3569,7 @@ public void timeout() {
}
}
};
IntegrationTestTools.waitFor("Waiting for task " + origTask + " resume", checker, timeout, DEFAULT_TASK_SLEEP_TIME);
IntegrationTestTools.waitFor("Waiting for resumed task " + origTask + " finish", checker, timeout, DEFAULT_TASK_SLEEP_TIME);

Task freshTask = taskManager.getTaskWithResult(origTask.getOid(), waitResult);
logger.debug("Final task:\n{}", freshTask.debugDump());
Expand Down
Expand Up @@ -2882,8 +2882,8 @@ protected void setGlobalTracingOverrideAll(@NotNull TracingProfileType profile)
taskManager.setGlobalTracingOverride(Arrays.asList(TracingRootType.values()), profile);
}

protected void removeGlobalTracingOverride() {
taskManager.removeGlobalTracingOverride();
protected void unsetGlobalTracingOverride() {
taskManager.unsetGlobalTracingOverride();
}

protected Consumer<PrismObject<TaskType>> workerThreadsCustomizer(int threads) {
Expand Down
Expand Up @@ -785,7 +785,7 @@ String recordTaskThreadsDump(String taskOid, String cause, OperationResult paren
void setGlobalTracingOverride(@NotNull Collection<TracingRootType> roots, @NotNull TracingProfileType profile);

// EXPERIMENTAL
void removeGlobalTracingOverride();
void unsetGlobalTracingOverride();

/**
* @return true if we consider this node to be "up" (alive). This is determined by looking at operational state
Expand Down
Expand Up @@ -2633,7 +2633,7 @@ public void setGlobalTracingOverride(@NotNull Collection<TracingRootType> roots,
}

@Override
public void removeGlobalTracingOverride() {
public void unsetGlobalTracingOverride() {
globalTracingOverride = null;
}

Expand Down

0 comments on commit ed8e7b8

Please sign in to comment.