/** * Verifies that the indicated deploy step has the expected status. */ public static Expect deployStepStatus(String phaseName, String stepName, Status expectedStatus) { return stepStatus(Constants.DEPLOY_PLAN_NAME, phaseName, stepName, expectedStatus); }
/** * Configures the test with custom options as would be provided via an {@code options.json} file. If this is not * invoked then the service defaults from {@code config.json} are used for the test. * * @param optionKeyVals an even number of strings which will be unpacked as (key, value, key, value, ...), where the * keys should be in {@code section1.section2.section3.name} form as an {@code options.json} file would have * @return {@code this} */ public ServiceTestRunner setOptions(String... optionKeyVals) { return setOptions(toMap(optionKeyVals)); }
/** * Verifies that a pod was launched with exactly the provided task names in the last accept call. */ public static Expect launchedTasks(Collection<String> taskNames) { return launchedTasks(1, taskNames); }
public CassandraRecoveryPlanOverriderTest() throws Exception { ServiceTestResult result = new ServiceTestRunner() .setPodEnv("node", "LOCAL_SEEDS", "foo,bar") .run(); rawSpec = result.getRawServiceSpec(); serviceSpec = result.getServiceSpec(); }
private ServiceTestRunner getDefaultRunner() throws Exception { // Our Main.java only defines SERVICE_ZK_ROOT in our name nodes. // However, the test utilities are strict about missing template params so we set something for all pods: return new ServiceTestRunner() .setPodEnv("journal", "SERVICE_ZK_ROOT", "") .setPodEnv("data", "SERVICE_ZK_ROOT", "") .setPodEnv("name", "SERVICE_ZK_ROOT", "/path/to/zk"); } }
/** * Configures the test with additional environment variables in the specified Pod, beyond those which would be * included by the Scheduler or by Mesos. This may be useful for services whose tasks configure environment * variables before rendering config files via execution of {@code bootstrap}. * * @param podType the pod to set the environment against * @param podEnvKeyVals an even number of strings which will be unpacked as (key, value, key, value, ...) * @return {@code this} */ public ServiceTestRunner setPodEnv(String podType, String... podEnvKeyVals) { return setPodEnv(podType, toMap(podEnvKeyVals)); }
/** * Configures the test with the provided state from a prior run. This may be used to initialize a second simulation * with the state of a first simulation. Otherwise the simulation will be performed with empty state, simulating * an initial install. * * @param serviceTestResult the result from a previous simulation, from which state will be retrieved * @return {@code this} */ public ServiceTestRunner setState(ServiceTestResult serviceTestResult) { this.persister = serviceTestResult.getPersister(); this.oldClusterState = serviceTestResult.getClusterState(); return this; }
/** * Returns the last task id for a task of the specified name. * * @param taskName the task name to be found * @return the task id * @throws IllegalStateException if no such task was found */ public Protos.TaskID getTaskId(String taskName) { return getLastLaunchedTask(taskName).getTask().getTaskId(); } }
/** * Configures the test with custom template parameters to be applied against the Universe packaging, as would be * provided via {@code TEMPLATE_X} envvars when building the service. These are applied onto {@code config.json} * and {@code resource.json} for the test * * @param paramKeyVals an even number of strings which will be unpacked as (key, value, key, value, ...) * @return {@code this} */ public ServiceTestRunner setBuildTemplateParams(String... paramKeyVals) { return setBuildTemplateParams(toMap(paramKeyVals)); }
/** * Configures the test with additional environment variables in the Scheduler beyond those which would be included * by the service's {@code marathon.json.mustache}. This may be useful for tests against custom Service * Specification YAML files which reference envvars that aren't also present in the packaging's Marathon definition. * These values will override any produced by the service's packaging. * * @param schedulerEnvKeyVals an even number of strings which will be unpacked as (key, value, key, value, ...) * @return {@code this} */ public ServiceTestRunner setSchedulerEnv(String... schedulerEnvKeyVals) { setSchedulerEnv(toMap(schedulerEnvKeyVals)); return this; }
/** * Creates a new instance against the provided Service Specification YAML filename within the service's * {@code src/main/dist} directory. * * <p>WARNING: If you do not invoke the {@link #run()} method, your test will not run! * * @param specDistFilename path to the Service Specification YAML file, relative to the {@code src/main/dist} * directory */ public ServiceTestRunner(String specDistFilename) { this(getDistFile(specDistFilename)); }
public static void allowRackChanges( ConfigValidator<ServiceSpec> configValidator, ServiceTestRunner testRunner, String placementEnvKey) throws Exception { validateZoneTransition( configValidator, testRunner, placementEnvKey, MAX_PER_ZONE_RULE, GROUP_BY_ZONE_RULE, true); }
/** * Verifies that the recovery plan has the expected total number of steps. */ public static Expect recoveryStepCount(int expectedStepCount) { return stepCount(Constants.RECOVERY_PLAN_NAME, expectedStepCount); }
public Send build() { return new SendTaskStatus(this); } }
public SendOffer build() { return new SendOffer(podType, podToReuse, hostname, count); }
public static ClusterState create(ServiceSpec serviceSpec, AbstractScheduler scheduler) { return new ClusterState(serviceSpec, scheduler); }
public static void rejectRackEnablement( ConfigValidator<ServiceSpec> configValidator, ServiceTestRunner testRunner, String placementEnvKey) throws Exception { validateZoneTransition( configValidator, testRunner, placementEnvKey, HOST_RULE, GROUP_BY_ZONE_RULE, false); }
/** * Verifies that the indicated recovery step has the expected status. */ public static Expect recoveryStepStatus(String phaseName, String stepName, Status expectedStatus) { return stepStatus(Constants.RECOVERY_PLAN_NAME, phaseName, stepName, expectedStatus); }
/** * Verifies that the deploy plan has the expected total number of steps. */ public static Expect deployStepCount(int expectedStepCount) { return stepCount(Constants.DEPLOY_PLAN_NAME, expectedStepCount); }
public static void rejectRackDisablement( ConfigValidator<ServiceSpec> configValidator, ServiceTestRunner testRunner, String placementEnvKey) throws Exception { validateZoneTransition( configValidator, testRunner, placementEnvKey, GROUP_BY_ZONE_RULE, HOST_RULE, false); } }