install multiple versions of GO on the same machine [linux]

This quick tutorial shows how to do install multiple versions of go manually.

I’ll try to prepare a shell script that will do it automatically for you πŸ™‚

  1. download selected GO releases
  2. create directories for specific version of GO
  3. unpack downloaded GO releases
  4. install `go` alternatives
  5. install `godoc` alternatives
  6. install `gofmt` alternatives
  7. configure version of go, godoc & gofmt interactively
  8. alternatively you can configured it in a non-interactive way
  9. set the GOROOT env variable to match the location of selected version of GO
# 1
wget https://storage.googleapis.com/golang/go1.4.2.linux-amd64.tar.gz
wget https://storage.googleapis.com/golang/go1.4.3.linux-amd64.tar.gz
wget https://storage.googleapis.com/golang/go1.5.linux-amd64.tar.gz
wget https://storage.googleapis.com/golang/go1.5.1.linux-amd64.tar.gz

# 2
sudo mkdir -p /usr/local/go/1.4.2/
sudo mkdir -p /usr/local/go/1.4.3/
sudo mkdir -p /usr/local/go/1.5/
sudo mkdir -p /usr/local/go/1.5.1/

# 3
sudo tar -C /usr/local/go/1.4.2/ --strip-components=1 -xzf go1.4.2.linux-amd64.tar.gz
sudo tar -C /usr/local/go/1.4.3/ --strip-components=1 -xzf go1.4.3.linux-amd64.tar.gz
sudo tar -C /usr/local/go/1.5/ --strip-components=1 -xzf go1.5.linux-amd64.tar.gz
sudo tar -C /usr/local/go/1.5.1/ --strip-components=1 -xzf go1.5.1.linux-amd64.tar.gz

# 4
sudo update-alternatives --install /usr/bin/go go /usr/local/go/1.4.2/bin/go 2
sudo update-alternatives --install /usr/bin/go go /usr/local/go/1.4.3/bin/go 3
sudo update-alternatives --install /usr/bin/go go /usr/local/go/1.5/bin/go 4
sudo update-alternatives --install /usr/bin/go go /usr/local/go/1.5.1/bin/go 5

# 5
sudo update-alternatives --install /usr/bin/godoc godoc /usr/local/go/1.4.2/bin/godoc 2
sudo update-alternatives --install /usr/bin/godoc godoc /usr/local/go/1.4.3/bin/godoc 3
sudo update-alternatives --install /usr/bin/godoc godoc /usr/local/go/1.5/bin/godoc 4
sudo update-alternatives --install /usr/bin/godoc godoc /usr/local/go/1.5.1/bin/godoc 5

# 6
sudo update-alternatives --install /usr/bin/gofmt gofmt /usr/local/go/1.4.2/bin/gofmt 2
sudo update-alternatives --install /usr/bin/gofmt gofmt /usr/local/go/1.4.3/bin/gofmt 3
sudo update-alternatives --install /usr/bin/gofmt gofmt /usr/local/go/1.5/bin/gofmt 4
sudo update-alternatives --install /usr/bin/gofmt gofmt /usr/local/go/1.5.1/bin/gofmt 5

# 7 - If you want to configure version of go, godoc & gofmt interactively then use:
sudo update-alternatives --config go
sudo update-alternatives --config godoc
sudo update-alternatives --config gofmt

# 8 - If you want to configure version non-interactively then use:
sudo update-alternatives --set go /usr/local/go/1.4.2/bin/go
sudo update-alternatives --set godoc /usr/local/go/1.4.2/bin/godoc
sudo update-alternatives --set gofmt /usr/local/go/1.4.2/bin/gofmt

sudo update-alternatives --set go /usr/local/go/1.4.3/bin/go
sudo update-alternatives --set godoc /usr/local/go/1.4.3/bin/godoc
sudo update-alternatives --set gofmt /usr/local/go/1.4.3/bin/gofmt

