StyxScheduler implements AppInit { static FlyteRunner createFlyteRunner(String runnerId, Config config, StateManager stateManager) { if (!config.getBoolean(FLYTE_ENABLED)) { return FlyteRunner.noop(); } var flyteAdminClient = getFlyteAdminClient(config, runnerId); return FlyteRunner.flyteAdmin(runnerId, flyteAdminClient, stateManager); } private  StyxScheduler(Builder builder); static Builder newBuilder(); static StyxScheduler createDefault(); @Override void create(Environment environment); @VisibleForTesting static NamespacedKubernetesClient getKubernetesClient(Config config, String id); static final String SERVICE_NAME; static final String STYX_STALE_STATE_TTL_CONFIG; }
@Test public void testCreateFlyteRunner() { var configMap = ImmutableMap.<String, String>builder() .put("styx.flyte.enabled", "true") .put("styx.flyte.admin.production.host", "localhost") .put("styx.flyte.admin.production.port", "81") .put("styx.flyte.admin.production.insecure", "true"); var config = ConfigFactory.parseMap(configMap.build()); final FlyteRunner flyteRunner = StyxScheduler.createFlyteRunner("production", config, stateManager); assertThat(flyteRunner.isEnabled(), is(true)); }
@Test public void testCreateFlyteRunnerForMissingRunnerIdConfig() { var configMap = ImmutableMap.<String, String>builder() .put("styx.flyte.enabled", "true") .put("styx.flyte.admin.production.host", "localhost") .put("styx.flyte.admin.production.port", "81") .put("styx.flyte.admin.production.insecure", "true"); var config = ConfigFactory.parseMap(configMap.build()); assertThrows( IllegalArgumentException.class, () -> StyxScheduler.createFlyteRunner("staging", config, stateManager) ); }