Java Code Examples for org.apache.flink.test.util.TestBaseUtils#getFromHTTP()

The following examples show how to use org.apache.flink.test.util.TestBaseUtils#getFromHTTP() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: WebFrontendITCase.java    From Flink-CEPplus with Apache License 2.0 6 votes vote down vote up
@Test
public void getNumberOfTaskManagers() {
	try {
		String json = TestBaseUtils.getFromHTTP("http://localhost:" + getRestPort() + "/taskmanagers/");

		ObjectMapper mapper = new ObjectMapper();
		JsonNode response = mapper.readTree(json);
		ArrayNode taskManagers = (ArrayNode) response.get("taskmanagers");

		assertNotNull(taskManagers);
		assertEquals(NUM_TASK_MANAGERS, taskManagers.size());
	} catch (Exception e) {
		e.printStackTrace();
		fail(e.getMessage());
	}
}
 
Example 2
Source File: WebFrontendITCase.java    From Flink-CEPplus with Apache License 2.0 6 votes vote down vote up
@Test
public void getTaskmanagers() throws Exception {
	String json = TestBaseUtils.getFromHTTP("http://localhost:" + getRestPort() + "/taskmanagers/");

	ObjectMapper mapper = new ObjectMapper();
	JsonNode parsed = mapper.readTree(json);
	ArrayNode taskManagers = (ArrayNode) parsed.get("taskmanagers");

	assertNotNull(taskManagers);
	assertEquals(NUM_TASK_MANAGERS, taskManagers.size());

	JsonNode taskManager = taskManagers.get(0);
	assertNotNull(taskManager);
	assertEquals(NUM_SLOTS, taskManager.get("slotsNumber").asInt());
	assertTrue(taskManager.get("freeSlots").asInt() <= NUM_SLOTS);
}
 
Example 3
Source File: WebFrontendITCase.java    From Flink-CEPplus with Apache License 2.0 6 votes vote down vote up
@Test
public void getTaskManagerLogAndStdoutFiles() {
	try {
		String json = TestBaseUtils.getFromHTTP("http://localhost:" + getRestPort() + "/taskmanagers/");

		ObjectMapper mapper = new ObjectMapper();
		JsonNode parsed = mapper.readTree(json);
		ArrayNode taskManagers = (ArrayNode) parsed.get("taskmanagers");
		JsonNode taskManager = taskManagers.get(0);
		String id = taskManager.get("id").asText();

		WebMonitorUtils.LogFileLocation logFiles = WebMonitorUtils.LogFileLocation.find(CLUSTER_CONFIGURATION);

		//we check for job manager log files, since no separate taskmanager logs exist
		FileUtils.writeStringToFile(logFiles.logFile, "job manager log");
		String logs = TestBaseUtils.getFromHTTP("http://localhost:" + getRestPort() + "/taskmanagers/" + id + "/log");
		assertTrue(logs.contains("job manager log"));

		FileUtils.writeStringToFile(logFiles.stdOutFile, "job manager out");
		logs = TestBaseUtils.getFromHTTP("http://localhost:" + getRestPort() + "/taskmanagers/" + id + "/stdout");
		assertTrue(logs.contains("job manager out"));
	} catch (Exception e) {
		e.printStackTrace();
		fail(e.getMessage());
	}
}
 
Example 4
Source File: WebFrontendITCase.java    From flink with Apache License 2.0 6 votes vote down vote up
@Test
public void getTaskManagerLogAndStdoutFiles() throws Exception {
	String json = TestBaseUtils.getFromHTTP("http://localhost:" + getRestPort() + "/taskmanagers/");

	ObjectMapper mapper = new ObjectMapper();
	JsonNode parsed = mapper.readTree(json);
	ArrayNode taskManagers = (ArrayNode) parsed.get("taskmanagers");
	JsonNode taskManager = taskManagers.get(0);
	String id = taskManager.get("id").asText();

	WebMonitorUtils.LogFileLocation logFiles = WebMonitorUtils.LogFileLocation.find(CLUSTER_CONFIGURATION);

	//we check for job manager log files, since no separate taskmanager logs exist
	FileUtils.writeStringToFile(logFiles.logFile, "job manager log");
	String logs = TestBaseUtils.getFromHTTP("http://localhost:" + getRestPort() + "/taskmanagers/" + id + "/log");
	assertThat(logs, containsString("job manager log"));

	FileUtils.writeStringToFile(logFiles.stdOutFile, "job manager out");
	logs = TestBaseUtils.getFromHTTP("http://localhost:" + getRestPort() + "/taskmanagers/" + id + "/stdout");
	assertThat(logs, containsString("job manager out"));
}
 
