Github user suez1224 commented on a diff in the pull request: https://github.com/apache/flink/pull/5416#discussion_r175342198 --- Diff: flink-yarn-tests/src/test/java/org/apache/flink/yarn/YarnTestBase.java --- @@ -379,6 +382,50 @@ public boolean accept(File dir, String name) { } } + public static void ensureStringInNamedLogFiles(final String[] mustHave, final String fileName) { + File cwd = new File("target/" + YARN_CONFIGURATION.get(TEST_CLUSTER_NAME_KEY)); + Assert.assertTrue("Expecting directory " + cwd.getAbsolutePath() + " to exist", cwd.exists()); + Assert.assertTrue( + "Expecting directory " + cwd.getAbsolutePath() + " to be a directory", cwd.isDirectory()); + + File foundFile = findFile(cwd.getAbsolutePath(), new FilenameFilter() { + @Override + public boolean accept(File dir, String name) { + if (fileName != null && !name.equals(fileName)) { + return false; + } + File f = new File(dir.getAbsolutePath() + "/" + name); + LOG.info("Searching in {}", f.getAbsolutePath()); + try { + Set<String> foundSet = new HashSet<String>(mustHave.length); + Scanner scanner = new Scanner(f); + while (scanner.hasNextLine()) { + final String lineFromFile = scanner.nextLine(); + for (String str : mustHave) { + if (lineFromFile.contains(str)) { + foundSet.add(str); + } + } + if (foundSet.containsAll(Arrays.asList(mustHave))) { --- End diff -- done
---