sudo update-alternatives --set go /usr/local/go/1.5/bin/go
sudo update-alternatives --set godoc /usr/local/go/1.5/bin/godoc
sudo update-alternatives --set gofmt /usr/local/go/1.5/bin/gofmt

sudo update-alternatives --set go /usr/local/go/1.5.1/bin/go
sudo update-alternatives --set godoc /usr/local/go/1.5.1/bin/godoc
sudo update-alternatives --set gofmt /usr/local/go/1.5.1/bin/gofmt

# 9 - set GOROOT to your current version of GO
export GOROOT=$(dirname $(dirname $(readlink -f $(which go | cut -d" " -f3))))

Getting the Brightness Control to work on Lenovo ThinkPad with Linux Mint 17 (x64) installed and with Nvidia Quadro K1000M on board

I haven’t had much problems with getting the Brightness Control to work in Mint 16, but after installing v17 I had to struggle much more.

I honestly admit that I don’t know which of the following steps actually did the trick, nevertheless it works now πŸ™‚

OK, I’m currently running Mint 17 x64 on Lenovo W530 with Nvidia Quadro K1000M and with Nvidia 331.38 installed.

Display mode in BIOS is set to “Discrete Mode”.

Here’s a list of things I did:

– I’ve updated the bios to latest available version (G5ET99WW (2.59))

Here’s my tutorial how to upgrade it from a USB pendrive

– Generated a new xorg.conf using “NVIDIA X Server Settings” -> “X Server Display Configuration” -> “Save to X Configuration file”

– Then added “EnableBrightnessControl=1” to the device section in /etc/X11/xorg.conf:

     Section "Device"
         Identifier     "Device0"
         Driver         "nvidia"
         VendorName     "NVIDIA Corporation"
         BoardName      "Quadro K1000M"
         Option         "RegistryDwords" "EnableBrightnessControl=1"
     EndSection

– After rebooting, the only thing I could find in /sys/class/backlight was:

thinkpad_screen

– Then I tried to set the “GRUB_CMDLINE_LINUX_DEFAULT” in /etc/default/grub to:

GRUB_CMDLINE_LINUX_DEFAULT="quiet splash acpi_osi=Linux acpi_backlight=vendor"

or

> GRUB_CMDLINE_LINUX_DEFAULT="quiet splash nox2apic acpi_osi=Linux acpi_backlight=vendor"

but that didn’t work

– Finally I set it to only:

> GRUB_CMDLINE_LINUX_DEFAULT="quiet splash nox2apic"

– and after rebooting Brightness Control buttons (Fn+F8 & F9) started to work
and in the /sys/class/backlight I found acpi_video0 instead of thinkpad_screen

     $ ll /sys/class/backlight
     total 0
     lrwxrwxrwx 1 root root 0 Aug 10 10:14 acpi_video0 -> ../../devices/pci0000:00/0000:00:01.0/0000:01:00.0/backlight/acpi_video0/

I hope this will help someone.
Pls drop some comments if it helped you!

Cheers,
SeΓ±or QA

Create a bootable USB on Linux (Mint, Ububtu) pendrive to upgrade Lenovo ThinkPad W530 BIOS

Recently I had to update the bios of my laptop from a USB pendrive, because I had no CD/DVD drive around.

Cameron Seader’s post http://blog.seader.us/2013/10/lenovo-bios-update-method-for-linux-and.html came very handy, but used an obsolete tool so I updated his instructions a bit to make them work.

1. Get the machine type and model of your laptop
In order to grab this information you can either go to the BIOS or use dmidecode or hwinfo.
In my case it was ThinkPad W530 2438-2KU.

2. Download appropriate bios update iso from Lenovo’s site
I got mine: “g5uj22us.iso” from http://support.lenovo.com/en_US/downloads/detail.page?DocID=DS029170

3. Extract the boot image from the iso
To do it you can use genisoimage, which can be installed using regular:

$ sudo apt-get install genisoimage

