@Test public void testTags() { assumeTrue(isMainRun()); Topology t = newTopology(); TStream<String> s1 = t.strings("3"); TStream<String> s2 = t.strings("3"); TStream<String> s3 = t.strings("3"); s1.addResourceTags(); assertNull(getResourceTags(s1)); s2.addResourceTags("A", "B"); Set<String> s2s = getResourceTags(s2); assertEquals(2, s2s.size()); assertTrue(s2s.contains("A")); assertTrue(s2s.contains("B")); s3.addResourceTags("C", "D", "E"); Set<String> s3s = getResourceTags(s3); assertEquals(3, s3s.size()); assertTrue(s3s.contains("C")); assertTrue(s3s.contains("D")); assertTrue(s3s.contains("E")); s2s = getResourceTags(s2); assertEquals(2, s2s.size()); assertTrue(s2s.contains("A")); assertTrue(s2s.contains("B")); s2.addResourceTags("X", "Y"); s2s = getResourceTags(s2); assertEquals(4, s2s.size()); assertTrue(s2s.contains("A")); assertTrue(s2s.contains("B")); assertTrue(s2s.contains("X")); assertTrue(s2s.contains("Y")); // Colocating means the s1 will inherit // s3 resource tags s1.colocate(s3); Set<String> s1s = getResourceTags(s1); assertEquals(3, s1s.size()); assertTrue(s1s.contains("C")); assertTrue(s1s.contains("D")); assertTrue(s1s.contains("E")); }
/** * Test with a distributed execution with explicit colocation of two functions end up on the same * container. */ @Test @Ignore("Need to figure out how to get the tags set by the test") // TODO public void testSimpleDistributedHostTags() throws Exception { assumeTrue(SC_OK); assumeTrue(getTesterType() == StreamsContext.Type.DISTRIBUTED_TESTER); Topology t = newTopology(); TStream<String> sa = t.strings("a"); sa.addResourceTags("application"); sa = sa.filter(new AllowAll<String>()); sa.addResourceTags("application"); getConfig().put(ContextProperties.KEEP_ARTIFACTS, Boolean.TRUE); Condition<List<String>> aout = t.getTester().stringContents(sa, "a"); complete(t.getTester(), aout, 10, TimeUnit.SECONDS); assertTrue(aout.getResult().toString(), aout.valid()); }