| # |
| # 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 = SequentialTask( |
| name = 'http_example', |
| resources = Resources(cpu=0.4, ram=34*MB, disk=64*MB, gpu='{{profile.gpu}}'), |
| processes = [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=3) |
| update_config_watch_secs = UpdateConfig(watch_secs=10, batch_size=3) |
| health_check_config = HealthCheckConfig(initial_interval_secs=5, interval_secs=2, min_consecutive_successes=15) |
| shell_health_check_config = HealthCheckConfig( |
| health_checker = HealthCheckerConfig( |
| shell = ShellHealthChecker(shell_command='stat /usr/local/bin/run-server.sh')), |
| initial_interval_secs=5, |
| interval_secs=2, |
| min_consecutive_successes=15 |
| ) |
| |
| job = Service( |
| cluster = 'devcluster', |
| instances = 3, |
| 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_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, |
| health_check_config=shell_health_check_config |
| ).bind(profile=DefaultProfile()), |
| job( |
| name = 'http_example_unified_docker', |
| container = Mesos(image=DockerImage(name='http_example_netcat', tag='latest')), |
| task = no_python_task, |
| health_check_config=shell_health_check_config |
| ).bind(profile=DefaultProfile()) |
| ] |