You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@flink.apache.org by tillrohrmann <gi...@git.apache.org> on 2018/03/18 15:18:16 UTC
[GitHub] flink pull request #5416: [FLINK-8562] [Security] Fix YARNSessionFIFOSecured...
Github user tillrohrmann commented on a diff in the pull request:
https://github.com/apache/flink/pull/5416#discussion_r175292445
--- 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 --
can we construct `Arrays.asList(mustHave)` once and pass it to the `FilenameFilter`?
---