What lessons to learn from Mount Blanc and diving as software architect

In my previous post about exceeding my limits I have mentioned 2 trips from several I did in 2013. I would like to share lessons I learnt specially for development. You will see that there is not much difference in mistakes in software development as well in mistakes in diving or reaching top of mountains.

Let’s share some problems we have encounter:

During descent from Mount Blanc we (group of 3 people) decided we are not going to be tight together anymore, as it give us more freedom and we don’t have wait on each other. On the way back one of my friend felt over the cliff and by miracle was lucky to not fall down in gulf. We can’t say same about his DLSr camera. We have lost our best pictures from ascent and top of Mount Blanc, anyway my friend is still with us enjoys life like never before.

During my so far most deep dive, we swum almost all time against current and we have spent more air than we thought. On the way up, we had to use  extra safety air bottles we left in case of emergency, because we run out of air in our bottles.

These things I don’t share with everyone usually, because instead of learning lessons from my mistakes it scares them to actually not do anything.

And how it connects with development ?

  • If possible do pair programming and TDD – best exercise can be learnt on coderetreat
  • Never ever in name of “freedom, not enough time, not enough budget,…” write code without tests –  tests are your safety “rope” which holds your code together and can saves you life
  • Always count on unexpected events  (have extra hours, budget, resource hidden which you can pull on when needed) – this is like having extra safety bottles with air in water
  • Did you notice that both situation happened after “reaching  goal”  on the way back ? – Finishing your software and putting into production is our main goal, but be ready to expect the “real” problems when real users starts using it
  • Good preparation is the key for success – be tough on yourself – think about the most worst cases and expect even worse situations

These are just few things – happy new year 2014 and be ready to exceed your limits in next coming year.


Exceeding my limits in 2013 -52m –> 4810m :)

Year 2013 was great year where I had opportunity to exceed my limits above but as well at bottom 🙂

Ascent on Mount Blanc  4810 m

Preparations started about 6months ahead. It was tough, what ever I thought it takes in reality it was at least 2x harder. But it is worth it.

When you get there, you are full emotions – happiness, completely tired, feeling freezing cold and at same time enjoying shining sun on your face.

Your biggest enemy is weather and your physical condition. Here are few tips:

  • you can book bed in cottage no earlier than 30 days before ascent. Booking starts at 7:00am and usually ends at 7:10 am – So many people wants to book at same time.
  • To fight against weather good tip is to book whole week (every day) – when it gets closer, and you have better idea about weather for given days, you start cancelling your bookings
  • To fight against  physical condition, high altitude sickness ,…. – there was one thing I was telling to myself for 2 days. One more step , One more step. It doesn’t matter how long it takes, but you will get there.

 Here are few pictures and video from Mont Blanc

Descent to -52m in ocean

I love to dive. Very soon I figure out that normal diving  is “not enough” for me 🙂  In 2013 I have spent week on safari in Egypt. Everyday up to 4 dives. Last day I asked my friends I wanted to go down, deeper then usual 30m. I have to say, that my friends are technical divers (sometimes they do over -100m dives). So I did -52m in Egypt. 52m is not much, anyway when you so deep it takes you almost half hour to get properly in surface – that’s why maximum for non technical divers is recommended around -20m

 

It was very good year with many good things and few bad things as well, but these 2 shows that you can do always more than you thought. With good preparation you can manage many things, you can overcome fear, achieve more.


first coderetreat in Ostrava

About month ago I decided that we should have session of CodeRetreat also in Ostrava. On December 14th there is Global Code Retreat Day, so I started to look whether we can make it in that short time and what is needed.

I had one condition – I can prepare everything, but I want to be participant during all sessions. So I have asked my friend Daniel Kolman to join us as CodeRetreat Master.

And what are my feelings ? It was great time, spent with great people, doing great things (learning how to code better and learning from others). I would like to point out 2 sessions:

  1. do session, where you can’t talk – basically you write test and hand over your keyboard to your pair body to write code. That was strange to program without communication
  2. write test with implementation inside the test (no object class, just the implementation) -> continue with other test with implementation inside that test. If you start having duplications extrat them into separate method and continue with other tests and when it make sense extrat it into separate class.  => that was really interesting how hard was it for me to stop thinking about classes objects and concentrate only on implementation inside of tests.

