Skip to content
Permalink
Browse files
file: Add some extra logs to attempt catching info about flakiness #3584
  • Loading branch information
aldettinger committed May 13, 2022
1 parent 0c28fd3 commit 2200e7de3bbc2e603ceb54f5c52cee8a221abbd7
Showing 3 changed files with 15 additions and 0 deletions.
@@ -99,18 +99,27 @@ public void startRoute(String routeId) throws Exception {
@Path("/getFromMock/{mockId}")
@GET
public String getFromMock(@PathParam("mockId") String mockId) {
System.out.println("CAMEL-QUARKUS-3584 => FileResource.getFromMock(" + mockId + ").thread.id => "
+ Thread.currentThread().getId());
MockEndpoint mockEndpoint = context.getEndpoint("mock:" + mockId, MockEndpoint.class);
System.out.println("CAMEL-QUARKUS-3584 => FileResource.getFromMock(" + mockId + ").mockEndpoint => 0x"
+ System.identityHashCode(mockEndpoint));

String result = mockEndpoint.getExchanges().stream().map(e -> e.getIn().getBody(String.class))
.collect(Collectors.joining(SEPARATOR));

System.out.println("CAMEL-QUARKUS-3584 => FileResource.getFromMock(" + mockId + ") returns => " + result);

return result;
}

@Path("/resetMock/{mockId}")
@GET
public void resetMock(@PathParam("mockId") String mockId) {
System.out.println("CAMEL-QUARKUS-3584 => FileResource.resetMock().thread.id => " + Thread.currentThread().getId());
MockEndpoint mockEndpoint = context.getEndpoint("mock:" + mockId, MockEndpoint.class);
System.out.println(
"CAMEL-QUARKUS-3584 => FileResource.resetMock.mockEndpoint => 0x" + System.identityHashCode(mockEndpoint));
mockEndpoint.reset();
}

@@ -121,6 +130,7 @@ public void resetMock(@PathParam("mockId") String mockId) {
public Response createFile(@PathParam("folder") String folder, byte[] content, @QueryParam("charset") String charset,
@QueryParam("fileName") String fileName)
throws Exception {
System.out.println("CAMEL-QUARKUS-3584 => FileResource.createFile().thread.id => " + Thread.currentThread().getId());
StringBuilder url = new StringBuilder("file:target/" + folder + "?initialDelay=10");
if (charset != null && !charset.equals("")) {
url.append("&charset=").append(charset);
@@ -62,10 +62,12 @@ public void configure() {
.to("mock:charsetIsoRead");

from("file://target/idempotent?idempotent=true&move=done/${file:name}&initialDelay=0&delay=10")
.log("CAMEL-QUARKUS-3584 => from(\"file://target/idempotent?idempotent=true&move=done/${file:name}&initialDelay=0&delay=10\")... consumed message ${body}")
.convertBodyTo(String.class).to("mock:idempotent");

bindToRegistry("myFilter", new MyFileFilter<>());
from(("file://target/filter?initialDelay=0&delay=10&filter=#myFilter"))
.log("CAMEL-QUARKUS-3584 => from(\"file://target/filter?initialDelay=0&delay=10&filter=#myFilter\")... consumed message ${body}")
.convertBodyTo(String.class).to("mock:filter");

from(("file://target/sortBy?initialDelay=0&delay=10&sortBy=reverse:file:name"))
@@ -112,6 +112,7 @@ public void batch() throws InterruptedException, UnsupportedEncodingException {

@Test
public void idempotent() throws IOException {
System.out.println("CAMEL-QUARKUS-3584 => FileTest.idempotent().thread.id => " + Thread.currentThread().getId());
// Create a new file
String fileName01 = createFile(FILE_CONTENT_01, "/file/create/idempotent");

@@ -149,6 +150,7 @@ public void idempotent() throws IOException {

@Test
public void filter() throws IOException {
System.out.println("CAMEL-QUARKUS-3584 => FileTest.filter().thread.id => " + Thread.currentThread().getId());
String fileName = createFile(FILE_CONTENT_01, "/file/create/filter", null, "skip_" + UUID.randomUUID().toString());
createFile(FILE_CONTENT_02, "/file/create/filter");

@@ -164,6 +166,7 @@ public void filter() throws IOException {

@Test
public void sortBy() throws IOException, InterruptedException {
System.out.println("CAMEL-QUARKUS-3584 => FileTest.sortBy().thread.id => " + Thread.currentThread().getId());
createFile(FILE_CONTENT_03, "/file/create/" + SORT_BY, null, "c_" + UUID.randomUUID().toString());
createFile(FILE_CONTENT_01, "/file/create/" + SORT_BY, null, "a_" + UUID.randomUUID().toString());
createFile(FILE_CONTENT_02, "/file/create/" + SORT_BY, null, "b_" + UUID.randomUUID().toString());

0 comments on commit 2200e7d

Please sign in to comment.