/** * Print a debug message with the JSON representation of the SourceRecord. * * @param record the source record; may not be null */ public static void debug(SourceRecord record) { Testing.debug(SchemaUtil.asDetailedString(record)); }
protected void printEvent(Event event) { Testing.print(event); }
message.set("key", keyJson); message.set("value", valueJson); Testing.print("Message on topic '" + record.topic() + "':"); Testing.print(prettyJson(message)); Testing.printError(t); Testing.print("Problem with message on topic '" + record.topic() + "':"); if (keyJson != null) { Testing.print("valid key = " + prettyJson(keyJson)); Testing.print("invalid key"); Testing.print("valid value = " + prettyJson(valueJson)); Testing.print("invalid value");
Testing.debug("Consumed record " + recordsConsumed + " / " + numberOfRecords + " (" + (numberOfRecords - recordsConsumed) + " more)"); debug(record); } else if (Testing.Print.isEnabled()) { Testing.print("Consumed record " + recordsConsumed + " / " + numberOfRecords + " (" + (numberOfRecords - recordsConsumed) + " more)"); print(record);
public static void printError(String message, Throwable throwable) { printError(message); printError(throwable); }
GtidSet replicaGtidSet = null; while (true) { Testing.debug("Checking replica's GTIDs and comparing to master's..."); replicaGtidSet = readAvailableGtidSet(replica); Testing.debug("Replica's GTIDs are caught up to the master's."); sw.stop(); return; Testing.debug("Waiting for replica's GTIDs to catch up to master's..."); Thread.sleep(100); Testing.print("Waited a total of " + sw.durations().statistics().getTotalAsString() + " for the replica to catch up to the master."); } catch (InterruptedException e) { Thread.interrupted();
protected static String prettyJson(JsonNode json) { try { return new ObjectMapper().writerWithDefaultPrettyPrinter().writeValueAsString(json); } catch (Throwable t) { Testing.printError(t); fail(t.getMessage()); assert false : "Will not get here"; return null; } }
protected void logIgnoredEvent(Event event) { Testing.print("Ignored event: " + event); }
protected void storeDocuments(String dbName, String collectionName, String pathOnClasspath) { primary().execute("storing documents", mongo -> { Testing.debug("Storing in '" + dbName + "." + collectionName + "' documents loaded from from '" + pathOnClasspath + "'"); MongoDatabase db1 = mongo.getDatabase(dbName); MongoCollection<Document> coll = db1.getCollection(collectionName); coll.drop(); storeDocuments(coll, pathOnClasspath); }); }
.build()); Testing.print("Configuration: " + config); Testing.debug("Getting or creating 'movies' collections"); Testing.debug("Completed getting 'movies' collections"); }); Testing.debug("Adding document to 'movies' collections"); Testing.debug("Completed adding documents to 'movies' collections"); }); long maxSeconds = 5; primary.execute("read oplog from beginning", mongo -> { Testing.debug("Getting local.oplog.rs"); Testing.debug("Reading local.oplog.rs"); try (MongoCursor<Document> cursor = results.iterator();) { Document event = null; Testing.debug("Completed local.oplog.rs"); }); Testing.print("Found: " + event); BsonTimestamp position = event.get("ts", BsonTimestamp.class); assert position != null;
Testing.print("Problem with message on topic '" + record.topic() + "':"); Testing.printError(t); Testing.print("error " + msg); Testing.print(" key: " + SchemaUtil.asString(record.key())); Testing.print(" key deserialized from JSON: " + prettyJson(keyJson)); if (keyWithSchema != null) { Testing.print(" key to/from JSON: " + SchemaUtil.asString(keyWithSchema.value())); Testing.print(" key to/from Avro: " + SchemaUtil.asString(avroKeyWithSchema.value())); Testing.print(" value: " + SchemaUtil.asString(record.value())); Testing.print(" value deserialized from JSON: " + prettyJson(valueJson)); if (valueWithSchema != null) { Testing.print(" value to/from JSON: " + SchemaUtil.asString(valueWithSchema.value())); Testing.print(" value to/from Avro: " + SchemaUtil.asString(avroValueWithSchema.value()));
/** * A method that will delete a file or folder only if it is within the 'target' directory (for safety). * Folders are removed recursively. * * @param path the path to the file or folder in the target directory */ public static void delete(Path path) { if (path != null) { path = path.toAbsolutePath(); if (inTestDataDir(path)) { try { IoUtil.delete(path); } catch (IOException e) { printError("Unable to remove '" + path.toAbsolutePath() + "'", e); } } else { printError("Will not remove directory that is outside test data area: " + path); } } }
protected void printStatements(String dbName, String ddlStatements) { Testing.print("Running DDL for '" + dbName + "': " + ddlStatements); }
private void applyCommand(Document record, ConsumerCompletion result) { if (isCommand(record)) { Testing.debug("applying command: " + SchemaUtil.asString(record)); String command = record.getString(CONTROL_KEY); if (CONTROL_RESTART.equalsIgnoreCase(command)) { // We're supposed to restart the connector, so stop it ... result.restartRequested(); String msg = "Stopping connector after record as requested"; Testing.debug(msg); throw new StopConnectorException(msg); } else if (CONTROL_STOP.equalsIgnoreCase(command)) { // We're supposed to restart the connector, so stop it ... result.stop(); String msg = "Stopping connector after record as requested"; Testing.debug(msg); throw new StopConnectorException(msg); } } }
PreviousContext prev = LoggingContext.forConnector(getClass().getSimpleName(), "runner", spec.name()); try { Testing.debug("actual record: " + SchemaUtil.asString(actualRecord)); timeSinceLastRecord.reset(); } catch (IOException e) { String msg = "Error converting JSON to SourceRecord"; Testing.debug(msg); throw new ConnectException(msg, e); Testing.debug(msg); throw new MismatchRecordException(msg, actualRecordHistory, expectedRecordHistory); result.error(); String msg = "Source record was found but not expected: " + SchemaUtil.asString(actualRecord); Testing.debug(msg); throw new MismatchRecordException(msg, actualRecordHistory, expectedRecordHistory); } else if (isCommand(expected)) { Testing.debug("applying command: " + SchemaUtil.asString(expected)); applyCommand(expected, result); } else { Testing.debug("expected record: " + SchemaUtil.asString(expectedRecord)); String msg = "Source record with key " + SchemaUtil.asString(actualRecord.key()) + " did not match expected record: " + e.getMessage(); Testing.debug(msg); throw new MismatchRecordException(e, msg, actualRecordHistory, expectedRecordHistory);
protected void logConsumedEvent(Event event) { Testing.print("Consumed event: " + event); }
protected void appendCommand(Path results, Document command) throws IOException { assertThat(command).isNotNull(); assertThat(Files.exists(results)).isTrue(); Array arrayOfDocuments = readResults(results.toFile()); arrayOfDocuments.add(command); try (OutputStream stream = new FileOutputStream(results.toFile())) { ArrayWriter.prettyWriter().write(arrayOfDocuments, stream); } if (Testing.Debug.isEnabled()) { String content = IoUtil.read(results.toFile()); Testing.debug("expected results file '" + results + "' after appending command:"); Testing.debug(content); } }
/** * Print a message with the JSON representation of the SourceRecord. * * @param record the source record; may not be null */ public static void print(SourceRecord record) { Testing.print(SchemaUtil.asString(record)); }
@Test public void otherTypes() throws Exception { Testing.debug("Inserted"); final SourceRecords records = consumeRecordsByTopic(EXPECTED_RECORD_COUNT); List<SourceRecord> testTableRecords = records.recordsForTopic("server1.dbo.type_xml"); assertThat(testTableRecords).hasSize(1); // insert VerifyRecord.isValidRead(testTableRecords.get(0)); Struct after = (Struct) ((Struct)testTableRecords.get(0).value()).get("after"); assertRecord(after, EXPECTED_XML); }