Tuesday 13 December 2011

How many times have you had problems trying to make your bamboo plans prepared to run in different environments, i.e.: prod, testing, dev?

In the following example, I have a small web application that uses spring where I inject the url of the external service I want to use into a java class. I have a different url for different environments. Now I want to pass the environment I want to pass al the way from bamboo2 to java and spring. So from bamboo I will be able to define a plan for every environment so that I will be able to test every environment, deploy to every environment and so on.
I am assuming you have a good knowledge about spring, bamboo, maven and unit testing in general and the only thing you do not know is how to make it more generic.

Properties file:

configuration-local.properties:
app.url=http://localhost:8080/app

configuration-testing.properties:
app.url=http://testing:8080/app

configuration-production.properties:
app.url=http://production:8080/app
So we have a file for each configuration.

Spring config file:

applicationContext.xml:
<beans 
xmlns:context="http://www.springframework.org/schema/context" 
xmlns:mvc="http://www.springframework.org/schema/mvc" 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
xmlns="http://www.springframework.org/schema/beans" 
xsi:schemalocation="http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd
              http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
              http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd">

 <bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer" id="propertyConfigurer">
  <property name="systemPropertiesModeName" value="SYSTEM_PROPERTIES_MODE_OVERRIDE">
  <property name="location" value="classpath:configuration-${env}.properties">
 </property></property></bean> 

 <bean class="com.miguel.app.App" id="app">  
  <property name="url" value="${app.url}">
 </property></bean>
</beans>

Maven

Configure surefire plugin:
   <plugin>
    <artifactid>maven-surefire-plugin</artifactid>
    <configuration>
     <environmentvariables>
      <env>${env}</env>
     </environmentvariables>
     <systemproperties>
        <property>
            <name>env</name>
            <value>${env}</value>
        </property>
     </systemproperties>
    </configuration>
   </plugin>

Bamboo:

In the plan go to configure job
set the goal:
test -Denv=dev

Thursday 24 November 2011

If hosts file does not seem to work in your browser

Given a host file with the following content:

10.100.12.10 yourhost.co.uk

If your hosts file does not seem to work with yourhost.co.uk when you load that url in firefox, internet explorer, chrome and/ or safari and you get a message like this:

Network Error (dns_unresolved_hostname) 

 
Your requested host "yourhost.co.uk" could not be resolved by DNS.  
 

For assistance, contact your network support team.  

but ping can resolve the ip address,

Pinging yourhost.co.uk [10.100.12.10] with 32 bytes of data:
Reply from 10.100.12.10: bytes=32 time<1ms TTL=64
Reply from 10.100.12.10: bytes=32 time<1ms TTL=64
Reply from 10.100.12.10: bytes=32 time<1ms TTL=64
Reply from 10.100.12.10: bytes=32 time<1ms TTL=64

Ping statistics for 10.100.12.10:
    Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
    Minimum = 0ms, Maximum = 0ms, Average = 0ms

Try to go to your internet explorer, then "internet options", then click "connections" tab, then click "LAN settings" button. Although you are accessing this internet options through explorer, it affects the other browser as well. Please untick "Automatically detect settings", at least the fixed my problem, it may fix yours.

Friday 15 April 2011

Agile development vs development by contract

Don't get me wrong, I really enjoy working in an agile process but I am not totally sure that is fine for any situation...

What about when you are a company that creates custom-built software, you have a client and asks you for a budget to do application X? How do you give a quote? To give a figure, you need to agree on same requirements and depending on the implementation it will cost you more or less. If you want to give a realistic figure, you will need to think about the architecture, the technologies you are going to use.

Don't tell me that you have to trust, because that is not going to happen. This is real world. The client needs a guarantee, a figure and you need to limit what are planning to deliver with that figure: the list of requirements.

Basically I am talking about a pre-negotiation, a negotiation that should lead to a very detailed document, analysis, design and so on. Later on, you can be the most agile person or team in the world but this first step contradicts agile totally. You can even make your client to get involved and change the spec, attend the demos, etc but the first step is like the original sin, so you can't be truly agile.

Of course, after a while, your client may trust you and probably you can implement this agile approach from the scratch.

When somebody says why the waterfall process has lasted so much, my only answer probably is that at the beginning probably most companies did custom-built software, so they had all the requirements very clear at the beginning, so doing a design and then implement, was just natural. As nowadays many companies have the software development department inside, people are starting realizing that in this case, we can use a more agile approach.

Thursday 24 March 2011

Changing my mind a bit about Apple

I have been in love with Apple products for a while. I have not bought everything from them though. Just a Mac Book Pro almost two years ago. However I have been thinking about buying an iPhone and an iPad for a while. I was thinking about doing that this year but recently I have started to change my mind about Apple:
-Firstly I realize that most of the software I use is on the web, email, google apps, reader, facebook, twitter.
-Then, I am really tired about Safari, it used to work fine but nowadays it is very slow and it keeps waiting for a long time many times and collopsing from time to time.
-I am also quite tired of iPhoto and how difficult is to make it importing your well organized in directories collection of pictures.
-I have discovered that Chrome uses much less memory and it is always responsive.
-Also Picasa for Mac works fine and it respects my hierarchy of folders and is perfectly integrated into picasa web albums.
-I have even left iTunes, who needs to have all mp3 on the hardrive, when you have spotify? Probably the same people who has a mp3 player but I have not. So keeping my huge collection of mp3 in the hard drive does not make sense for me.
-Also Apple is still behaving specially, like not having features that everybody has, creating a close environment, strange rules for the app market, etc.
-Windows 7 works allright at last.
-Android probably is more complicated than iPhone, but it is open, more options and come on I am supposed to be a geek not my grandma, I should love all that freedom.

So basically I am not using anything apple specific. Yes probably the hardware is better quality and mac os x works allright and has a unix core but I am more dependent on Google enviroment.

For all the points before, I am really considering buying an Android instead of an iPhone, I still think iPad is better than other tablets but I think kindle is really good for what it tries to do and I will reconsider Windows for my next laptop if I buy one.

Tuesday 22 February 2011

I have detected a trend: The test developer

I think in the near term more and more companies will be looking for test developers. A test developer is a mix between a tester and developer. Basically is a tester but able to create programs to test the application in an automated way. Before the automated testing was reserved to programmer for unit testing and integration testing, nowadays with the consolidation of selenium, cucumber, soap-ui, jmeter, you can test in an automated way the application end-to-end or close to it.

Wednesday 16 February 2011

Technical words on fashion in 2011

Cloud, grid, grid services, java7, selenium, tdd, bdd, agile, automated testing, scala, functional languages, nosql, online apps, android, mobile applications, concurrent programming.