Example 5
Source File: WebFrontendITCase.java    From flink with Apache License 2.0 6 votes vote down vote up
@Test
public void getNumberOfTaskManagers() {
	try {
		String json = TestBaseUtils.getFromHTTP("http://localhost:" + getRestPort() + "/taskmanagers/");

		ObjectMapper mapper = new ObjectMapper();
		JsonNode response = mapper.readTree(json);
		ArrayNode taskManagers = (ArrayNode) response.get("taskmanagers");

		assertNotNull(taskManagers);
		assertEquals(NUM_TASK_MANAGERS, taskManagers.size());
	} catch (Exception e) {
		e.printStackTrace();
		fail(e.getMessage());
	}
}
 
Example 6
Source File: WebFrontendITCase.java    From flink with Apache License 2.0 6 votes vote down vote up
@Test
public void getTaskmanagers() throws Exception {
	String json = TestBaseUtils.getFromHTTP("http://localhost:" + getRestPort() + "/taskmanagers/");

	ObjectMapper mapper = new ObjectMapper();
	JsonNode parsed = mapper.readTree(json);
	ArrayNode taskManagers = (ArrayNode) parsed.get("taskmanagers");

	assertNotNull(taskManagers);
	assertEquals(NUM_TASK_MANAGERS, taskManagers.size());

	JsonNode taskManager = taskManagers.get(0);
	assertNotNull(taskManager);
	assertEquals(NUM_SLOTS, taskManager.get("slotsNumber").asInt());
	assertTrue(taskManager.get("freeSlots").asInt() <= NUM_SLOTS);
}
 
Example 7
Source File: WebFrontendITCase.java    From flink with Apache License 2.0 6 votes vote down vote up
@Test
public void getTaskManagerLogAndStdoutFiles() {
	try {
		String json = TestBaseUtils.getFromHTTP("http://localhost:" + getRestPort() + "/taskmanagers/");

		ObjectMapper mapper = new ObjectMapper();
		JsonNode parsed = mapper.readTree(json);
		ArrayNode taskManagers = (ArrayNode) parsed.get("taskmanagers");
		JsonNode taskManager = taskManagers.get(0);
		String id = taskManager.get("id").asText();

		WebMonitorUtils.LogFileLocation logFiles = WebMonitorUtils.LogFileLocation.find(CLUSTER_CONFIGURATION);

		//we check for job manager log files, since no separate taskmanager logs exist
		FileUtils.writeStringToFile(logFiles.logFile, "job manager log");
		String logs = TestBaseUtils.getFromHTTP("http://localhost:" + getRestPort() + "/taskmanagers/" + id + "/log");
		assertTrue(logs.contains("job manager log"));

		FileUtils.writeStringToFile(logFiles.stdOutFile, "job manager out");
		logs = TestBaseUtils.getFromHTTP("http://localhost:" + getRestPort() + "/taskmanagers/" + id + "/stdout");
		assertTrue(logs.contains("job manager out"));
	} catch (Exception e) {
		e.printStackTrace();
		fail(e.getMessage());
	}
}
 
