MCPcopy Create free account
hub / github.com/apache/mesos / getProcessIOData

Function getProcessIOData

src/tests/api_tests.cpp:5454–5492  ·  view source on GitHub ↗

Reads `ProcessIO::Data` records from the pipe `reader` until EOF is reached and returns the merged stdout and stderr. NOTE: It ignores any `ProcessIO::Control` records.

Source from the content-addressed store, hash-verified

5452// and returns the merged stdout and stderr.
5453// NOTE: It ignores any `ProcessIO::Control` records.
5454static Future<tuple<string, string>> getProcessIOData(
5455 ContentType contentType,
5456 http::Pipe::Reader reader)
5457{
5458 return reader.readAll()
5459 .then([contentType](const string& data) -> Future<tuple<string, string>> {
5460 string stdoutReceived;
5461 string stderrReceived;
5462
5463 ::recordio::Decoder decoder;
5464
5465 Try<std::deque<string>> records = decoder.decode(data);
5466
5467 if (records.isError()) {
5468 return process::Failure(records.error());
5469 }
5470
5471 while(!records->empty()) {
5472 string record = std::move(records->front());
5473 records->pop_front();
5474
5475 Try<v1::agent::ProcessIO> processIO =
5476 deserialize<v1::agent::ProcessIO>(contentType, record);
5477
5478 if (processIO.isError()) {
5479 return process::Failure(processIO.error());
5480 }
5481
5482 if (processIO->data().type() == v1::agent::ProcessIO::Data::STDOUT) {
5483 stdoutReceived += processIO->data().data();
5484 } else if (processIO->data().type() ==
5485 v1::agent::ProcessIO::Data::STDERR) {
5486 stderrReceived += processIO->data().data();
5487 }
5488 }
5489
5490 return std::make_tuple(stdoutReceived, stderrReceived);
5491 });
5492}
5493
5494
5495TEST_P(AgentAPITest, GetFlags)

Callers 3

foreachFunction · 0.85
TEST_FFunction · 0.85

Calls 9

FailureClass · 0.85
readAllMethod · 0.80
typeMethod · 0.80
dataMethod · 0.80
errorMethod · 0.65
thenMethod · 0.45
decodeMethod · 0.45
isErrorMethod · 0.45
emptyMethod · 0.45

Tested by

no test coverage detected