layout | title |
---|---|
course |
Ubuntu Virtual Machine for testing assignments |
If you wish, you can run your entire project by submitting it to the test server. This has the appeal of simplicity: All you need on your own computer is your preferred editor and git.
But this approach has the disadvantage of being slow. Every submisison takes time, and you will wind up going through the process many times, only to find out you have a syntax error because you mis-typed a variable name or forgot a closing colon. Or you get a runtime error because you mispelled the method for one of the library classes.
It will be a lot faster to run short, initial tests on your own machine, clean out the dumb errors, and only then submit to the test server to see how well your code performs.
To run tests, on your own machine, you'll need to install on your machine the full software stack that runs on the test server. That can take a lot of time, is specific to your operating system, and is generally annoying. But if you already have all or most of the tools installed, it could be a good approach.
The final approach is to download and use this virtual machine, containing Ubuntu 13.10 Server and all the necessary packages. This approach will require at least 1GB free space on your disk. You still have to do a bit of installation (to install VirtualBox), followed by some configuration, but it's generally less work than building the entire stack yourself. Once you have the VM installed, you development cycle becomes:
- Edit your program using your standard editor on your regular operating system.
- Test it by running it under our stack on the virtual machine.
- Once it works,
git push submit master
from your regular operating system, to run your code on the test server.
If you decide to use the virtual machine, here's how to set it up.
-
Download and install Oracle VirtualBox. There are versions for the popular operating systems.
-
Download the virtual machine Note that the
ubuntu-13.10-3GB-disk.ova
file is 430 MB long---you might schedule the download at a time when the network is less congested, such as the morning. -
Import the virtual machine file
ubuntu-13.10-3GB-disk.ova
into Virtual Box. Use theFile/Import Appliance...
menu entry. Accept all the default settings. -
Start the virtual machine (green arrow button) and sign on. Your userid and password are both 'ubuntu'.
-
Set your git id and email:
git config --global user.name YOURNAME
git config --global user.email YOUREMAIL
replacing YOURNAME
and YOUREMAIL
with your name and email as single-quoted strings (i.e., 'Hao Ramayanan'
, and '[email protected]'
).
- Shutdown the machine (menu entry
Machine/ACPI Shutdown
---you will probably want to learn the hotkey for this action).
Sharing a directory between your host OS and the guest OS in the virtual machine (repeat for every assignment)
For each assignment, you will want to share the directory containing your code on the host machine with a directory in the guest Ubuntu OS in the virtual machine.
Assume that you have cloned the boilerplate repository for your current assignment into directory assign
and are editing code there.
- Select the virtual machine from the list in VirtualBox.
- Press the "Settings" button (orange gear).
- Select the "Shared Folders" tab on the far right top.
- Press the "Add" button (folder with '+' sign on right).
- Navigate the "Folder Path" to the directory containing your assignment (
assign
in our example) and select that directory. - Check the "Auto-mount" box. The directory should appear in the "Machine Folders" list, with "Auto-mount" as "Yes" and "Access" as "Full".
- Press "OK".
- Start the machine and sign in.
Your assignment directory will be /media/sf_NAME
, where NAME
is your
assignment (/media/sf_assign
in our example). You can edit files in your
host operating system using your favourite editor, save them, and those updated files will
be visible to the guest Ubuntu system, where you can run your tests.
{% comment %}
The base install was Ubuntu 13.10.
And this:
sudo su -c "echo 'ubuntu ALL=(ALL) NOPASSWD:ALL' >> /etc/sudoers"
Also:
sudo sh -c "echo 'manual' > /etc/init/ssh.override"
{% endcomment %}