Skip to content

Commit 5c4fdc0

Browse files
author
Charles Greer
authored
Merge pull request #1356 from marklogic/bugfix/DHFPROD-653
Bugfix/dhfprod 653
2 parents e3a869a + 3e0e232 commit 5c4fdc0

File tree

6 files changed

+39
-53
lines changed

6 files changed

+39
-53
lines changed

marklogic-data-hub/src/main/resources/ml-modules/root/data-hub/4/impl/debug-lib.xqy

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ declare function debug:enable($enabled as xs:boolean)
4848
declare function debug:on() as xs:boolean
4949
{
5050
let $key := "debugging-enabled"
51-
let $flag := hul:from-field-cache-or-empty($key, ())
51+
let $flag := hul:from-field-cache-or-empty($key, $hul:EXPIRATION)
5252
return
5353
if (exists($flag)) then
5454
$flag
@@ -65,7 +65,7 @@ declare function debug:on() as xs:boolean
6565
)
6666
)
6767
',(), map:new(map:entry("database", xdmp:modules-database()))),
68-
()
68+
$hul:EXPIRATION
6969
)
7070
};
7171

marklogic-data-hub/src/main/resources/ml-modules/root/data-hub/4/impl/hub-utils-lib.xqy

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@ declare namespace hub = "http://marklogic.com/data-hub";
2929

3030
declare option xdmp:mapping "false";
3131

32+
declare variable $hul:EXPIRATION as xs:dayTimeDuration := xs:dayTimeDuration("PT0.3S");
33+
3234
declare variable $_cache := map:map();
3335
(:~
3436
: determine if a module exists or not

marklogic-data-hub/src/main/resources/ml-modules/root/data-hub/4/impl/trace-lib.xqy

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ declare function trace:enable-tracing($enabled as xs:boolean)
7171
declare function trace:enabled() as xs:boolean
7272
{
7373
let $key := "tracing-enabled"
74-
let $flag := hul:from-field-cache-or-empty($key, ())
74+
let $flag := hul:from-field-cache-or-empty($key, $hul:EXPIRATION)
7575
return
7676
if (exists($flag)) then
7777
$flag
@@ -88,7 +88,7 @@ declare function trace:enabled() as xs:boolean
8888
)
8989
)
9090
',(), map:new(map:entry("database", xdmp:modules-database()))),
91-
xs:dayTimeDuration("PT1M")
91+
$hul:EXPIRATION
9292
)
9393
};
9494

marklogic-data-hub/src/test/java/com/marklogic/hub/HubTestBase.java

Lines changed: 3 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -337,39 +337,11 @@ protected void disableDebugging() {
337337
}
338338

339339
protected void enableTracing() {
340-
ManageClient manageClient = ((HubConfigImpl)getHubFlowRunnerConfig()).getManageClient();
341-
String resp = manageClient.getJson("/manage/v2/hosts?format=json");
342-
JsonNode actualObj = null;
343-
try {
344-
actualObj = new ObjectMapper().readTree(resp);
345-
} catch (IOException e1) {
346-
// TODO Auto-generated catch block
347-
e1.printStackTrace();
348-
}
349-
JsonNode nameNode = actualObj.path("host-default-list").path("list-items");
350-
List<String> hosts = nameNode.findValuesAsText("nameref");
351-
hosts.forEach(serverHost ->
352-
{
353-
try {
354-
DatabaseClient client = getClient(serverHost, stagingPort, HubConfig.DEFAULT_STAGING_NAME, flowRunnerUser, flowRunnerPassword, stagingAuthMethod);
355-
Tracing.create(client).enable();
356-
clients.add(client);
357-
} catch (Exception e) {
358-
// TODO Auto-generated catch block
359-
e.printStackTrace();
360-
}
361-
});
340+
Tracing.create(stagingClient).enable();
362341
}
363342

364343
protected void disableTracing() {
365-
clients.forEach(client ->
366-
{
367-
Tracing.create(client).disable();
368-
client.newServerEval().xquery("xquery version \"1.0-ml\";\n" +
369-
"import module namespace hul = \"http://marklogic.com/data-hub/hub-utils-lib\" at \"/data-hub/4/impl/hub-utils-lib.xqy\";\n" +
370-
"hul:invalidate-field-cache(\"tracing-enabled\")").eval();
371-
372-
});
344+
Tracing.create(stagingClient).disable();
373345
}
374346

375347
//getHubAdminConfig is used for installation, scaffolding
@@ -1083,7 +1055,7 @@ private void installCARootCertIntoStore(File caRootCert) {
10831055
}
10841056
}
10851057