Here is quick intro to CodeRetreat: 

  • consists of 6 sessions where you write code for Game of Life and after each session you delete your code and start from scratch again
  • you do always pair programing
  • you concentrate on quality of code and not just to “make it working” – that’s why you delete your code, as it is not important how much you have done, but rather how good you have done it
  • each session concetrate on different tasks  – concetrate on good naming of your method and fields, every method can have maximum of 4 lines, TDD (starts with test which fails and then implementation which confirms that test will pass), pair programing – do ping -pong coding (one write test, mate writes implementation) …. 
  • you have very good options to learn new languages – in our case we had (java, groovy, clojure, scala, php, C#,…) 

here are few pictures from Ostrava CodeRetreat 

Big thanks goes to Daniel Kolman and others who helped us with it.


Jenkins on openshift #3 – building repo from github or bitbucket

Next task I wanted to do is to create jenkins on openshift and be able to build projects from github or bitbucket. It sounds simple, but you will face quite a lot of issues. So let’s do it:

Create Jenkins gear

  • this creates gear called “jenkins” using jenkins-1 application and includes ssh wrapper “git-ssh” which helps you to overcome ssh obstacles (openshift forbids to write into .ssh folder) – as you will see we will have to solve this problem several times later as well

Set jenkins slave

jenkins needs other linux machines (called slaves) to use them for building, anyway we don’t have so much free gears, so we will use jenkins itself for it.

Manage Jenkins -> Configure System -> 
# of executors = 1
Labels = put here anything

Generate ssh key

Add public key (id_rsa.pub) to github & bitbucket

search github/ bitbucket how to do it 🙂

Add new Jenkins Job

  • in begining I mentioned that home folder is not writeable, so we are encountering several problems, like ssh can’t write into .ssh , maven can’t write into .m2 folder and so on. The only solution is to point all applications into writeable folder which is $OPENSHIFT_DATA_DIR
  • Because of the problem above, you can’t use standard maven jobs but you have to use “Build a free-style software project”
  • Source Code Management: git: your git url (i.e. git@bitbucket.org:majecek/testtest.git)
  • Build: (add Execute shell): enter:

  • this creates setings.xml file and when runing maven commands – you have to specify where is the settings file
  • check this site for more info
  • next step is to add hooks in github/bitbucket – so after push in repo they will trigger jenkins to create new build – again check it in github/bitbucke or this site

Feed Sonar with data from Jenkins

This was quite a problem. I have to admit that I didn’t finish it, but found solution. Here is another problem, sonar and specially it’s mysql runs on different gear and openshift by default don’t allow any connection between gears nor from outside.

  • install Sonar plugin into jenkins, add URL & jdbc url and all info needed
  • I had to add into Sonar Aditional properties: -DSONAR_USER_HOME=$OPENSHIFT_DATA_DIR
    • this is again, because sonar can’t write into home directory, so you have to point to writeable folder

Now you will face problem, that jenkins can’t connect to MYSQL DB – as said above, this is because gears can’t communicate to each other. There are 2 solutions:

  • set up SONAR as scaled application – scalled applications can communicate to each other
  • setup ssh port forwarding between applications

You can read more here.


SonarQube part #2 – let’s feed it with some data

In previous article, I have showed you how to build sonarqube 4.0 on openshift , but let’s feed it with some data.

  • Let’s create dummy j2ee project using maven
    • mvn archetype:generate
    • cd <<project_name>>
    • mvn clean compile
  • openshift port forward to access database
    • rhc port-forward <<APPLICATION_NAME>>
    • you should see something like this:
      Service      Local                            OpenShift
      ——- ————–       —-     —————
      java     127.0.0.1:8080 => 127.X.X.X:8080
      mysql 127.0.0.1:3306 => 127.X.X.X:3306
    • database can be accessed on localhost:3306

Now we have few options how to feed sonar

  • maven – best for maven projects
  • sonarqube runner – best for java legacy code
  • jenkins,….

Maven projects

5 things to change or consider:

  1. jdbc url – make sure you have correct url, port, application name
  2. mysql username
  3. mysql password
  4. sonar host url
  5. I am using maven version 3 – in case you have maven version 2 you have set different dependences

to run:

mvn clean compile sonar:sonar 

or (including profile name to be used)

mvn clean compile sonar:sonar -Dsonar.profile="Sun checks"

SonarQube Runner

4 things to change or consider:

  1. jdbc url – make sure you have correct url, port, application name
  2. mysql username
  3. mysql password
  4. sonar host url

to run:

  • you have to download SonarQube runner & set PATH variable
    export SONAR_RUNNER_HOME=/Path/to/SonnarRunner/sonar-runner-2.3
    export PATH=$SONAR_RUNNER_HOME/bin:$PATH
  • create file called “sonar-project.properties” and fill it with info mentioned above in gist
  • run:
    sonar-runner

Now change code (i.e. add empty private method, named with upper case letter, ….) and run analysis again to feed sonar. Check sonar – it shows you all violations and issues in your code, …  (also it depends on plugins you have installed on your sonar)

Example project can be found on Bitbucket


How to run SonarQube 4.0 on openshift

I have managed to run latest SonarQube on openshift for free.

Because openshift has bug you can’t just have one-line command to do all setup for you, but I had to separate it into several commands and two git repos.

Bug

you can’t have .openshift folder in repo – so I have to have 2 git repos

  1. git repo with sonar without (.openshift folder)
  2. git repo with .openshift folder  with start & stop commands

How to get SonarQube 4.0 running on openshift

Description

  1. when RedHat fixes the bug, you should be fine, just with line #1
  2. cd into project
  3. add another git repo which holds .openshift folder with start & stop commands
  4. get changes from repo above
  5. pull from origin repo – git was complaining when I didn’t do pull
  6. push into openshift
  7. wait several minutes until sonar gets running

Thanks

Big thanks goes to Rui Rodrigues(@rodriguesrmb) as he managed to solve port binding problems and update java wrapper with new version