Example 8
Source File: WebFrontendITCase.java    From flink with Apache License 2.0 6 votes vote down vote up
@Test
public void getTaskManagers() throws Exception {
	String json = TestBaseUtils.getFromHTTP("http://localhost:" + getRestPort() + "/taskmanagers/");

	ObjectMapper mapper = new ObjectMapper();
	JsonNode parsed = mapper.readTree(json);
	ArrayNode taskManagers = (ArrayNode) parsed.get("taskmanagers");

	assertNotNull(taskManagers);
	assertEquals(NUM_TASK_MANAGERS, taskManagers.size());

	JsonNode taskManager = taskManagers.get(0);
	assertNotNull(taskManager);
	assertEquals(NUM_SLOTS, taskManager.get("slotsNumber").asInt());
	assertTrue(taskManager.get("freeSlots").asInt() <= NUM_SLOTS);
}
 
Example 9
Source File: WebFrontendITCase.java    From flink with Apache License 2.0 5 votes vote down vote up
@Test
public void getConfiguration() throws Exception {
	String config = TestBaseUtils.getFromHTTP("http://localhost:" + getRestPort() + "/jobmanager/config");
	Map<String, String> conf = WebMonitorUtils.fromKeyValueJsonArray(config);

	MemorySize expected = CLUSTER_CONFIGURATION.get(TaskManagerOptions.MANAGED_MEMORY_SIZE);
	MemorySize actual = MemorySize.parse(conf.get(TaskManagerOptions.MANAGED_MEMORY_SIZE.key()));

	assertEquals(expected, actual);
}
 
Example 10
Source File: WebFrontendITCase.java    From Flink-CEPplus with Apache License 2.0 5 votes vote down vote up
@Test
public void getFrontPage() {
	try {
		String fromHTTP = TestBaseUtils.getFromHTTP("http://localhost:" + getRestPort() + "/index.html");
		String text = "Apache Flink Dashboard";
		assertTrue("Startpage should contain " + text, fromHTTP.contains(text));
	} catch (Exception e) {
		e.printStackTrace();
		fail(e.getMessage());
	}
}
 
Example 11
Source File: WebFrontendITCase.java    From flink with Apache License 2.0 5 votes vote down vote up
@Test
public void getCustomLogFiles() throws Exception {
	WebMonitorUtils.LogFileLocation logFiles = WebMonitorUtils.LogFileLocation.find(CLUSTER_CONFIGURATION);

	String customFileName = "test.log";
	final String logDir = logFiles.logFile.getParent();
	final String expectedLogContent = "job manager custom log";
	FileUtils.writeStringToFile(new File(logDir, customFileName), expectedLogContent);

	String logs = TestBaseUtils.getFromHTTP("http://localhost:" + getRestPort() + "/jobmanager/logs/" + customFileName);
	assertThat(logs, containsString(expectedLogContent));
}
 
Example 12
Source File: WebFrontendITCase.java    From flink with Apache License 2.0 5 votes vote down vote up
@Test
public void getLogAndStdoutFiles() throws Exception {
	WebMonitorUtils.LogFileLocation logFiles = WebMonitorUtils.LogFileLocation.find(CLUSTER_CONFIGURATION);

	FileUtils.writeStringToFile(logFiles.logFile, "job manager log");
	String logs = TestBaseUtils.getFromHTTP("http://localhost:" + getRestPort() + "/jobmanager/log");
	assertThat(logs, containsString("job manager log"));

	FileUtils.writeStringToFile(logFiles.stdOutFile, "job manager out");
	logs = TestBaseUtils.getFromHTTP("http://localhost:" + getRestPort() + "/jobmanager/stdout");
	assertThat(logs, containsString("job manager out"));
}
 
Example 13
Source File: WebFrontendITCase.java    From flink with Apache License 2.0 5 votes vote down vote up
@Test
public void getNumberOfTaskManagers() throws Exception {
	String json = TestBaseUtils.getFromHTTP("http://localhost:" + getRestPort() + "/taskmanagers/");

	ObjectMapper mapper = new ObjectMapper();
	JsonNode response = mapper.readTree(json);
	ArrayNode taskManagers = (ArrayNode) response.get("taskmanagers");

	assertNotNull(taskManagers);
	assertEquals(NUM_TASK_MANAGERS, taskManagers.size());
}
 
