Search in sources :

Example 1 with NBConfiguration

use of io.nosqlbench.nb.api.config.standard.NBConfiguration in project nosqlbench by nosqlbench.

the class ConfigModelTest method testMultipleParams.

@Test
public void testMultipleParams() {
    ConfigModel cm = ConfigModel.of(ConfigModelTest.class, Param.defaultTo(List.of("a", "b"), "value").setRequired(false), Param.required("c", int.class));
    NBConfiguration cfg = cm.apply(Map.of("c", 232));
    assertThat(cfg.getOptional("a")).isEmpty();
    assertThat(cfg.get("c", int.class)).isEqualTo(232);
}
Also used : ConfigModel(io.nosqlbench.nb.api.config.standard.ConfigModel) NBConfiguration(io.nosqlbench.nb.api.config.standard.NBConfiguration) Test(org.junit.jupiter.api.Test)

Example 2 with NBConfiguration

use of io.nosqlbench.nb.api.config.standard.NBConfiguration in project nosqlbench by nosqlbench.

the class ActivityTypeLoader method getDriverAdapter.

private Optional<ActivityType> getDriverAdapter(String activityTypeName, ActivityDef activityDef) {
    Optional<DriverAdapter> oda = DRIVERADAPTER_SPI_FINDER.getOptionally(activityTypeName);
    if (oda.isPresent()) {
        DriverAdapter<?, ?> driverAdapter = oda.get();
        activityDef.getParams().remove("driver");
        if (driverAdapter instanceof NBConfigurable) {
            NBConfigModel cfgModel = ((NBConfigurable) driverAdapter).getConfigModel();
            Optional<String> op_yaml_loc = activityDef.getParams().getOptionalString("yaml", "workload");
            if (op_yaml_loc.isPresent()) {
                Map<String, Object> disposable = new LinkedHashMap<>(activityDef.getParams());
                StmtsDocList workload = StatementsLoader.loadPath(logger, op_yaml_loc.get(), disposable, "activities");
                cfgModel = cfgModel.add(workload.getConfigModel());
            }
            NBConfiguration cfg = cfgModel.apply(activityDef.getParams());
            ((NBConfigurable) driverAdapter).applyConfig(cfg);
        }
        ActivityType activityType = new StandardActivityType<>(driverAdapter, activityDef);
        return Optional.of(activityType);
    } else {
        return Optional.empty();
    }
}
Also used : NBConfigurable(io.nosqlbench.nb.api.config.standard.NBConfigurable) StandardActivityType(io.nosqlbench.engine.api.activityimpl.uniform.StandardActivityType) StandardActivityType(io.nosqlbench.engine.api.activityimpl.uniform.StandardActivityType) ActivityType(io.nosqlbench.engine.api.activityapi.core.ActivityType) NBConfiguration(io.nosqlbench.nb.api.config.standard.NBConfiguration) StmtsDocList(io.nosqlbench.engine.api.activityconfig.yaml.StmtsDocList) DriverAdapter(io.nosqlbench.engine.api.activityimpl.uniform.DriverAdapter) NBConfigModel(io.nosqlbench.nb.api.config.standard.NBConfigModel)

Example 3 with NBConfiguration

use of io.nosqlbench.nb.api.config.standard.NBConfiguration in project nosqlbench by nosqlbench.

the class DynamoDBDriverAdapter method getOpMapper.

@Override
public OpMapper<DynamoDBOp> getOpMapper() {
    DriverSpaceCache<? extends DynamoDBSpace> spaceCache = getSpaceCache();
    NBConfiguration adapterConfig = getConfiguration();
    return new DynamoDBOpMapper(adapterConfig, spaceCache);
}
Also used : NBConfiguration(io.nosqlbench.nb.api.config.standard.NBConfiguration)

Example 4 with NBConfiguration

use of io.nosqlbench.nb.api.config.standard.NBConfiguration in project nosqlbench by nosqlbench.

the class SSLKsFactoryTest method testOpenSSLGetContextWithMissingCertError.

@Test
public void testOpenSSLGetContextWithMissingCertError() {
    String[] params = { "ssl=openssl", "caCertFilePath=src/test/resources/ssl/cacert.crt", "keyFilePath=src/test/resources/ssl/client.key" };
    ActivityDef activityDef = ActivityDef.parseActivityDef(String.join(";", params));
    NBConfiguration sslCfg = SSLKsFactory.get().getConfigModel().extractConfig(activityDef.getParams());
    assertThatExceptionOfType(RuntimeException.class).isThrownBy(() -> SSLKsFactory.get().getContext(sslCfg)).withMessageContaining("Unable to load key from").withCauseInstanceOf(IllegalArgumentException.class);
}
Also used : NBConfiguration(io.nosqlbench.nb.api.config.standard.NBConfiguration) ActivityDef(io.nosqlbench.engine.api.activityimpl.ActivityDef) Test(org.junit.jupiter.api.Test)

Example 5 with NBConfiguration

use of io.nosqlbench.nb.api.config.standard.NBConfiguration in project nosqlbench by nosqlbench.

the class SSLKsFactoryTest method testJdkGetContextWithTruststoreAndKeystoreAndDifferentKeyPassword.

@Test
public void testJdkGetContextWithTruststoreAndKeystoreAndDifferentKeyPassword() {
    String[] params = { "ssl=jdk", "truststore=src/test/resources/ssl/server_truststore.p12", "tspass=nosqlbench_server", "keystore=src/test/resources/ssl/client_diff_password.p12", "kspass=nosqlbench_client", "keyPassword=nosqlbench" };
    ActivityDef activityDef = ActivityDef.parseActivityDef(String.join(";", params));
    NBConfiguration sslCfg = SSLKsFactory.get().getConfigModel().extractConfig(activityDef.getParams());
    assertThat(SSLKsFactory.get().getContext(sslCfg)).isNotNull();
}
Also used : NBConfiguration(io.nosqlbench.nb.api.config.standard.NBConfiguration) ActivityDef(io.nosqlbench.engine.api.activityimpl.ActivityDef) Test(org.junit.jupiter.api.Test)

Aggregations

NBConfiguration (io.nosqlbench.nb.api.config.standard.NBConfiguration)24 Test (org.junit.jupiter.api.Test)18 ActivityDef (io.nosqlbench.engine.api.activityimpl.ActivityDef)17 NBConfigurable (io.nosqlbench.nb.api.config.standard.NBConfigurable)2 Cqld4CoreOpMapper (io.nosqlbench.adapter.cqld4.opmappers.Cqld4CoreOpMapper)1 ActivityType (io.nosqlbench.engine.api.activityapi.core.ActivityType)1 StmtsDocList (io.nosqlbench.engine.api.activityconfig.yaml.StmtsDocList)1 DriverAdapter (io.nosqlbench.engine.api.activityimpl.uniform.DriverAdapter)1 StandardActivityType (io.nosqlbench.engine.api.activityimpl.uniform.StandardActivityType)1 Annotator (io.nosqlbench.nb.api.annotations.Annotator)1 ConfigLoader (io.nosqlbench.nb.api.config.standard.ConfigLoader)1 ConfigModel (io.nosqlbench.nb.api.config.standard.ConfigModel)1 NBConfigModel (io.nosqlbench.nb.api.config.standard.NBConfigModel)1 NBMapConfigurable (io.nosqlbench.nb.api.config.standard.NBMapConfigurable)1 IOException (java.io.IOException)1 PrintWriter (java.io.PrintWriter)1 Socket (java.net.Socket)1 SocketFactory (javax.net.SocketFactory)1