Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/integration' into integration
Browse files Browse the repository at this point in the history
  • Loading branch information
jwomeara committed May 22, 2024
2 parents 130cabf + 71207e6 commit 59be85b
Show file tree
Hide file tree
Showing 8 changed files with 50 additions and 31 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ private void writeRule(AgeOffRuleConfiguration ruleConfiguration) throws IOExcep
}

private void openConfigurationElement() throws IOException {
this.writer.write("<?xml version=\"1.0\"?>\n");
this.writer.write("<ageoffConfiguration>\n");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public AgeOffRuleFormatter(AgeOffRuleConfiguration configuration) {
}

/**
* Outputs the configured rule to the writer
* Outputs the configured rule to the writer. Will not close the writer.
*
* @param writer
* output writer
Expand All @@ -48,7 +48,6 @@ void format(Writer writer) throws IOException {
AgeOffRuleLoader.RuleConfig ruleConfig = createRuleConfig(this.configuration);

writer.write(transformToXmlString(ruleConfig));
writer.close();
}

private AgeOffRuleLoader.RuleConfig createRuleConfig(AgeOffRuleConfiguration configuration) throws IOException {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
public class RuleConfigDocument extends DocumentImpl {
private static final String FILTER_CLASS_ELEMENT_NAME = "filterClass";
private static final String MATCH_PATTERN_ELEMENT_NAME = "matchPattern";
private static final String IS_MERGE_ELEMENT_NAME = "ismerge";
private static final String TTL_ELEMENT_NAME = "ttl";
private static final String TTL_UNITS_ATTRIBUTE_NAME = "units";
private static final String RULE_ELEMENT_NAME = "rule";
Expand Down Expand Up @@ -53,7 +52,6 @@ private Element createRuleElement() {

private void appendElementsToRule() {
appendFilterClassElement();
appendMergeElement();
appendTtlElement();
appendMatchPatternElement();
appendCustomElements();
Expand Down Expand Up @@ -95,14 +93,6 @@ private void appendTtlElement() {
}
}

private void appendMergeElement() {
if (this.ruleConfig.isMerge) {
Element mergeElement = super.createElement(IS_MERGE_ELEMENT_NAME);
mergeElement.setTextContent(Boolean.TRUE.toString());
rule.appendChild(mergeElement);
}
}

private void enableCommentEscaping(Element rule) {
adjustEscaping(rule, StreamResult.PI_ENABLE_OUTPUT_ESCAPING);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,25 @@
import static org.junit.Assert.assertTrue;

import java.io.ByteArrayInputStream;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.io.StringWriter;
import java.io.Writer;
import java.lang.reflect.InvocationTargetException;
import java.net.URISyntaxException;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.util.List;
import java.util.stream.Collectors;

import org.apache.accumulo.core.data.Key;
import org.apache.accumulo.core.data.Value;
import org.apache.accumulo.core.iterators.IteratorEnvironment;
import org.apache.xerces.dom.DocumentImpl;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.TemporaryFolder;
import org.w3c.dom.Element;
import org.w3c.dom.Node;

Expand All @@ -33,12 +39,12 @@ public class AgeOffFileGeneratorTest {

// @formatter:off
private static final String EXPECTED_FILE_CONTENTS =
"<?xml version=\"1.0\"?>\n" +
"<ageoffConfiguration>\n" +
" <parent>" + PARENT_FILE_NAME + "</parent>\n" +
" <rules>\n" +
" <rule label=\"labeledPatternsFormat\" mode=\"merge\">\n" +
" <filterClass>datawave.iterators.filter.ColumnVisibilityLabeledFilter</filterClass>\n" +
" <ismerge>true</ismerge>\n" +
" <matchPattern>\n" +
" dryFood bakingPowder=365d\n" +
" dryFood driedBeans=548d\n" +
Expand Down Expand Up @@ -66,12 +72,12 @@ public class AgeOffFileGeneratorTest {
"</ageoffConfiguration>\n";

private static final String OTHER_EXPECTED_FILE_CONTENTS =
"<?xml version=\"1.0\"?>\n" +
"<ageoffConfiguration>\n" +
" <parent>test-root-field.xml</parent>\n" +
" <rules>\n" +
" <rule mode=\"merge\">\n" +
" <filterClass>datawave.iterators.filter.ageoff.DataTypeAgeOffFilter</filterClass>\n" +
" <ismerge>true</ismerge>\n" +
" <isindextable>true</isindextable>\n" +
" </rule>\n" +
" <rule>\n" +
Expand Down Expand Up @@ -196,8 +202,23 @@ public class AgeOffFileGeneratorTest {
"</ageoffConfiguration>\n";
// @formatter:on

@Rule
public TemporaryFolder temporaryFolder = new TemporaryFolder();

@Test
public void createFileWithMultipleRules() throws IOException {
public void generateFileContentsWithMultipleRules() throws IOException {
AgeOffFileConfiguration.Builder builder = createBuilderForMultipleRules();
assertEquals(EXPECTED_FILE_CONTENTS, generateFileContentsInMemory(builder));
}

@Test
public void writeMultipleRulesToLocalFile() throws IOException {
File temporaryFile = writeToFile(createBuilderForMultipleRules());
String actualResult = Files.readAllLines(temporaryFile.toPath()).stream().collect(Collectors.joining("\n")) + "\n";
assertEquals(EXPECTED_FILE_CONTENTS, actualResult);
}

private AgeOffFileConfiguration.Builder createBuilderForMultipleRules() {
AgeOffRuleConfiguration.Builder colVisFilterRule = defineColVisFilterRule();
AgeOffRuleConfiguration.Builder testFilterRule = defineTestFilterRule();
AgeOffRuleConfiguration.Builder dataTypeRule = defineDataTypeRule();
Expand All @@ -208,7 +229,7 @@ public void createFileWithMultipleRules() throws IOException {
builder.addNextRule(dataTypeRule);
builder.addNextRule(testFilterRule);
builder.withIndentation(" ");
assertEquals(EXPECTED_FILE_CONTENTS, generateFile(builder));
return builder;
}

@Test
Expand All @@ -222,7 +243,7 @@ public void createAnotherFileWithMultipleRules() throws IOException, URISyntaxEx
builder.addNextRule(fieldRule);
builder.addNextRule(defineColQualifierRule());
builder.withIndentation(" ");
assertEquals(OTHER_EXPECTED_FILE_CONTENTS, generateFile(builder));
assertEquals(OTHER_EXPECTED_FILE_CONTENTS, generateFileContentsInMemory(builder));
}

@Test
Expand Down Expand Up @@ -351,11 +372,20 @@ private AgeOffRuleConfiguration.Builder defineFieldAgeOffRule() {
return builder;
}

private String generateFile(AgeOffFileConfiguration.Builder builder) throws IOException {
StringWriter out = new StringWriter();
private String generateFileContentsInMemory(AgeOffFileConfiguration.Builder builder) throws IOException {
StringWriter writer = new StringWriter();
AgeOffFileGenerator generator = new AgeOffFileGenerator(builder.build());
generator.format(writer);
return writer.toString();
}

private File writeToFile(AgeOffFileConfiguration.Builder builder) throws IOException {
File temporaryFile = temporaryFolder.newFile();
Writer writer = Files.newBufferedWriter(temporaryFile.toPath());
AgeOffFileGenerator generator = new AgeOffFileGenerator(builder.build());
generator.format(out);
return out.toString();
generator.format(writer);
writer.close();
return temporaryFile;
}

private class TestProvider implements AgeOffRuleLoader.AgeOffFileLoaderDependencyProvider {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ public void createRuleFromCsv() throws IOException {
String expectedOutputText =
"<rule label=\"test\" mode=\"merge\">\n" +
" <filterClass>datawave.ingest.util.cache.watch.TestTrieFilter</filterClass>\n" +
" <ismerge>true</ismerge>\n" +
" <matchPattern>\n" +
" dryFood bakingPowder=365d\n" +
" dryFood driedBeans=548d\n" +
Expand Down Expand Up @@ -111,7 +110,6 @@ public void createRuleForDataTypeIndexTable() throws IOException {
String expectedOutputText =
"<rule mode=\"merge\">\n" +
" <filterClass>datawave.iterators.filter.ageoff.DataTypeAgeOffFilter</filterClass>\n" +
" <ismerge>true</ismerge>\n" +
" <isindextable>true</isindextable>\n" +
"</rule>\n";
// @formatter:on
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,6 @@ public void includesMerge() throws IOException {
// @formatter:off
String expected = "<rule mode=\"merge\">\n" +
" <filterClass>myclass</filterClass>\n" +
" <ismerge>true</ismerge>\n" +
"</rule>\n";
// @formatter:on
assertEquals(actual, expected, actual);
Expand Down Expand Up @@ -127,7 +126,6 @@ public void includesAll() throws IOException {
// @formatter:off
String expected = "<rule label=\"tag\" mode=\"merge\">\n" +
" <filterClass>myclass</filterClass>\n" +
" <ismerge>true</ismerge>\n" +
" <ttl units=\"h\">2468</ttl>\n" +
" <matchPattern>\n" +
"1234\n" +
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ wait_and_shutdown(){
TIMEOUT_MINUTES=75
fi

echo "Sending wait and shutdown command to the web service. Will wait up to $TIMEOUT_MINUTES for queries to complete."
echo "Sending wait and shutdown command to the web service. Will wait up to $TIMEOUT_MINUTES minutes for queries to complete."
curl --fail -s -o /tmp/curl_shutdown.log http://localhost:8080/DataWave/Common/Health/shutdown?timeoutMinutes=$TIMEOUT_MINUTES
CURL_STATUS=$?
if [ $CURL_STATUS -ne 0 ]; then
Expand All @@ -29,6 +29,12 @@ wait_and_shutdown(){
fi
}


echo "Capturing ENV Properties"
printenv > env.properties
echo "Setting Runtime Config"
$WILDFLY_HOME/bin/jboss-cli.sh --file=./runtime-config.cli --properties=env.properties

if [[ "$@" != *"bin/standalone.sh"* ]]; then
exec "$@"
else
Expand Down Expand Up @@ -63,9 +69,6 @@ else
trap 'kill -WINCH $CMD_PID' WINCH
trap 'kill -USR2 $CMD_PID' USR2

printenv > env.properties
$WILDFLY_HOME/bin/jboss-cli.sh --file=./runtime-config.cli --properties=env.properties

eval "$@" "&"
CMD_PID=${!}

Expand Down
4 changes: 2 additions & 2 deletions web-services/deploy/docs/docs/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,11 @@ <h1 align="center" style="color: white">Welcome to DataWave</h1>
</div>

<div class="grid-x" align="center" style="justify-content: center;">
<div class="cell small-4">
<!--<div class="cell small-4">
<a href="apidocs/index.html"><img src="images/api_icon_finished.png" width="50%"
style="alignment-adjust:central;padding: 20px"></a>
<div style="padding-bottom: 30%">API Documents</div></a>
</div>
</div>-->
<div class="cell small-4">
<a href="query_help.html"><img src="images/userGuide_icon.png" width="50%"
style="alignment-adjust:central;padding: 20px"></a>
Expand Down

0 comments on commit 59be85b

Please sign in to comment.