1086-
protected void debugOutput(Document xmldoc) throws TransformerException {
1058+
protected void debugOutput(Document xmldoc) {
10871059
debugOutput(xmldoc, System.out);
10881060
}
10891061

marklogic-data-hub/src/test/java/com/marklogic/hub/job/TracingTest.java

Lines changed: 20 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -15,32 +15,33 @@
1515
*/
1616
package com.marklogic.hub.job;
1717

18-
import static org.custommonkey.xmlunit.XMLAssert.assertXMLEqual;
19-
import static org.junit.Assert.assertEquals;
20-
import static org.junit.Assert.assertFalse;
21-
import static org.junit.Assert.assertTrue;
22-
23-
import java.io.IOException;
24-
import java.net.URISyntaxException;
25-
import java.net.URL;
26-
import java.nio.file.Paths;
27-
28-
import com.marklogic.hub.FlowManager;
29-
import com.marklogic.hub.HubConfig;
30-
import com.marklogic.hub.HubTestBase;
31-
import com.marklogic.hub.Tracing;
32-
import org.junit.*;
33-
import org.w3c.dom.Document;
34-
3518
import com.fasterxml.jackson.databind.JsonNode;
3619
import com.marklogic.client.document.DocumentRecord;
3720
import com.marklogic.client.io.DOMHandle;
3821
import com.marklogic.client.io.JacksonHandle;
3922
import com.marklogic.client.io.StringHandle;
4023
import com.marklogic.client.query.RawStructuredQueryDefinition;
4124
import com.marklogic.client.query.StructuredQueryBuilder;
25+
import com.marklogic.hub.FlowManager;
26+
import com.marklogic.hub.HubConfig;
27+
import com.marklogic.hub.HubTestBase;
28+
import com.marklogic.hub.Tracing;
4229
import com.marklogic.hub.flow.Flow;
4330
import com.marklogic.hub.flow.FlowRunner;
31+
import org.custommonkey.xmlunit.XMLUnit;
32+
import org.junit.After;
33+
import org.junit.Assert;
34+
import org.junit.Before;
35+
import org.junit.Test;
36+
import org.w3c.dom.Document;
37+
38+
import java.io.IOException;
39+
import java.net.URISyntaxException;
40+
import java.net.URL;
41+
import java.nio.file.Paths;
42+
43+
import static org.custommonkey.xmlunit.XMLAssert.assertXMLEqual;
44+
import static org.junit.Assert.*;
4445

4546

4647
public class TracingTest extends HubTestBase {
@@ -51,6 +52,7 @@ public class TracingTest extends HubTestBase {
5152

5253
@Before
5354
public void setup() throws IOException, URISyntaxException {
55+
XMLUnit.setIgnoreWhitespace(true);
5456
enableDebugging();
5557
clearDatabases(HubConfig.DEFAULT_STAGING_NAME, HubConfig.DEFAULT_JOB_NAME, HubConfig.DEFAULT_FINAL_NAME);
5658

@@ -304,6 +306,7 @@ public void runSjsXmlFlowWithBinaryContent() {
304306

305307
DocumentRecord doc = finalDocMgr.read("1").next();
306308
Document finalDoc = doc.getContent(new DOMHandle()).get();
309+
//debugOutput(finalDoc);
307310
assertXMLEqual(getXmlFromResource("tracing-test/traces/finalSjsXmlDoc.xml"), finalDoc);
308311

309312
Document node = traceDocMgr.search(allButCollectors(), 1).next().getContent(new DOMHandle()).get();

marklogic-data-hub/src/test/java/com/marklogic/hub/util/Installer.java

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,20 @@
11
package com.marklogic.hub.util;
22

33

4+
import com.marklogic.appdeployer.AppConfig;
5+
import com.marklogic.appdeployer.command.Command;
6+
import com.marklogic.appdeployer.command.CommandContext;
7+
import com.marklogic.hub.HubConfig;
48
import com.marklogic.hub.HubTestBase;
9+
import com.marklogic.hub.deploy.commands.LoadHubModulesCommand;
10+
import com.marklogic.hub.deploy.commands.LoadUserStagingModulesCommand;
511
import org.junit.jupiter.api.Test;
612
import org.slf4j.Logger;
713
import org.slf4j.LoggerFactory;
814

15+
import java.util.ArrayList;
16+
import java.util.List;
17+
918
public class Installer {
1019

1120
HubTestBase htb;
@@ -45,7 +54,7 @@ public void uninstallHub() {
4554
htb.deleteProjectDir();
4655
}
4756
catch(Exception e) {
48-
logger.warn("Unable to delete the project directory", e);
57+
logger.warn("Unable to delete the project directory", e);
4958
}
5059
}
5160
}

0 commit comments

Comments
 (0)