or can be downloaded from: http://manpages.ubuntu.com/manpages/lucid/man1/genisoimage.1.html
Once you have this tool, run:

$ geteltorito g5uj22us.iso > biosupdate.img

4. Copy the boot image to the USB pendrive

$ sudo dd if=biosupdate.img of=/dev/usbthumdrive bs=512K

Reboot and boot from USB to run the Flash Utility

Cheers,
SeΓ±or QA

How to unit test Django’s Function Based Views

Let’s assume than the URL pattern to your Function Based View is defined like that:
urls.py

urlpatterns = patterns(
    ...,
    url(r'^$', views.index, name='index'),
    ...
)

and your function based view looks like this:
views.py

@api_view(['GET'])
@permission_classes((AllowAny,))
def index(request):
    data = {
        'field': 'value'
    }
    return Response(data)

Then you can unit test such view by creating a minimal instance
of the HttpRequest and pass it to that view.
I tried to mock to test such view with the Mock library, by with no luck!!!
If case you know how to do it with Mock, then let me know!

def test_index_function_based_view():
    _request = HttpRequest()
    _request.method = 'GET'
    request = Request(_request)
    response = index(request)
    assert response.data['field'] ==  'value'

Run your Selenium driven tests in parallel using TestNG.

Sometime ago I came across this post:
http://rationaleemotions.wordpress.com/2013/07/31/parallel-webdriver-executions-using-testng/
And I thought it’d be good to have it in a repo to save you time setting up your own project.

Basically this example project runs JUnit tests in parallel using TestNG.
Tests are grouped by the browser in which they’re going to be executed (have a look at the TestNG XML Suite files in src/test/resources).
As you might have guessed to drive the browsers we use Selenium WebDriver πŸ™‚
And of course you can run your tests locally or remotely using Selenium GRID.

You can find the repo here: https://github.com/kowalcj0/parallel-selenium-with-testng

And here’s a video showing this project in action πŸ™‚

GEE [Jmeter-ec2] – video tutorials part 2

Hi All,

I just added few more videos showing how to configure your test environment to run your JMeter tests:

  • locally on a Vagrant box
  • using remote machines
  • and on Amazon EC2

04 – create a first test plan, run it using Gee and a vagrant box
Shows how to create a new test plan from a template project. Then how to run it using GEE on our local vagrant box.

05 – configure passwordless ssh access to a linux box
Shows how to configure a passwordless SSH access to a remote Linux box. Such access is required by Gee to run your JMeter tests on a remote machine.

06 – automatically install JMeter with plugins on a remote machine
Shows how to use download-jmeter.sh script to download JMeter and JMeter-plugins automatically on a linux host that will be used by GEE to run your load tests.

07 – run your JMeter test on remote linux hosts
Shows how to configure GEE and remote Linux hosts to run your JMeter tests. This video might come handy when you’d like to run your tests using internal network resources.

08 – run your JMeter test on Amazon EC2
Shows how to configure GEE to run your JMeter tests using Amazon EC2 services.

Configure your Logitech Performance MX Mouse buttons to work with Linux Mint

To make your extra mouse buttons work on Linux Mint (I’ve tested it with v15) follow all the steps listed in this tutorial except the step 4 πŸ™‚

Once you get to step 4, use this key mappings to make the ‘zoom’ and ‘switch between windows’ buttons work as on windows.

vi $HOME/.xbindkeysrc
...

# show all windows: Scale
"xte 'keydown Control_L' 'keydown Alt_L' 'key Down' 'keyup Control_L' 'keyup Alt_L'"
  b:10 + release

# Zooming with Logitech Performance MX mouse
# thx to: http://www.ralf-oechsner.de/opensource/page/logitech_performance_mx
# Press 'zoom' button and scroll up/down to zoom in/out
# then press the 'zoom' button again to exit from the 'zoom' mode
"xte 'keydown Control_L' &"
   b:13
"xte 'keyup Control_L' &"
   Control + b:13

I hope that you’ll like Mint even more from now on πŸ™‚