Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add dynamic extension schema generation
Plus some minor improvements in the system-level performance test. (cherry picked from commit d801958)
- Loading branch information
Showing
15 changed files
with
228 additions
and
15,945 deletions.
There are no files selected for viewing
52 changes: 0 additions & 52 deletions
52
...ory/src/test/java/com/evolveum/midpoint/testing/story/sysperf/ExtensionSchemaVariant.java
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
52 changes: 0 additions & 52 deletions
52
...ng/story/src/test/java/com/evolveum/midpoint/testing/story/sysperf/PopulationVariant.java
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
138 changes: 138 additions & 0 deletions
138
.../story/src/test/java/com/evolveum/midpoint/testing/story/sysperf/SchemaConfiguration.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.