Map<String, String> expectedValues = Maps.newHashMap();
expectedValues.put(EnvKeys.YARN_CONTAINER_MEMORY_MB, "2048");
expectedValues.put(EnvKeys.TWILL_INSTANCE_COUNT, "1");
// check environment of the runnable.
Discoverable discoverable = envEchoServices.iterator().next();
for (Map.Entry<String, String> expected : expectedValues.entrySet()) {
Socket socket = new Socket(discoverable.getSocketAddress().getHostName(),
discoverable.getSocketAddress().getPort());
try {
PrintWriter writer = new PrintWriter(new OutputStreamWriter(socket.getOutputStream(), Charsets.UTF_8), true);
LineReader reader = new LineReader(new InputStreamReader(socket.getInputStream(), Charsets.UTF_8));
writer.println(expected.getKey());
Assert.assertEquals(expected.getValue(), reader.readLine());