@Before public void beforeAll() throws Exception { server = new TestingServer(); server.start(); Capabilities mockCapabilities = Mockito.mock(Capabilities.class); when(mockCapabilities.supportsNamedVips()).thenReturn(true); taskFactory = new CassandraDaemonTask.Factory(mockCapabilities); configurationFactory = new ConfigurationFactory<>( MutableSchedulerConfiguration.class, BaseValidator.newValidator(), Jackson.newObjectMapper() .registerModule(new GuavaModule()) .registerModule(new Jdk8Module()), "dw"); connectString = server.getConnectString(); }
@Test public void canDeserializeCorrectly() throws IOException, ConfigurationException { final HikariDataSourceFactory factory = new YamlConfigurationFactory<>(HikariDataSourceFactory.class, BaseValidator.newValidator(), Jackson.newObjectMapper(), "dw") .build(new ResourceConfigurationSourceProvider(), "config.yaml"); assertThat(factory.getUser()).isEqualTo("nick"); assertThat(factory.getPassword()).isEqualTo("nickss"); assertThat(factory.getDatasourceClassName()).isEqualTo("org.postgresql.ds.PGSimpleDataSource"); assertThat(factory.getProperties()).containsExactly(entry("databaseName", "postgres")); assertThat(factory.getMinSize()).isEqualTo(OptionalInt.empty()); assertThat(factory.getMaxSize()).isEqualTo(12); assertThat(factory.isAutoCommit()).isTrue(); }
@Before public void beforeEach() throws Exception { factory = new ConfigurationFactory<>( MutableSchedulerConfiguration.class, BaseValidator.newValidator(), Jackson.newObjectMapper().registerModule(new GuavaModule()) .registerModule(new Jdk8Module()), "dw"); configuration = factory.build( new SubstitutingSourceProvider( new FileConfigurationSourceProvider(), new EnvironmentVariableSubstitutor(false, true)), Resources.getResource("scheduler.yml").getFile()); }
private UserInfoConfiguration buildConfigurationFromString(String fileLocation) throws Exception { final File file = new File(Resources.getResource(fileLocation).toURI()); return new DefaultConfigurationFactoryFactory<UserInfoConfiguration>() .create(UserInfoConfiguration.class, BaseValidator.newValidator(), Jackson.newObjectMapper(), "dw") .build(file); }
@Before public void setup() throws Exception { final File configFile = new File(Resources.getResource("dropwizard/valid-conf.yml").toURI()); configuration = new DefaultConfigurationFactoryFactory<UserInfoConfiguration>() .create(UserInfoConfiguration.class, BaseValidator.newValidator(), Jackson.newObjectMapper(), "dw") .build(configFile); // Common Expectations when(environment.healthChecks()).thenReturn(healthCheckRegistry); when(environment.jersey()).thenReturn(jerseyEnvironment); assertThat(configuration.getData().getNamesResource()).isEqualTo("fixtures/users/test-names.txt"); }
@Before public void beforeEach() throws Exception { server = new TestingServer(); server.start(); final ConfigurationFactory<MutableSchedulerConfiguration> factory = new ConfigurationFactory<>( MutableSchedulerConfiguration.class, BaseValidator.newValidator(), Jackson.newObjectMapper().registerModule( new GuavaModule()) .registerModule(new Jdk8Module()), "dw"); config = factory.build( new SubstitutingSourceProvider( new FileConfigurationSourceProvider(), new EnvironmentVariableSubstitutor(false, true)), Resources.getResource("scheduler.yml").getFile()); ServiceConfig initial = config.createConfig().getServiceConfig(); final CassandraSchedulerConfiguration targetConfig = config.createConfig(); clusterTaskConfig = targetConfig.getClusterTaskConfig(); final CuratorFrameworkConfig curatorConfig = config.getCuratorConfig(); RetryPolicy retryPolicy = (curatorConfig.getOperationTimeout().isPresent()) ? new RetryUntilElapsed( curatorConfig.getOperationTimeoutMs() .get() .intValue() , (int) curatorConfig.getBackoffMs()) : new RetryForever((int) curatorConfig.getBackoffMs()); stateStore = new CuratorStateStore( targetConfig.getServiceConfig().getName(), server.getConnectString(), retryPolicy); stateStore.storeFrameworkId(Protos.FrameworkID.newBuilder().setValue("1234").build()); identity = new IdentityManager( initial,stateStore); identity.register("test_id"); DefaultConfigurationManager configurationManager = new DefaultConfigurationManager(CassandraSchedulerConfiguration.class, config.createConfig().getServiceConfig().getName(), server.getConnectString(), config.createConfig(), new ConfigValidator(), stateStore); Capabilities mockCapabilities = Mockito.mock(Capabilities.class); when(mockCapabilities.supportsNamedVips()).thenReturn(true); configuration = new ConfigurationManager( new CassandraDaemonTask.Factory(mockCapabilities), configurationManager); cassandraState = new CassandraState( configuration, clusterTaskConfig, stateStore); }
@BeforeClass public static void beforeAll() throws Exception { server = new TestingServer(); server.start(); final ConfigurationFactory<MutableSchedulerConfiguration> factory = new ConfigurationFactory<>( MutableSchedulerConfiguration.class, BaseValidator.newValidator(), Jackson.newObjectMapper().registerModule( new GuavaModule()) .registerModule(new Jdk8Module()), "dw"); config = factory.build( new SubstitutingSourceProvider( new FileConfigurationSourceProvider(), new EnvironmentVariableSubstitutor(false, true)), Resources.getResource("scheduler.yml").getFile()); final CuratorFrameworkConfig curatorConfig = config.getCuratorConfig(); RetryPolicy retryPolicy = (curatorConfig.getOperationTimeout().isPresent()) ? new RetryUntilElapsed( curatorConfig.getOperationTimeoutMs() .get() .intValue() , (int) curatorConfig.getBackoffMs()) : new RetryForever((int) curatorConfig.getBackoffMs()); stateStore = new CuratorStateStore( config.createConfig().getServiceConfig().getName(), server.getConnectString(), retryPolicy); final CassandraSchedulerConfiguration configuration = config.createConfig(); try { final ConfigValidator configValidator = new ConfigValidator(); final DefaultConfigurationManager defaultConfigurationManager = new DefaultConfigurationManager(CassandraSchedulerConfiguration.class, configuration.getServiceConfig().getName(), server.getConnectString(), configuration, configValidator, stateStore); Capabilities mockCapabilities = Mockito.mock(Capabilities.class); when(mockCapabilities.supportsNamedVips()).thenReturn(true); configurationManager = new ConfigurationManager( new CassandraDaemonTask.Factory(mockCapabilities), defaultConfigurationManager); } catch (ConfigStoreException e) { throw new RuntimeException(e); } }
@BeforeClass public static void beforeAll() throws Exception { server = new TestingServer(); server.start(); final ConfigurationFactory<MutableSchedulerConfiguration> factory = new ConfigurationFactory<>( MutableSchedulerConfiguration.class, BaseValidator.newValidator(), Jackson.newObjectMapper().registerModule( new GuavaModule()) .registerModule(new Jdk8Module()), "dw"); MutableSchedulerConfiguration mutable = factory.build( new SubstitutingSourceProvider( new FileConfigurationSourceProvider(), new EnvironmentVariableSubstitutor(false, true)), Resources.getResource("scheduler.yml").getFile()); config = mutable.createConfig(); final CuratorFrameworkConfig curatorConfig = mutable.getCuratorConfig(); RetryPolicy retryPolicy = (curatorConfig.getOperationTimeout().isPresent()) ? new RetryUntilElapsed( curatorConfig.getOperationTimeoutMs() .get() .intValue() , (int) curatorConfig.getBackoffMs()) : new RetryForever((int) curatorConfig.getBackoffMs()); StateStore stateStore = new CuratorStateStore( config.getServiceConfig().getName(), server.getConnectString(), retryPolicy); configurationManager = new DefaultConfigurationManager(CassandraSchedulerConfiguration.class, config.getServiceConfig().getName(), server.getConnectString(), config, new ConfigValidator(), stateStore); config = (CassandraSchedulerConfiguration) configurationManager.getTargetConfig(); }
private void beforeHelper(String configName) throws Exception { MockitoAnnotations.initMocks(this); mesosConfig = Mockito.mock(MesosConfig.class); client = Mockito.mock(SchedulerClient.class); Mockito.when(mockFuture.get()).thenReturn(true); Mockito.when(mockStage.toCompletableFuture()).thenReturn(mockFuture); backup = Mockito.mock(BackupManager.class); restore = Mockito.mock(RestoreManager.class); cleanup = Mockito.mock(CleanupManager.class); repair = Mockito.mock(RepairManager.class); upgrade = Mockito.mock(UpgradeSSTableManager.class); seeds = Mockito.mock(SeedsManager.class); capabilities = Mockito.mock(Capabilities.class); executorService = Executors.newSingleThreadScheduledExecutor(); frameworkId = TestUtils.generateFrameworkId(); factory = new ConfigurationFactory<>( MutableSchedulerConfiguration.class, BaseValidator.newValidator(), Jackson.newObjectMapper().registerModule( new GuavaModule()) .registerModule(new Jdk8Module()), "dw"); config = factory.build( new SubstitutingSourceProvider( new FileConfigurationSourceProvider(), new EnvironmentVariableSubstitutor(false, true)), Resources.getResource(configName).getFile()); stateStore = new CuratorStateStore( "/" + config.getServiceConfig().getName(), server.getConnectString()); DefaultConfigurationManager defaultConfigurationManager = new DefaultConfigurationManager(CassandraSchedulerConfiguration.class, "/" + config.createConfig().getServiceConfig().getName(), server.getConnectString(), config.createConfig(), new ConfigValidator(), stateStore); Capabilities mockCapabilities = Mockito.mock(Capabilities.class); when(mockCapabilities.supportsNamedVips()).thenReturn(true); configurationManager = new ConfigurationManager( new CassandraDaemonTask.Factory(mockCapabilities), defaultConfigurationManager); cassandraState = new CassandraState( configurationManager, configurationManager.getTargetConfig().getClusterTaskConfig(), stateStore); offerRequirementProvider = new PersistentOfferRequirementProvider(defaultConfigurationManager); scheduler = new CassandraScheduler( configurationManager, mesosConfig, offerRequirementProvider, cassandraState, client, backup, restore, cleanup, repair, upgrade, true, seeds, executorService, stateStore, defaultConfigurationManager, capabilities); masterInfo = TestUtils.generateMasterInfo(); driver = new QueuedSchedulerDriver(); scheduler.setSchedulerDriver(driver); scheduler.registered(driver, frameworkId, masterInfo); }
@Before public void beforeEach() throws Exception { MockitoAnnotations.initMocks(this); server = new TestingServer(); server.start(); Capabilities mockCapabilities = mock(Capabilities.class); when(mockCapabilities.supportsNamedVips()).thenReturn(true); taskFactory = new CassandraDaemonTask.Factory(mockCapabilities); final ConfigurationFactory<MutableSchedulerConfiguration> factory = new ConfigurationFactory<>( MutableSchedulerConfiguration.class, BaseValidator.newValidator(), Jackson.newObjectMapper().registerModule( new GuavaModule()) .registerModule(new Jdk8Module()), "dw"); config = factory.build( new SubstitutingSourceProvider( new FileConfigurationSourceProvider(), new EnvironmentVariableSubstitutor(false, true)), Resources.getResource("scheduler.yml").getFile()); final CassandraSchedulerConfiguration targetConfig = config.createConfig(); clusterTaskConfig = targetConfig.getClusterTaskConfig(); final CuratorFrameworkConfig curatorConfig = config.getCuratorConfig(); RetryPolicy retryPolicy = (curatorConfig.getOperationTimeout().isPresent()) ? new RetryUntilElapsed( curatorConfig.getOperationTimeoutMs() .get() .intValue() , (int) curatorConfig.getBackoffMs()) : new RetryForever((int) curatorConfig.getBackoffMs()); stateStore = new CuratorStateStore( targetConfig.getServiceConfig().getName(), server.getConnectString(), retryPolicy); stateStore.storeFrameworkId(Protos.FrameworkID.newBuilder().setValue("1234").build()); configurationManager = new DefaultConfigurationManager(CassandraSchedulerConfiguration.class, config.createConfig().getServiceConfig().getName(), server.getConnectString(), config.createConfig(), new ConfigValidator(), stateStore); cassandraState = new CassandraState( new ConfigurationManager(taskFactory, configurationManager), clusterTaskConfig, stateStore); }
@BeforeClass public static void beforeAll() throws Exception { server = new TestingServer(); server.start(); final ConfigurationFactory<MutableSchedulerConfiguration> factory = new ConfigurationFactory<>( MutableSchedulerConfiguration.class, BaseValidator.newValidator(), Jackson.newObjectMapper().registerModule( new GuavaModule()) .registerModule(new Jdk8Module()), "dw"); MutableSchedulerConfiguration mutable = factory.build( new SubstitutingSourceProvider( new FileConfigurationSourceProvider(), new EnvironmentVariableSubstitutor(false, true)), Resources.getResource("scheduler.yml").getFile()); config = mutable.createConfig(); ServiceConfig initial = config.getServiceConfig(); clusterTaskConfig = config.getClusterTaskConfig(); final CuratorFrameworkConfig curatorConfig = mutable.getCuratorConfig(); RetryPolicy retryPolicy = (curatorConfig.getOperationTimeout().isPresent()) ? new RetryUntilElapsed( curatorConfig.getOperationTimeoutMs() .get() .intValue() , (int) curatorConfig.getBackoffMs()) : new RetryForever((int) curatorConfig.getBackoffMs()); stateStore = new CuratorStateStore( config.getServiceConfig().getName(), server.getConnectString(), retryPolicy); stateStore.storeFrameworkId(Protos.FrameworkID.newBuilder().setValue("1234").build()); identity = new IdentityManager( initial,stateStore); identity.register("test_id"); DefaultConfigurationManager configurationManager = new DefaultConfigurationManager(CassandraSchedulerConfiguration.class, config.getServiceConfig().getName(), server.getConnectString(), config, new ConfigValidator(), stateStore); Capabilities mockCapabilities = Mockito.mock(Capabilities.class); when(mockCapabilities.supportsNamedVips()).thenReturn(true); configuration = new ConfigurationManager( new CassandraDaemonTask.Factory(mockCapabilities), configurationManager); provider = new ClusterTaskOfferRequirementProvider(); }
@Before public void beforeEach() throws Exception { MockitoAnnotations.initMocks(this); server = new TestingServer(); server.start(); final ConfigurationFactory<MutableSchedulerConfiguration> factory = new ConfigurationFactory<>( MutableSchedulerConfiguration.class, BaseValidator.newValidator(), Jackson.newObjectMapper().registerModule( new GuavaModule()) .registerModule(new Jdk8Module()), "dw"); config = factory.build( new SubstitutingSourceProvider( new FileConfigurationSourceProvider(), new EnvironmentVariableSubstitutor(false, true)), Resources.getResource("scheduler.yml").getFile()); ServiceConfig initial = config.createConfig().getServiceConfig(); final CassandraSchedulerConfiguration targetConfig = config.createConfig(); clusterTaskConfig = targetConfig.getClusterTaskConfig(); final CuratorFrameworkConfig curatorConfig = config.getCuratorConfig(); RetryPolicy retryPolicy = (curatorConfig.getOperationTimeout().isPresent()) ? new RetryUntilElapsed( curatorConfig.getOperationTimeoutMs() .get() .intValue() , (int) curatorConfig.getBackoffMs()) : new RetryForever((int) curatorConfig.getBackoffMs()); stateStore = new CuratorStateStore( targetConfig.getServiceConfig().getName(), server.getConnectString(), retryPolicy); stateStore.storeFrameworkId(Protos.FrameworkID.newBuilder().setValue("1234").build()); identity = new IdentityManager(initial,stateStore); identity.register("test_id"); DefaultConfigurationManager configurationManager = new DefaultConfigurationManager(CassandraSchedulerConfiguration.class, config.createConfig().getServiceConfig().getName(), server.getConnectString(), config.createConfig(), new ConfigValidator(), stateStore); Capabilities mockCapabilities = Mockito.mock(Capabilities.class); when(mockCapabilities.supportsNamedVips()).thenReturn(true); configuration = new ConfigurationManager( new CassandraDaemonTask.Factory(mockCapabilities), configurationManager); cassandraState = new CassandraState( configuration, clusterTaskConfig, stateStore); taskFactory = new CassandraTaskFactory(executorDriver); }