blob: b9bf6f806b6cd9641c58b1b77b2f8264d199b220 [file] [log] [blame]
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
import getpass
class DefaultProfile(Struct):
role=Default(String, getpass.getuser())
cmd=Default(String, 'cp /vagrant/src/test/sh/org/apache/aurora/e2e/http_example.py .')
gpu=Default(Integer, 0)
ContainerProfile = DefaultProfile(
cmd = 'cp /tmp/http_example.py .'
)
GpuProfile = DefaultProfile(
gpu=1
)
run_server = Process(
name = 'run_server',
cmdline = 'python http_example.py {{thermos.ports[http]}} {{thermos.ports[health]}}'
)
stage_server = Process(
name = 'stage_server',
cmdline = '{{profile.cmd}}'
)
test_task = Task(
name = 'http_example',
resources = Resources(cpu=0.5, ram=32*MB, disk=64*MB, gpu='{{profile.gpu}}'),
processes = [stage_server, run_server],
constraints = order(stage_server, run_server)
)
no_python_task = Task(
name = 'http_example_no_python',
resources = Resources(cpu=0.4, ram=32*MB, disk=64*MB),
processes = [Process(name='run_server', cmdline='run-server.sh {{thermos.ports[http]}}')])
update_config = UpdateConfig(watch_secs=0, batch_size=2)
update_config_watch_secs = UpdateConfig(watch_secs=10, batch_size=2)
update_config_var_batch = UpdateConfig(update_strategy = VariableBatchUpdateStrategy(batch_sizes = [1,2]))
# "I am going to fail" config.
shell_config = ShellHealthChecker(
# This shell validates two things:
# 1. the shell command is not run as a privileged user
# 2. a failed shell command results in a health check failure
shell_command='rm -f /etc/passwd'
)
health_check_config = HealthCheckConfig(
health_checker=HealthCheckerConfig(shell=shell_config),
initial_interval_secs=5,
interval_secs=1,
min_consecutive_successes=5
)
job = Service(
cluster = 'devcluster',
instances = 2,
update_config = update_config,
health_check_config = health_check_config,
task = test_task,
role = '{{profile.role}}',
environment = 'test',
contact = '{{profile.role}}@localhost',
announce = Announcer(),
)
jobs = [
job(
name = 'http_example'
).bind(profile=DefaultProfile()),
job(
name = 'http_example_watch_secs',
update_config = update_config_watch_secs
).bind(profile=DefaultProfile()),
job(
name = 'http_example_var_batch_update',
update_config = update_config_watch_secs
).bind(profile=DefaultProfile()),
job(
name = 'http_example_revocable',
tier = 'revocable'
).bind(profile=DefaultProfile()),
job(
name = 'http_example_docker',
container = Docker(image='{{docker.image[http_example][latest]}}'),
).bind(profile=ContainerProfile),
job(
name = 'http_example_gpu'
).bind(profile=GpuProfile),
job(
name = 'http_example_unified_appc',
container = Mesos(image=AppcImage(name='http_example_netcat', image_id='{{appc_image_id}}')),
task = no_python_task
).bind(profile=DefaultProfile()),
job(
name = 'http_example_unified_docker',
container = Mesos(image=DockerImage(name='http_example_netcat', tag='latest')),
task = no_python_task
).bind(profile=DefaultProfile())
]