Skip to content

Commit

Permalink
Add dynamic extension schema generation
Browse files Browse the repository at this point in the history
Plus some minor improvements in the system-level performance test.

(cherry picked from commit d801958)
  • Loading branch information
mederly committed May 3, 2021
1 parent c5d13de commit cf7300a
Show file tree
Hide file tree
Showing 15 changed files with 228 additions and 15,945 deletions.

This file was deleted.

Expand Up @@ -20,7 +20,7 @@
import com.evolveum.midpoint.test.TestResource;
import com.evolveum.midpoint.xml.ns._public.common.common_3.TaskType;

class ImportsConfiguration {
class ImportConfiguration {

private static final String PROP = "import";
private static final String PROP_THREADS = PROP + ".threads";
Expand All @@ -33,7 +33,7 @@ class ImportsConfiguration {

private final List<TestResource<TaskType>> generatedTasks;

private ImportsConfiguration() {
private ImportConfiguration() {
threads = Integer.parseInt(System.getProperty(PROP_THREADS, "0"));
noOpRuns = Integer.parseInt(System.getProperty(PROP_NO_OP_RUNS, "1"));

Expand All @@ -60,8 +60,8 @@ public String toString() {
'}';
}

public static ImportsConfiguration setup() {
ImportsConfiguration configuration = new ImportsConfiguration();
public static ImportConfiguration setup() {
ImportConfiguration configuration = new ImportConfiguration();
System.out.println("Import: " + configuration);
return configuration;
}
Expand Down

This file was deleted.

Expand Up @@ -20,13 +20,13 @@ class ProgressOutputFile {
writer.println("test;time;progress");
}

void recordProgress(String testName, Task task) {
void recordProgress(String label, Task task) {
long start = task.getLastRunStartTimestamp();
Long lastFinish = task.getLastRunFinishTimestamp();
long thisFinish = lastFinish != null && lastFinish > start ? lastFinish : System.currentTimeMillis();
long running = thisFinish - start;
long progress = task.getProgress();
writer.println(testName + ";" + running + ";" + progress);
writer.println(label + task.getName() + ";" + running + ";" + progress);
writer.flush();
}
}
Expand Up @@ -18,10 +18,10 @@

class RecomputationConfiguration {

private static final String PROP = "recompute";
private static final String PROP = "recomputation";
private static final String PROP_THREADS = PROP + ".threads";

private static final File TASK_TEMPLATE_FILE = new File(TEST_DIR, "task-recompute.vm.xml");
private static final File TASK_TEMPLATE_FILE = new File(TEST_DIR, "task-recomputation.vm.xml");

private static final String RECOMPUTE_TASK_OID = "f5920848-6c8f-4eda-ae26-2b961d6dae1b";

Expand All @@ -44,7 +44,7 @@ TestResource<TaskType> getGeneratedTask() {

@Override
public String toString() {
return "RecomputeConfiguration{" +
return "RecomputationConfiguration{" +
"threads=" + threads +
'}';
}
Expand Down
Expand Up @@ -20,7 +20,7 @@
import static com.evolveum.midpoint.testing.story.sysperf.TestSystemPerformance.TEST_DIR;
import static com.evolveum.midpoint.testing.story.sysperf.Util.mapOf;

class ReconciliationsConfiguration {
class ReconciliationConfiguration {

private static final String PROP = "reconciliation";
private static final String PROP_THREADS = PROP + ".threads";
Expand All @@ -33,7 +33,7 @@ class ReconciliationsConfiguration {

private final List<TestResource<TaskType>> generatedTasks;

private ReconciliationsConfiguration() {
private ReconciliationConfiguration() {
threads = Integer.parseInt(System.getProperty(PROP_THREADS, "0"));
runs = Integer.parseInt(System.getProperty(PROP_RUNS, "1"));

Expand All @@ -54,14 +54,14 @@ List<TestResource<TaskType>> getGeneratedTasks() {

@Override
public String toString() {
return "ReconciliationsConfiguration{" +
return "ReconciliationConfiguration{" +
"threads=" + threads +
", runs=" + runs +
'}';
}

public static ReconciliationsConfiguration setup() {
ReconciliationsConfiguration configuration = new ReconciliationsConfiguration();
public static ReconciliationConfiguration setup() {
ReconciliationConfiguration configuration = new ReconciliationConfiguration();
System.out.println("Import: " + configuration);
return configuration;
}
Expand Down
@@ -0,0 +1,138 @@
/*
* Copyright (C) 2010-2021 Evolveum and contributors
*
* This work is dual-licensed under the Apache License 2.0
* and European Union Public License. See LICENSE file for details.
*/

package com.evolveum.midpoint.testing.story.sysperf;

import java.io.File;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;

import static com.evolveum.midpoint.test.util.MidPointTestConstants.TARGET_DIR_PATH;
import static com.evolveum.midpoint.testing.story.sysperf.TestSystemPerformance.TEST_DIR;

class SchemaConfiguration {

private static final String PROP = "schema";
private static final String PROP_SINGLE_VALUED_PROPERTIES = PROP + ".single-valued-properties";
private static final String PROP_MULTI_VALUED_PROPERTIES = PROP + ".multi-valued-properties";
private static final String PROP_INDEXED_PERCENTAGE = PROP + ".indexed-percentage";

private static final File SCHEMA_TEMPLATE_FILE = new File(TEST_DIR, "schema.vm.xsd");

private static final String GENERATED_SCHEMA_DIR_PATH = TARGET_DIR_PATH + "/schema";
private static final File GENERATED_SCHEMA_DIR = new File(GENERATED_SCHEMA_DIR_PATH);
private static final File GENERATED_SCHEMA_FILE = new File(GENERATED_SCHEMA_DIR, "schema.xsd");

private static final String P_SINGLE_PATTERN = "p-single-%04d";
private static final String P_MULTI_PATTERN = "p-multi-%04d";

private final int singleValuedProperties;
private final int multiValuedProperties;
private final int indexedPercentage;

private SchemaConfiguration() {
this.singleValuedProperties = Integer.parseInt(System.getProperty(PROP_SINGLE_VALUED_PROPERTIES, "100"));
this.multiValuedProperties = Integer.parseInt(System.getProperty(PROP_MULTI_VALUED_PROPERTIES, "10"));
this.indexedPercentage = Integer.parseInt(System.getProperty(PROP_INDEXED_PERCENTAGE, "0"));

generateSchemaFile();
}

int getSingleValuedProperties() {
return singleValuedProperties;
}

int getMultiValuedProperties() {
return multiValuedProperties;
}

int getIndexedPercentage() {
return indexedPercentage;
}

@Override
public String toString() {
return "SchemaConfiguration{" +
"singleValuedProperties=" + singleValuedProperties +
", multiValuedProperties=" + multiValuedProperties +
", indexedPercentage=" + indexedPercentage +
'}';
}

public static SchemaConfiguration setup() {
System.setProperty("midpoint.global.extensionDir", GENERATED_SCHEMA_DIR_PATH);

SchemaConfiguration configuration = new SchemaConfiguration();
System.out.println("Schema: " + configuration);
return configuration;
}

private void generateSchemaFile() {

List<ItemDef> itemDefList = new ArrayList<>();
IndexedSelector indexedSelector = new IndexedSelector();
for (int i = 0; i < singleValuedProperties; i++) {
String name = String.format(P_SINGLE_PATTERN, i);
boolean indexed = indexedSelector.getNext();
itemDefList.add(new ItemDef(name, "1", indexed));
}
indexedSelector.reset();
for (int i = 0; i < multiValuedProperties; i++) {
String name = String.format(P_MULTI_PATTERN, i);
boolean indexed = indexedSelector.getNext();
itemDefList.add(new ItemDef(name, "unbounded", indexed));
}

//noinspection ResultOfMethodCallIgnored
GENERATED_SCHEMA_DIR.mkdirs();

VelocityGenerator.generate(SCHEMA_TEMPLATE_FILE, GENERATED_SCHEMA_FILE,
Map.of("itemList", itemDefList));
}

public static class ItemDef {
private final String name;
private final String maxOccurs;
private final boolean indexed;

private ItemDef(String name, String maxOccurs, boolean indexed) {
this.name = name;
this.maxOccurs = maxOccurs;
this.indexed = indexed;
}

public String getName() {
return name;
}

public String getMaxOccurs() {
return maxOccurs;
}

public boolean isIndexed() {
return indexed;
}
}

private class IndexedSelector {
private int counter;
private boolean getNext() {
counter += indexedPercentage;
if (counter >= 100) {
counter -= 100;
return true;
} else {
return false;
}
}

public void reset() {
counter = 0;
}
}
}
Expand Up @@ -19,12 +19,12 @@ class SummaryOutputFile {

void logStart() {
writer.println("Started: " + new Date(START) + " (" + START + ")");
writer.printf("Extension schema variant: %s\n", EXTENSION_SCHEMA_VARIANT);
writer.printf("Schema: %s\n", SCHEMA_CONFIGURATION);
writer.printf("Sources: %s\n", SOURCES_CONFIGURATION);
writer.printf("Targets: %s\n", TARGETS_CONFIGURATION);
writer.printf("Roles: %s\n", ROLES_CONFIGURATION);
writer.printf("Imports: %s\n", IMPORTS_CONFIGURATION);
writer.printf("Reconciliations: %s\n", RECONCILIATIONS_CONFIGURATION);
writer.printf("Import: %s\n", IMPORTS_CONFIGURATION);
writer.printf("Reconciliation: %s\n", RECONCILIATIONS_CONFIGURATION);
writer.printf("Recomputation: %s\n", RECOMPUTATION_CONFIGURATION);
writer.printf("Progress file: %s\n\n", ProgressOutputFile.FILE);
writer.flush();
Expand Down

0 comments on commit cf7300a

Please sign in to comment.