domingo, octubre 14, 2012

NoSQLUnit 0.5.0 released


NoSQLUnit is a JUnit extension to make writing unit and high-level tests of systems that use NoSQL as backend easier. Visit official page for more information.

In current release instead of supporting one new engine, I focused on implementing an embedded in-memory Redis engine based on Jedis.  Read in documentation the limitations on current implementation. And of course now NoSQLUnit also supports embedded Redis apart from Managed and Remote, you only have to register EmbeddedRedis rule to use it.
@ClassRule
public static EmbeddedRedis embeddedRedis = newEmbeddedRedisRule().build();
Moreover I have fixed some issues with Managed Cassandra lifecycle.

Also I have extended the support to embedded Neo4j engine by allowing the use of instance defined into Spring context file using spring data namespace. See next example that NoSQLUnit will populate data into instance defined in application context.
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<beans xmlns="http://www.springframework.org/schema/beans"
        xmlns:context="http://www.springframework.org/schema/context"
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xmlns:neo4j="http://www.springframework.org/schema/data/neo4j"
        xsi:schemaLocation="
            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
            http://www.springframework.org/schema/data/neo4j
            http://www.springframework.org/schema/data/neo4j/spring-neo4j-2.0.xsd">

    <context:annotation-config/>
    <neo4j:config storeDirectory="target/config-test"/>

</beans>
And in your test you only have to define SpringEmbeddedNeo4j rule passing the application context object where Neo4j is defined.
@Autowired
private ApplicationContext applicationContext;
...
@ClassRule
SpringEmbeddedNeo4j springEmbeddedGds = newSpringEmbeddedNeo4jRule().beanFactory(applicationContext).build();
And finally in this version of NoSQLUnit, I have implemented that we can use Shard connections provided by Jedis library to populate defined data into different shards. The only thing you should do is changing configuration instance of RedisRule to ShardedRedisConfiguration. See next simple example:
@Rule
public RedisRule redisRule = new RedisRule(newShardedRedisConfiguration()
         .shard(host("127.0.0.1"), port(ManagedRedis.DEFAULT_PORT))
             .password("a")
             .timeout(1000)
             .weight(1000)
         .shard(host("127.0.0.1"), port(ManagedRedis.DEFAULT_PORT + 1))
             .password("b")
             .timeout(3000)
             .weight(3000)
         .build());

And that's all for current version.

Next release 0.6.0 will contain support for HBase. Moreover there are an open poll to vote which engine would you like to see in next releases:


Stay in touch with the project and of course I am opened to any ideas that you think that could make NoSQLUnit better.

We keep learning,
Alex.

Well, these boots are made for walking, and that's just what they'll do, One of these days these boots are gonna walk all over you. (These Boots Are Made For Walkin' - Nancy Sinatra)
Music: http://www.youtube.com/watch?v=SbyAZQ45uww

miércoles, octubre 10, 2012

Installing And Running Hubot, Terminator is Here


In current post we are going to see how to install hubot and make it work over XMPP protocol (using open fire server),  and how can help us during our daily work.

Hubot is a robot which belongs to your chat infrastructure as one more user, which you can talk with him. Hubot can help you automate a lot of tasks, like deploy a site, manage your Pomodoro,   or managing issue system to cite a few of them. Hubot is written in CoffeScript on Node.js, keep in mind that Hubot can be extended with CoffeScript and you can easily extend it.

This post is written using Ubuntu, so if you are using any other OS, you only have to modify the way of how components are installed.

First of all (I assume you have a JVM installed), you must install npm and node.js. For this I have used apt-get.
sudo apt-get install nodejs npm
Next step is installing Hubot dependencies by running next apt-get command.
apt-get install build-essential libssl-dev git-core redis-server libexpat1-dev
Then we need to install CoffeScript. So we can run next command:
npm install -g coffee-script
And finally we are going to install Hubot in /opt directory. Obviously could be any other one.
cd /opt
git clone git://github.com/github/hubot.git && cd hubot
npm install
Hubot is installed, to see if it works simply run from installation directory:
alex@grumpy:/opt/hubot$ ./bin/hubot
and Hubot shell will be started. This shell is really useful for testing purposes but not for production environment.
Hubot> hubot ping
Hubot> PONG
which will produce a Pong message.

Now it is time to install Openfire server so we can communicate with Hubot using XMPP protocol instead of shell. Of course you could choose any other XMPP server, but for now Openfire is used.

To install it, download it from openfire site, and extract it to /opt directory.
tar -xzvf openfire_<version>.tar.gz
mv openfire /opt
Then it is time to configure Openfire server, we are going to use embedded database but of course you can configure an external database such as MySQL or Oracle.

A web-based wizard driven setup and configuration tool is built in Openfire, so let's start Openfire server for the first time and configure typical parameters like administrator username, server name, ...
$OPENFIRE_HOME/bin/openfire start
and access to http://localhost:9090.

Then log in as admin into Openfire and create first two users, developer and hubot. So go to Users/Groups -> Create New User, and fill required information for both users.


Next step is creating a room where all users that want to interact with Hubot will join. So go to Group Chat -> Create New Room and create a new room. In our case we are going to call hubot.


and finally we must disable TLS security, there is an issue between Openfire TLS version and node.js XMPP module so if you are using Openfire, you should disable it.


Next step is checking that developer user has access to hubot chatroom and the account is correctly configured, so we can open our XMPP client (in our case Spark) but should be work with any other one and verify that we can connect.

If you are using Spark, log in with developer account and in Actions menu you will find Join Conference room option. Setthere and choose previously created room (hubot). And now you know you have configured correctly XMPP part.

And now it is time for Hubot. First of all we are going to create a bot called my-bot:
alex@grumpy:/opt/hubot$ ./bin/hubot -c ./my-bot
Then enter into my-bot directory and open package.json and add next dependencies which configure  adapter so Hubot can use XMPP protocol for communication:
"dependencies": {
    "hubot": "2.3.2",
    "hubot-scripts": ">= 2.1.0",
    "optparse": "1.0.3",
    "node-xmpp": "0.3.2",
    "hubot-xmpp": "0.1.0",
    "htmlparser": "1.7.6",
    "soupselect": "0.2.0",
    "underscore": "1.3.3",
    "underscore.string": "2.2.0rc"
  }
Then before starting Hubot, you must install XMPP adapter. Run from hubot directory npm install, and XMPP extension will be installed into hubot.
alex@grumpy:/opt/hubot/my-bot$ npm install
And now we are ready to start using Hubot and Openfire.

We are going to start by adding environment variables to configure XMPP adapter.
export HUBOT_XMPP_USERNAME=hubot@grumpy
export HUBOT_XMPP_PASSWORD=<password>
export HUBOT_XMPP_ROOMS=hubot
Note that username should be accompanied for server name which in my case is grumpy. And finally it is time to start Hubot.
alex@grumpy:/opt/hubot/my-bot$ ./bin/hubot --adapter xmpp
And you will see at Spark your new friend (if you have already add hubot as a friend).


And after you check that we can go to hubot-scripts and download and install the useful ones depending on our environment.

In next video you could see a screencast of Hubot In Action with some scripts that I use.



I wish you have liked Hubot,

We keep learning,
Alex.


A Time For Us, At Last To See, A Life Worthwhile, For You And Me (A Time For Us - Andy Williams)
Music: http://www.youtube.com/watch?v=sRnx-s1TQbU