How to use test_simple_job method in autotest

Best Python code snippet using autotest_python Github


Full Screen

1# Copyright 2019, Inc. or its affiliates. All Rights Reserved.2#3# Licensed under the Apache License, Version 2.0 (the "License").4# You may not use this file except in compliance with the License.5# A copy of the License is located at6#7# or in the "LICENSE.txt" file accompanying this file.10# This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, express or implied.11# See the License for the specific language governing permissions and limitations under the License.12import logging13import pytest14from assertpy import assert_that15from remote_command_executor import RemoteCommandExecutor16from tests.common.schedulers_common import AWSBatchCommands17@pytest.mark.regions(["eu-west-1"])18@pytest.mark.instances(["c5.xlarge", "t2.large"])19@pytest.mark.dimensions("*", "*", "alinux", "awsbatch")20@pytest.mark.usefixtures("region", "os", "instance", "scheduler")21def test_awsbatch(pcluster_config_reader, clusters_factory, test_datadir):22 """23 Test all AWS Batch related features.24 Grouped all tests in a single function so that cluster can be reused for all of them.25 """26 cluster_config = pcluster_config_reader()27 cluster = clusters_factory(cluster_config)28 remote_command_executor = RemoteCommandExecutor(cluster)29 _test_simple_job_submission(remote_command_executor, test_datadir)30 _test_array_submission(remote_command_executor)31 _test_mnp_submission(remote_command_executor, test_datadir)32 _test_job_kill(remote_command_executor)33def _test_simple_job_submission(remote_command_executor, test_datadir):34"Testing inline submission.")35 _test_job_submission(remote_command_executor, "awsbsub --vcpus 2 --memory 256 --timeout 60 sleep 1")36 # FIXME: uncomment once this bug is fixed37 #"Testing inline submission with env.")38 # _test_job_submission(39 # remote_command_executor,40 # 'export TEST=test && awsbsub --vcpus 2 --memory 256 --timeout 60 -e TEST "env | grep TEST=test"',41 # )42"Testing stdin submission with env")43 _test_job_submission(44 remote_command_executor,45 'export TEST=test && echo "env | grep TEST=test" | awsbsub --vcpus 2 --memory 256 --timeout 60 -e TEST',46 )47"Testing command file with env")48 _test_job_submission(49 remote_command_executor,50 "export TEST=test && awsbsub --vcpus 2 --memory 256 --timeout 60 -e TEST -cf",51 [str(test_datadir / "")],52 )53def _test_array_submission(remote_command_executor):54"Testing array submission.")55 _test_job_submission(remote_command_executor, "awsbsub --vcpus 1 --memory 128 -a 4 sleep 1", children_number=4)56def _test_mnp_submission(remote_command_executor, test_datadir):57"Testing MNP submission with MPI job.")58 _test_job_submission(59 remote_command_executor,60 "awsbsub --vcpus 1 --memory 128 -n 4 -cf",61 additional_files=[str(test_datadir / "")],62 children_number=4,63 )64def _test_job_kill(remote_command_executor):65"Testing job kill.")66 awsbatch_commands = AWSBatchCommands(remote_command_executor)67 result = remote_command_executor.run_remote_command("awsbsub --vcpus 2 --memory 256 --timeout 60 sleep 300")68 job_id = awsbatch_commands.assert_job_submitted(result.stdout)69 remote_command_executor.run_remote_command("awsbkill {0}".format(job_id))70 status = awsbatch_commands.wait_job_completed(job_id)71 assert_that(status).contains_only("FAILED")72 result = remote_command_executor.run_remote_command("awsbstat -d {0}".format(job_id))73 assert_that(result.stdout).matches(r"statusReason\s+: Terminated by the user")74def _test_job_submission(remote_command_executor, submit_command, additional_files=None, children_number=0):75 logging.debug("Submitting Batch job")76 awsbatch_commands = AWSBatchCommands(remote_command_executor)77 result = remote_command_executor.run_remote_command(submit_command, additional_files=additional_files)78 job_id = awsbatch_commands.assert_job_submitted(result.stdout)79 logging.debug("Submitted Batch job id: {0}".format(job_id))80 awsbatch_commands.wait_job_completed(job_id)...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:


You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run autotest automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?