This repository was archived by the owner on Nov 17, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 6.7k
[MXNET-793] ★ Virtualized testing in CI with QEMU ★ #12094
Merged
Merged
Changes from all commits
Commits
Show all changes
30 commits
Select commit
Hold shift + click to select a range
9d28eb5
virtual testing with qemu
37693bd
Add install procedure
larroy eb6f400
update installation
3c469f9
Refine test run
e020eb4
use direct ssh
5439fc3
update readme
b6fbe31
Fix uneccesary cp
larroy a573533
Minor refinements
larroy 8487306
Refine error conditions in startup
larroy 3b499c7
requirements installed inside QEMU
b503d27
Update base image
larroy 836d258
Fix license
larroy 7b3a3b0
Dockerfile rename fallout
larroy 75c3864
license fixes
larroy 61d2063
refine documentation
larroy 05b089a
license fix
larroy c8d1322
update readme
larroy 2f1da4a
Update qemu base image and refine documentation
41b702e
Address CR comments wrt shebangs.
4024bc4
Address CR comments wrt comments.
e6202ce
adjust vda2 -> vda1
214b557
Disable SMP, bug with newer kernel
37f3b9e
Remove commented out code
larroy 81a4d9b
Fix licenses
larroy 94db7e3
CR comments addressed
larroy 9155aca
increase ram to 4096mb
larroy 21be103
Revert dockerfile renaming
larroy d52adbb
Fix undo rename of dockerfiles
larroy 5252551
Address CR comments
larroy 1bdcfef
CR
larroy File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,44 @@ | ||
| # -*- mode: dockerfile -*- | ||
| # Licensed to the Apache Software Foundation (ASF) under one | ||
| # or more contributor license agreements. See the NOTICE file | ||
| # distributed with this work for additional information | ||
| # regarding copyright ownership. The ASF licenses this file | ||
| # to you 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. | ||
| # | ||
| # Dockerfile to build and run MXNet on Ubuntu 16.04 for CPU | ||
|
|
||
| FROM ubuntu:16.04 | ||
|
|
||
| WORKDIR /work | ||
|
|
||
| RUN apt-get update | ||
| COPY install/ubuntu_python.sh /work/ | ||
| RUN /work/ubuntu_python.sh | ||
|
|
||
| COPY install/ubuntu_arm_qemu.sh /work | ||
| RUN /work/ubuntu_arm_qemu.sh | ||
|
|
||
| COPY install/ubuntu_arm_qemu_bin.sh /work | ||
| RUN /work/ubuntu_arm_qemu_bin.sh | ||
|
|
||
| ARG USER_ID=0 | ||
| ARG GROUP_ID=0 | ||
| COPY install/ubuntu_adduser.sh /work/ | ||
| RUN /work/ubuntu_adduser.sh | ||
|
|
||
| COPY runtime_functions.sh /work/ | ||
| COPY qemu/* /work/ | ||
| COPY qemu/ansible.cfg /etc/ansible/ansible.cfg | ||
|
|
||
| CMD ["./runtime_functions.py","run_ut_py3_qemu"] |
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,36 @@ | ||
| #!/usr/bin/env bash | ||
|
|
||
| # Licensed to the Apache Software Foundation (ASF) under one | ||
| # or more contributor license agreements. See the NOTICE file | ||
| # distributed with this work for additional information | ||
| # regarding copyright ownership. The ASF licenses this file | ||
| # to you 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. | ||
|
|
||
| # build and install are separated so changes to build don't invalidate | ||
| # the whole docker cache for the image | ||
|
|
||
| set -exuo pipefail | ||
|
|
||
| apt-get install -y \ | ||
| cmake \ | ||
| curl \ | ||
| wget \ | ||
| git \ | ||
| qemu \ | ||
| qemu-system-arm \ | ||
| unzip \ | ||
| bzip2 \ | ||
| vim-nox | ||
|
|
||
| pip3 install ansible ipython |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,40 @@ | ||
| #!/usr/bin/env bash | ||
|
|
||
| # Licensed to the Apache Software Foundation (ASF) under one | ||
| # or more contributor license agreements. See the NOTICE file | ||
| # distributed with this work for additional information | ||
| # regarding copyright ownership. The ASF licenses this file | ||
| # to you 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. | ||
|
|
||
| # build and install are separated so changes to build don't invalidate | ||
| # the whole docker cache for the image | ||
|
|
||
| set -exuo pipefail | ||
|
|
||
| # | ||
| # This disk image and kernels for virtual testing with QEMU is generated with some manual OS | ||
| # installation steps with the scripts and documentation found in the ci/qemu/ folder. | ||
| # | ||
| # The image has a base Debian OS and MXNet runtime dependencies installed. | ||
| # The root password is empty and there's a "qemu" user without password. SSH access is enabled as | ||
| # well. | ||
| # | ||
| # See also: ci/qemu/README.md | ||
| # | ||
|
|
||
| REMOTE="https://s3-us-west-2.amazonaws.com/mxnet-ci-prod-slave-data" | ||
| curl -f ${REMOTE}/vda_debian_stretch.qcow2.bz2 | bunzip2 > vda.qcow2 | ||
| curl -f ${REMOTE}/vmlinuz -o vmlinuz | ||
| curl -f ${REMOTE}/initrd.img -o initrd.img | ||
|
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| These are files used in the docker container that runs QEMU |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| # Licensed to the Apache Software Foundation (ASF) under one | ||
| # or more contributor license agreements. See the NOTICE file | ||
| # distributed with this work for additional information | ||
| # regarding copyright ownership. The ASF licenses this file | ||
| # to you 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. | ||
|
|
||
| [defaults] | ||
| host_key_checking = False | ||
| ansible_python_interpreter = /usr/bin/python3 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,48 @@ | ||
| # Licensed to the Apache Software Foundation (ASF) under one | ||
| # or more contributor license agreements. See the NOTICE file | ||
| # distributed with this work for additional information | ||
| # regarding copyright ownership. The ASF licenses this file | ||
| # to you 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. | ||
|
|
||
| --- | ||
| - name: provision QEMU VM | ||
| hosts: all | ||
| gather_facts: no | ||
| become: true | ||
| become_user: root | ||
| tasks: | ||
| - name: Wait until ssh is available | ||
| wait_for_connection: | ||
| delay: 0 | ||
| sleep: 3 | ||
| timeout: 400 | ||
| - command: hostname | ||
| register: h | ||
| - debug: msg="{{ h.stdout }}" | ||
|
|
||
| - name: copy mxnet artifacts | ||
| copy: | ||
| src: "{{ item }}" | ||
| dest: mxnet_dist/ | ||
| with_fileglob: "/work/mxnet/build/*.whl" | ||
|
|
||
| - name: copy runtime_functions.py | ||
| copy: | ||
| src: "/work/runtime_functions.py" | ||
| dest: . | ||
| - file: | ||
| path: runtime_functions.py | ||
| mode: 0755 | ||
|
|
||
|
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,31 @@ | ||
| #!/bin/bash | ||
|
|
||
| # Licensed to the Apache Software Foundation (ASF) under one | ||
| # or more contributor license agreements. See the NOTICE file | ||
| # distributed with this work for additional information | ||
| # regarding copyright ownership. The ASF licenses this file | ||
| # to you 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. | ||
|
|
||
| set -exuo pipefail | ||
|
|
||
| qemu-system-arm -M virt -m 1024 \ | ||
| -kernel vmlinuz \ | ||
| -initrd initrd.img \ | ||
| -append 'root=/dev/vda1' \ | ||
| -drive if=none,file=vda.qcow2,format=qcow2,id=hd \ | ||
| -device virtio-blk-device,drive=hd \ | ||
| -netdev user,id=mynet,hostfwd=tcp::2222-:22 \ | ||
| -device virtio-net-device,netdev=mynet \ | ||
| -nographic \ | ||
| -display none | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,117 @@ | ||
| #!/usr/bin/env python3 | ||
|
|
||
| # Licensed to the Apache Software Foundation (ASF) under one | ||
| # or more contributor license agreements. See the NOTICE file | ||
| # distributed with this work for additional information | ||
| # regarding copyright ownership. The ASF licenses this file | ||
| # to you 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. | ||
|
|
||
| # -*- coding: utf-8 -*- | ||
| """Runtime functions to use in docker / testing""" | ||
|
|
||
| __author__ = 'Pedro Larroy' | ||
| __version__ = '0.1' | ||
|
|
||
| import os | ||
| import sys | ||
| import subprocess | ||
| import argparse | ||
| import logging | ||
| from subprocess import call, check_call, Popen, DEVNULL, PIPE | ||
| import time | ||
| import sys | ||
| import types | ||
| import glob | ||
|
|
||
| def activate_this(base): | ||
| import site | ||
| import os | ||
| import sys | ||
| if sys.platform == 'win32': | ||
| site_packages = os.path.join(base, 'Lib', 'site-packages') | ||
| else: | ||
| site_packages = os.path.join(base, 'lib', 'python%s' % sys.version[:3], 'site-packages') | ||
| prev_sys_path = list(sys.path) | ||
| sys.real_prefix = sys.prefix | ||
| sys.prefix = base | ||
| # Move the added items to the front of the path: | ||
| new_sys_path = [] | ||
| for item in list(sys.path): | ||
| if item not in prev_sys_path: | ||
| new_sys_path.append(item) | ||
| sys.path.remove(item) | ||
| sys.path[:0] = new_sys_path | ||
|
|
||
| def run_ut_py3_qemu(): | ||
| from vmcontrol import VM | ||
| with VM() as vm: | ||
| logging.info("VM provisioning with ansible") | ||
| check_call(["ansible-playbook", "-v", "-u", "qemu", "-i", "localhost:{},".format(vm.ssh_port), "playbook.yml"]) | ||
| logging.info("VM provisioned successfully.") | ||
| logging.info("sync tests") | ||
| check_call(['rsync', '-e', 'ssh -p{}'.format(vm.ssh_port), '-a', 'mxnet/tests', 'qemu@localhost:mxnet']) | ||
| logging.info("execute tests") | ||
| check_call(["ssh", "-o", "ServerAliveInterval=5", "-p{}".format(vm.ssh_port), "qemu@localhost", "./runtime_functions.py", "run_ut_python3_qemu_internal"]) | ||
| logging.info("tests finished, vm shutdown.") | ||
| vm.shutdown() | ||
|
|
||
| def run_ut_python3_qemu_internal(): | ||
| """this runs inside the vm, it's run by the playbook above by ansible""" | ||
| pkg = glob.glob('mxnet_dist/*.whl')[0] | ||
| logging.info("=== NOW Running inside QEMU ===") | ||
| logging.info("PIP Installing %s", pkg) | ||
| check_call(['sudo', 'pip3', 'install', pkg]) | ||
| logging.info("PIP Installing mxnet/tests/requirements.txt") | ||
| check_call(['sudo', 'pip3', 'install', '-r', 'mxnet/tests/requirements.txt']) | ||
| logging.info("Running tests in mxnet/tests/python/unittest/") | ||
| check_call(['nosetests', '--with-timer', '--with-xunit', '--xunit-file', 'nosetests_unittest.xml', '--verbose', 'mxnet/tests/python/unittest/test_ndarray.py:test_ndarray_fluent']) | ||
|
|
||
|
|
||
| def parsed_args(): | ||
| parser = argparse.ArgumentParser(description="""python runtime functions""", epilog="") | ||
| parser.add_argument('command',nargs='*', | ||
| help="Name of the function to run with arguments") | ||
| args = parser.parse_args() | ||
| return (args, parser) | ||
|
|
||
| def script_name() -> str: | ||
| return os.path.split(sys.argv[0])[1] | ||
|
|
||
| def chdir_to_script_directory(): | ||
| # We need to be in the same directory than the script so the commands in the dockerfiles work as | ||
| # expected. But the script can be invoked from a different path | ||
| base = os.path.split(os.path.realpath(__file__))[0] | ||
| os.chdir(base) | ||
|
|
||
| def main(): | ||
| logging.getLogger().setLevel(logging.DEBUG) | ||
| logging.basicConfig(format='{}: %(asctime)-15s %(message)s'.format(script_name())) | ||
| chdir_to_script_directory() | ||
|
|
||
| # Run function with name passed as argument | ||
| (args, parser) = parsed_args() | ||
| logging.info("%s", args.command) | ||
| if args.command: | ||
| fargs = args.command[1:] | ||
| globals()[args.command[0]](*fargs) | ||
| return 0 | ||
| else: | ||
| parser.print_help() | ||
| fnames = [x for x in globals() if type(globals()[x]) is types.FunctionType] | ||
| print('\nAvailable functions: {}'.format(' '.join(fnames))) | ||
| return 1 | ||
|
|
||
| if __name__ == '__main__': | ||
| sys.exit(main()) | ||
|
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.