Saturday, September 26, 2015

Migrate from Boot2Docker to Docker Machine on OSX

Just learned that Docker deprecated official support to boot2docker and now official one is Docker Machine (at the time of writing 09/26/2015 is still in beta)

Step 1. is to Download binary from Docker Toolbox

Step 2. Stop boot2docker (boot2docker stop) and make sure to quit virtualBox. It might be a good opportunity to upgrade VirtualBox (make sure VirtualBox version is 4.3.28 or greater) 

Step 3. Run Docker Machine Installer. It will migrate your container etc for you.





Step 4. Once you get to Quick Start (see above) I open it in terminal. The biggest difference between Boot2Docker and Docker Machine is that Docker Machine allow you to create multiple machines so you have to specify which machine you are working on.
When migration is completed, installer will create default machine called "default" so to start the default docker machine, you specify docker machine (see below)


Now you should be able to run your familiar docker command but it didn't for me because I got timeout.... and looks like it is still looking at boot2docker vm which I already shutdown...


I realized that the following entries are in the .bash_profile. so I removed it and reload bash_profile

# docker:
    export DOCKER_CERT_PATH=/Users/naoko/.boot2docker/certs/boot2docker-vm
    export DOCKER_TLS_VERIFY=1
    export DOCKER_HOST=tcp://192.168.59.103:2376
alias docker="docker --tlsverify=false"

and add docker-machine version of it:

eval "$(docker-machine env default)"

reload the .bash_profile and ta-da!





Sunday, November 30, 2014

Python API Load Test in 5 min with Locust - A modern load testing framework

I was looking for simple way to set up load test for my API application (Django with DRF).
I first tried multi-mechanize but I had a few issue installing dependencies such as Matlab and decided that I don't have time for this... and encountered Locust.

With this great example, I had my API Load Test up and running in matter of 5 minutes.

Saturday, April 5, 2014

Writing Unit Test with Jasmine: How to test window.history

Here is how I wrote test to cover my back button directive in AngularJS.

my directive look like this:

app.directive('goBack', function ($window) {
    return {
        template: '<button id="button_goback" title="Go Back to Previous Page" class="btn btn-default" style="">Back</button>',
        restrict: 'E',
        replace: true,
        link: function (scope, element) {
            element.bind('click', function () {
                $window.history.back();
            });
        }
    };
});

and what I want to test is:

- I don't have to test JavaScript library to see if actually url was changed
- I want to make sure when this button is clicked, history.back is called

and here is my test look like:

it('should call history.back when back button is clicked', inject(function () {
        spyOn($window.history, 'back');
        element.find('button').click();
        expect($window.history.back).toHaveBeenCalled();
    }));