Thursday, 3 December 2015

Bamboo and Python Unit Tests

Recently I have been moving to Bamboo and integrating all the sweet features that it has available. Using it has been a bit of mare to do some things - (Bamboo and Squish for GUI testing) I'll detail that in another post, and bamboo's design and use is completely different to Jenkins.

I think Bamboo's plan, task and job approach is very top down, as opposed to Jenkins which is quite bottom up.

However one of the easier things to get done was getting the build to fail on the output of units tests created using the standard library in python. Then getting the failures to appear once the build has been completed in the build results.

An example:

Create a new repository with a test folder with a test_test.py file containing the below


def test_failure():
    assert False
def test_pass():
    assert True

This created a very simple unit test case to check in bamboo. One pass and one fail. Simple right...

So create a new plan that has a single job with tasks to
a. clone the repository
b. run the tests, remembering to pipe the output into a junit xml output to the test report folder:

py.test --junitxml=test-reports\results.xml
exit 0

the exit 0 is important on windows because if you don't do this the bamboo job can fail from a failure to run the tests at this point and does not parse the results of the tests for display in the bamboo GUI. This is not what you want to occur because if the tests fail to run you still want the tests that you have run to give you information from the results screen.

Then use a junit parser task (built into bamboo from the word go) to process the results:




BAM (boo)
job done.

Unit test in bamboo, detecting a unit test fail and showing details about the test and number of builds it has been failing for. In all this is a really useful feature of bamboo that can be configured out of the box pretty much,

Friday, 2 October 2015

Creating PyVisa Wheel install on Windows

So I have some legacy software that requires PyVisa 1.3 and I'm building wheels for all the packages that require this as this is the new standard for python packaging.

I was having issues creating the wheel file or even installing from the tar file from PyPi until I came across this bug report and it worked a treat.

To sum up all the actions that I needed to do.

1. Get the Tar file.
2. Extract the source.
3. make the following changes

setup.cfg:
-prefix = /usr 
In 'setup.py' home_dir can be derived in a platform independent fashion:
setup.py:
- home_dir = os.environ['HOME']
+ home_dir = os.path.expanduser('~')

4. Navigate to the root of the source and make the wheel file

python setup.py bdist_wheel

Viola you have a windows wheel file that can be installed fast and effective to all virtual environments.

The newer versions are much easier to package into wheel files. I will be sure to post up about other packages that I have any issues with and the solutions to them as well.

Thursday, 27 August 2015

Reserved Filenames on Windows

So today I was working on a full Atlassian product suite, you know Stash, Bamboo, JIRA. And we had a well known code base (the Linux kernel itself) that we are compiling on our Linux build agent.

However one of the development platforms is Window 7 (yes Windows 7 doesn't develop the Linux kernel but this is a test of the product suite and not windows 7 ability to compile the Linux kernel). So I'm cloning the Linux Kernel from Stash to Window 7 and it fails half way through and I'm thinking "Oh no Stash and Git must be configured incorrectly."

Once inspecting the git errors however it was complaining of

fatal: git rm: 'drivers/gpu/drm/nouveau/nvkm/subdev/i2c/aux.c': Permission denied

Obviously this had me trying again and then trying to create a file called aux.c on the desktop.

Queue a most random error from a file creation I have seen



The error was "specific device name is invalid" when creating the file aux.c on the desktop. Now as you can tell this got my interest and so off to google and windows and aux.c.

This lead me to an interesting little knowledge base article

https://support.microsoft.com/en-gb/kb/74496

where it details that some filenames on windows are reserved for certain things.

  Name    Function
   ----    --------
   CON     Keyboard and display
   PRN     System list device, usually a parallel port
   AUX     Auxiliary device, usually a serial port
   CLOCK$  System real-time clock
   NUL     Bit-bucket device
   A:-Z:   Drive letters
   COM1    First serial communications port
   LPT1    First parallel printer port
   LPT2    Second parallel printer port
   LPT3    Third parallel printer port
   COM2    Second serial communications port
   COM3    Third serial communications port
   COM4    Fourth serial communications port

Has anyone ever come across this before, it such an oddity of Windows to do this.....