use of org.junit.jupiter.params.provider.ValueSource in project logging-log4j2 by apache.
the class AsyncAppenderExceptionHandlingTest method AsyncAppender_should_not_stop_on_appender_failures.
@ParameterizedTest
@ValueSource(strings = { FailOnceAppender.ThrowableClassName.RUNTIME_EXCEPTION, FailOnceAppender.ThrowableClassName.LOGGING_EXCEPTION, FailOnceAppender.ThrowableClassName.EXCEPTION, FailOnceAppender.ThrowableClassName.ERROR, FailOnceAppender.ThrowableClassName.THROWABLE, FailOnceAppender.ThrowableClassName.THREAD_DEATH })
void AsyncAppender_should_not_stop_on_appender_failures(String throwableClassName) {
// Create the logger.
final String throwableClassNamePropertyName = "throwableClassName";
System.setProperty(throwableClassNamePropertyName, throwableClassName);
try (final LoggerContext loggerContext = Configurator.initialize("Test", "AsyncAppenderExceptionHandlingTest.xml")) {
final Logger logger = loggerContext.getRootLogger();
// Log the 1st message, which should fail due to the FailOnceAppender.
logger.info("message #1");
// Log the 2nd message, which should succeed.
final String lastLogMessage = "message #2";
logger.info(lastLogMessage);
// Stop the AsyncAppender to drain the queued events.
Configuration configuration = loggerContext.getConfiguration();
AsyncAppender asyncAppender = configuration.getAppender("Async");
Assertions.assertNotNull(asyncAppender, "couldn't obtain the FailOnceAppender");
asyncAppender.stop();
// Verify the logged message.
final FailOnceAppender failOnceAppender = configuration.getAppender("FailOnce");
Assertions.assertNotNull(failOnceAppender, "couldn't obtain the FailOnceAppender");
Assertions.assertTrue(failOnceAppender.isFailed(), "FailOnceAppender hasn't failed yet");
final List<String> accumulatedMessages = failOnceAppender.drainEvents().stream().map(LogEvent::getMessage).map(Message::getFormattedMessage).collect(Collectors.toList());
Assertions.assertEquals(Collections.singletonList(lastLogMessage), accumulatedMessages);
} finally {
System.setProperty(throwableClassNamePropertyName, Strings.EMPTY);
}
}
use of org.junit.jupiter.params.provider.ValueSource in project spring-security by spring-projects.
the class NimbusReactiveOpaqueTokenIntrospectorTests method handleNonJsonContentType.
@ParameterizedTest(name = "{displayName} when Content-Type={0}")
@ValueSource(strings = { MediaType.APPLICATION_CBOR_VALUE, MediaType.TEXT_MARKDOWN_VALUE, MediaType.APPLICATION_XML_VALUE, MediaType.APPLICATION_OCTET_STREAM_VALUE })
public void handleNonJsonContentType(String type) {
WebClient client = mockResponse(ACTIVE_RESPONSE, type);
ReactiveOpaqueTokenIntrospector introspectionClient = new NimbusReactiveOpaqueTokenIntrospector(INTROSPECTION_URL, client);
assertThatExceptionOfType(OAuth2IntrospectionException.class).isThrownBy(() -> introspectionClient.introspect("sometokenhere").block());
}
use of org.junit.jupiter.params.provider.ValueSource in project storm by apache.
the class TopologyIntegrationTest method testBasicTopology.
@ParameterizedTest
@ValueSource(strings = { "true", "false" })
public void testBasicTopology(boolean useLocalMessaging) throws Exception {
try (LocalCluster cluster = new LocalCluster.Builder().withSimulatedTime().withSupervisors(4).withDaemonConf(Collections.singletonMap(Config.STORM_LOCAL_MODE_ZMQ, !useLocalMessaging)).build()) {
TopologyBuilder builder = new TopologyBuilder();
builder.setSpout("1", new TestWordSpout(true), 3);
builder.setBolt("2", new TestWordCounter(), 4).fieldsGrouping("1", new Fields("word"));
builder.setBolt("3", new TestGlobalCount()).globalGrouping("1");
builder.setBolt("4", new TestAggregatesCounter()).globalGrouping("2");
StormTopology topology = builder.createTopology();
Map<String, Object> stormConf = new HashMap<>();
stormConf.put(Config.TOPOLOGY_WORKERS, 2);
stormConf.put(Config.TOPOLOGY_TESTING_ALWAYS_TRY_SERIALIZE, true);
List<FixedTuple> testTuples = Arrays.asList("nathan", "bob", "joey", "nathan").stream().map(value -> new FixedTuple(new Values(value))).collect(Collectors.toList());
MockedSources mockedSources = new MockedSources(Collections.singletonMap("1", testTuples));
CompleteTopologyParam completeTopologyParams = new CompleteTopologyParam();
completeTopologyParams.setMockedSources(mockedSources);
completeTopologyParams.setStormConf(stormConf);
Map<String, List<FixedTuple>> results = Testing.completeTopology(cluster, topology, completeTopologyParams);
assertThat(Testing.readTuples(results, "1"), containsInAnyOrder(new Values("nathan"), new Values("nathan"), new Values("bob"), new Values("joey")));
assertThat(Testing.readTuples(results, "2"), containsInAnyOrder(new Values("nathan", 1), new Values("nathan", 2), new Values("bob", 1), new Values("joey", 1)));
assertThat(Testing.readTuples(results, "3"), contains(new Values(1), new Values(2), new Values(3), new Values(4)));
assertThat(Testing.readTuples(results, "4"), contains(new Values(1), new Values(2), new Values(3), new Values(4)));
}
}
use of org.junit.jupiter.params.provider.ValueSource in project storm by apache.
the class BlobStoreTest method testWithAuthenticationDummy.
@ParameterizedTest
@ValueSource(booleans = { true, false })
void testWithAuthenticationDummy(boolean securityEnabled) throws Exception {
try (AutoCloseableBlobStoreContainer container = initHdfs("/storm/blobstore-auth-dummy-sec-" + securityEnabled)) {
BlobStore store = container.blobStore;
Subject who = getSubject("test_subject");
assertStoreHasExactly(store);
// Tests for case when subject != null (security turned on) and
// acls for the blob are set to WORLD_EVERYTHING
SettableBlobMeta metadata = new SettableBlobMeta(securityEnabled ? BlobStoreAclHandler.DEFAULT : BlobStoreAclHandler.WORLD_EVERYTHING);
try (AtomicOutputStream out = store.createBlob("test", metadata, who)) {
out.write(1);
}
assertStoreHasExactly(store, "test");
if (securityEnabled) {
// Testing whether acls are set to WORLD_EVERYTHING. Here the acl should not contain WORLD_EVERYTHING because
// the subject is neither null nor empty. The ACL should however contain USER_EVERYTHING as user needs to have
// complete access to the blob
assertTrue("ACL contains WORLD_EVERYTHING", !metadata.toString().contains("AccessControl(type:OTHER, access:7)"));
} else {
// Testing whether acls are set to WORLD_EVERYTHING
assertTrue("ACL does not contain WORLD_EVERYTHING", metadata.toString().contains("AccessControl(type:OTHER, access:7)"));
}
readAssertEqualsWithAuth(store, who, "test", 1);
LOG.info("Deleting test");
store.deleteBlob("test", who);
assertStoreHasExactly(store);
}
}
use of org.junit.jupiter.params.provider.ValueSource in project storm by apache.
the class TestGenericResourceAwareStrategy method testGenericResourceAwareStrategyWithSettingAckerExecutors.
/**
* Test if the scheduling logic for the GenericResourceAwareStrategy is correct
* with setting {@link Config#TOPOLOGY_ACKER_EXECUTORS}.
*
* Test details refer to {@link TestDefaultResourceAwareStrategy#testDefaultResourceAwareStrategyWithSettingAckerExecutors(int)}
*/
@ParameterizedTest
@ValueSource(ints = { -1, 0, 2, 200 })
public void testGenericResourceAwareStrategyWithSettingAckerExecutors(int numOfAckersPerWorker) throws InvalidTopologyException {
int spoutParallelism = 1;
int boltParallelism = 2;
TopologyBuilder builder = new TopologyBuilder();
builder.setSpout("spout", new TestSpout(), spoutParallelism);
builder.setBolt("bolt-1", new TestBolt(), boltParallelism).shuffleGrouping("spout");
builder.setBolt("bolt-2", new TestBolt(), boltParallelism).shuffleGrouping("bolt-1").addResource("gpu.count", 1.0);
builder.setBolt("bolt-3", new TestBolt(), boltParallelism).shuffleGrouping("bolt-2").addResource("gpu.count", 2.0);
String topoName = "testTopology";
StormTopology stormToplogy = builder.createTopology();
INimbus iNimbus = new INimbusTest();
Config conf = createGrasClusterConfig(50, 500, 0, null, Collections.emptyMap());
Map<String, Double> genericResourcesMap = new HashMap<>();
genericResourcesMap.put("gpu.count", 2.0);
Map<String, SupervisorDetails> supMap = genSupervisors(4, 4, 200, 2000, genericResourcesMap);
conf.put(Config.TOPOLOGY_PRIORITY, 0);
conf.put(Config.TOPOLOGY_NAME, topoName);
conf.put(Config.TOPOLOGY_WORKER_MAX_HEAP_SIZE_MB, 2000);
conf.put(Config.TOPOLOGY_SUBMITTER_USER, "user");
conf.put(Config.TOPOLOGY_ACKER_EXECUTORS, 4);
if (numOfAckersPerWorker == -1) {
// Leave topology.acker.executors.per.worker unset
} else {
conf.put(Config.TOPOLOGY_RAS_ACKER_EXECUTORS_PER_WORKER, numOfAckersPerWorker);
}
int estimatedNumWorker = ServerUtils.getEstimatedWorkerCountForRasTopo(conf, stormToplogy);
Nimbus.setUpAckerExecutorConfigs(topoName, conf, conf, estimatedNumWorker);
conf.put(Config.TOPOLOGY_ACKER_RESOURCES_ONHEAP_MEMORY_MB, 250);
conf.put(Config.TOPOLOGY_ACKER_CPU_PCORE_PERCENT, 50);
TopologyDetails topo = new TopologyDetails("testTopology-id", conf, stormToplogy, 0, genExecsAndComps(StormCommon.systemTopology(conf, stormToplogy)), currentTime, "user");
Topologies topologies = new Topologies(topo);
Cluster cluster = new Cluster(iNimbus, new ResourceMetrics(new StormMetricsRegistry()), supMap, new HashMap<>(), topologies, conf);
scheduler = new ResourceAwareScheduler();
scheduler.prepare(conf, new StormMetricsRegistry());
scheduler.schedule(topologies, cluster);
// We need to have 3 slots on 3 separate hosts. The topology needs 6 GPUs 3500 MB memory and 350% CPU
// The bolt-3 instances must be on separate nodes because they each need 2 GPUs.
// The bolt-2 instances must be on the same node as they each need 1 GPU
// (this assumes that we are packing the components to avoid fragmentation).
// The bolt-1 and spout instances fill in the rest.
// Ordered execs: [[6, 6], [2, 2], [4, 4], [5, 5], [1, 1], [3, 3], [0, 0]]
// Ackers: [[8, 8], [7, 7]] (+ [[9, 9], [10, 10]] when numOfAckersPerWorker=2)
HashSet<HashSet<ExecutorDetails>> expectedScheduling = new HashSet<>();
expectedScheduling.add(new HashSet<>(Arrays.asList(// bolt-3 - 500 MB, 50% CPU, 2 GPU
new ExecutorDetails(3, 3))));
// Total 500 MB, 50% CPU, 2 - GPU -> this node has 1500 MB, 150% cpu, 0 GPU left
expectedScheduling.add(new HashSet<>(Arrays.asList(// acker - 250 MB, 50% CPU, 0 GPU
new ExecutorDetails(7, 7), // acker - 250 MB, 50% CPU, 0 GPU
new ExecutorDetails(8, 8), // bolt-2 - 500 MB, 50% CPU, 1 GPU
new ExecutorDetails(6, 6), // bolt-1 - 500 MB, 50% CPU, 0 GPU
new ExecutorDetails(2, 2))));
// Total 1500 MB, 200% CPU, 2 GPU -> this node has 500 MB, 0% CPU, 0 GPU left
expectedScheduling.add(new HashSet<>(Arrays.asList(// acker- 250 MB, 50% CPU, 0 GPU
new ExecutorDetails(9, 9), // acker- 250 MB, 50% CPU, 0 GPU
new ExecutorDetails(10, 10), // bolt-1 - 500 MB, 50% CPU, 0 GPU
new ExecutorDetails(1, 1), // bolt-3 500 MB, 50% cpu, 2 GPU
new ExecutorDetails(4, 4))));
// Total 1500 MB, 200% CPU, 2 GPU -> this node has 500 MB, 0% CPU, 0 GPU left
expectedScheduling.add(new HashSet<>(Arrays.asList(// Spout - 500 MB, 50% CPU, 0 GPU
new ExecutorDetails(0, 0), // bolt-2 - 500 MB, 50% CPU, 1 GPU
new ExecutorDetails(5, 5))));
// Total 1000 MB, 100% CPU, 2 GPU -> this node has 1000 MB, 100% CPU, 0 GPU left
HashSet<HashSet<ExecutorDetails>> foundScheduling = new HashSet<>();
SchedulerAssignment assignment = cluster.getAssignmentById("testTopology-id");
for (Collection<ExecutorDetails> execs : assignment.getSlotToExecutors().values()) {
foundScheduling.add(new HashSet<>(execs));
}
assertEquals(expectedScheduling, foundScheduling);
}
Aggregations