Example 14
Source File: WebFrontendITCase.java    From flink with Apache License 2.0 5 votes vote down vote up
@Test
public void getConfiguration() {
	try {
		String config = TestBaseUtils.getFromHTTP("http://localhost:" + getRestPort() + "/jobmanager/config");

		Map<String, String> conf = WebMonitorUtils.fromKeyValueJsonArray(config);
		assertEquals(
			CLUSTER_CONFIGURATION.getString(ConfigConstants.LOCAL_START_WEBSERVER, null),
			conf.get(ConfigConstants.LOCAL_START_WEBSERVER));
	} catch (Exception e) {
		e.printStackTrace();
		fail(e.getMessage());
	}
}
 
Example 15
Source File: WebFrontendITCase.java    From flink with Apache License 2.0 5 votes vote down vote up
@Test
public void getLogAndStdoutFiles() throws Exception {
	WebMonitorUtils.LogFileLocation logFiles = WebMonitorUtils.LogFileLocation.find(CLUSTER_CONFIGURATION);

	FileUtils.writeStringToFile(logFiles.logFile, "job manager log");
	String logs = TestBaseUtils.getFromHTTP("http://localhost:" + getRestPort() + "/jobmanager/log");
	assertTrue(logs.contains("job manager log"));

	FileUtils.writeStringToFile(logFiles.stdOutFile, "job manager out");
	logs = TestBaseUtils.getFromHTTP("http://localhost:" + getRestPort() + "/jobmanager/stdout");
	assertTrue(logs.contains("job manager out"));
}
 
Example 16
Source File: WebFrontendITCase.java    From flink with Apache License 2.0 5 votes vote down vote up
@Test
public void getFrontPage() {
	try {
		String fromHTTP = TestBaseUtils.getFromHTTP("http://localhost:" + getRestPort() + "/index.html");
		String text = "Apache Flink Web Dashboard";
		assertTrue("Startpage should contain " + text, fromHTTP.contains(text));
	} catch (Exception e) {
		e.printStackTrace();
		fail(e.getMessage());
	}
}
 
Example 17
Source File: WebFrontendITCase.java    From Flink-CEPplus with Apache License 2.0 5 votes vote down vote up
@Test
public void getConfiguration() {
	try {
		String config = TestBaseUtils.getFromHTTP("http://localhost:" + getRestPort() + "/jobmanager/config");

		Map<String, String> conf = WebMonitorUtils.fromKeyValueJsonArray(config);
		assertEquals(
			CLUSTER_CONFIGURATION.getString(ConfigConstants.LOCAL_START_WEBSERVER, null),
			conf.get(ConfigConstants.LOCAL_START_WEBSERVER));
	} catch (Exception e) {
		e.printStackTrace();
		fail(e.getMessage());
	}
}
 
Example 18
Source File: WebFrontendITCase.java    From Flink-CEPplus with Apache License 2.0 5 votes vote down vote up
@Test
public void getLogAndStdoutFiles() throws Exception {
	WebMonitorUtils.LogFileLocation logFiles = WebMonitorUtils.LogFileLocation.find(CLUSTER_CONFIGURATION);

	FileUtils.writeStringToFile(logFiles.logFile, "job manager log");
	String logs = TestBaseUtils.getFromHTTP("http://localhost:" + getRestPort() + "/jobmanager/log");
	assertTrue(logs.contains("job manager log"));

	FileUtils.writeStringToFile(logFiles.stdOutFile, "job manager out");
	logs = TestBaseUtils.getFromHTTP("http://localhost:" + getRestPort() + "/jobmanager/stdout");
	assertTrue(logs.contains("job manager out"));
}
 
Example 19
Source File: WebFrontendITCase.java    From flink with Apache License 2.0 4 votes vote down vote up
@Test
public void getFrontPage() throws Exception {
	String fromHTTP = TestBaseUtils.getFromHTTP("http://localhost:" + getRestPort() + "/index.html");
	assertThat(fromHTTP, containsString("Apache Flink Web Dashboard"));
}