Search Here

Sunday, December 21, 2014

The concept of Software "Build Announcement"

Preface: 

I originally wrote this article in http://www.cmcrossroads.com/ during June 2009. But now, I found that this article is missing from the http://www.cmcrossroads.com/ and I try to trace it.

I also found that my original article was referred by  computer science department of Rochester Institute of Technology, NY.

Since the concept discussed in the article is still relevant, I thought to restore my article to my own blog (this one) with minor updates. I used Way Back Machine, to trace the original article source and I found it HERE.

I will also try to notify R.I.T CS department so that they may update the web link.

Lets continue to the article ...

The concept of Software "Build Announcement" 


This is a new era in Software Build and Release management. Continuous integration brings more frequent software builds. More frequent software builds means more frequent updates for testers, developers, and other stakeholders. This brings out new use cases / user stories:




  1. As a Test/Validation engineer, I want to know, is the "Product Build output" valid to take forward for testing. 

  2. As a Developer, I want to know, did the product build go through without any compilation issues? Was the Integration done correctly? 

  3. As a stakeholder (Product owner, Program manager), I want to know, what is the status of product build?
Many build management tools (e.g. Jenkins) provide the methods for notifying task completion via e-mails and they also provide a dashboard that shows task status. But "All green" status does not always mean that the product build is "good" and can be promoted to the testing phase.

This article is about creating effective Software "Build Announcements". 

Let's understand the user stories / use cases,



What does SW validation / test engineer want to know?

Typically, a Software testing environment is a controlled (separate) environment from the production Software Build environment. So when the product needs to be tested, Tester / validation engineer will promote the product to the testing environment (which may be in a different subnet, with different firewall settings etc..) and the Software product needs to be installed in right environment with all its dependencies (older versions may need to uninstalled before installing latest build) and then, finally, it is ready for testing or validation.

Clearly the above steps involve efforts (which may raise questions), What if installer itself is broken? What if the one component failed to compile? What if the application is not starting at all?, Test engineer will find out anyway but then it is too late. The testing environment needs to be rolled back (Uninstall the latest build and install the previous build) in order to continue with the testing.

What does the Software developer want to know?

Software developers want to know that, the software build went through without compilation issues and components are integrated properly. Just parsing (e.g. looking at error patterns) compiler logs is not good enough because software products usually depend on many run time binaries and integration issues will be found only while using (testing) the software product.

Software developers depend upon the testing team to know the major integration issues or they themselves need to do the minimal testing (Sanity testing) to ensure that the software build is properly integrated.

What do all the stakeholders want to know?

Stakeholders (e.g. Product owners, program managers etc...) want to know the status of the product build in a rather "Boolean" way (Pass or Fail) because the build management tool's dashboard will not show the clear status. For example, compilation task may show green but the run time component integration may fail.

What about automated task completion notification?

Build management tools supports automated task notification mails. It just notifies us that a particular build / task has been completed. It is also for a particular task not for a complete product build.

The level of continuous integration differs from product to product. Less "weighty" products may build the whole product (including packaging) every time the source code changes. Heavy weight products (which can takes 6 to 14 hrs to build the complete product package) still depends on nightly builds for full build and it might build a few components for every source code change.

Either way, once the complete build is over, it is available for testing and then someone/something needs to ensure the quality of build.

So how do we satisfy all the above requirements? How do we make sure that everyone (Test Engineer, Developer and Stakeholders) gets the required information. 

Software Build Announcement

Here we need the process of "Software Build Announcement". This is the mail notification that contains the "Boolean" result of build status (Pass/Fail).

How do we assess that the build has passed/failed? - It should be based on the "Quality Gate", You can name it as a BAT (Build Acceptance Test) or Sanity Test quality gate.

I prefer the "Sanity test" because it verifies the overall sanity of product which involves some part of functionality testing.

Sanity Testing

"Sanity Test" quality gate should involve the mandatory test cases which will help to ensure the build's status.

For example, A software product can have the following test cases to ensure the product is ready to take forward to testing,

1.    Compiler logs - Should not have compiler issues
2.    Packaging logs - Should not have packaging issues
3.    Product installation - Product should install with out issues
4.    Product invocation - Product should come up without crash
5.    Product de installation - Product should un install with out issue

Hey, Wait!  Many test cases also involve testing functions, Should I test the product build before announce the build?

Yes!, Here comes the Joy of Automation. Automate your Sanity test cases and Build announcement.


Sanity Test Automation

In Nokia, (I was working in Nokia SW division in 2009, Now working in NXP Semiconductors, Automotive SW Division) We have automated both sanity testing and Build announcements. Sanity test frame work architecture looks like this,

As the architecture diagram explains, Once the product build is completed, the Build server invokes the Sanity test cases via the Sanity test framework and the build will be tested  for sanity.

If all the mandatory test cases are passed, the build will be shared in a production build share area and the build will be announced as a "successful" build via Email - else the build will be shared in a temp build share and it will be announced as "failure" build via Email.

A minimal sanity testing helps here to announce the builds.


Here is our success build announcement format,


Here is our success build announcement format,

Sub: Build Announcement: Sprint_<Sprint No>_<Product_Name> -- build <Build Number>

<Product> Sanity Test Report
 -----------------------------------
     1. Download_Build: PASS * 
     2. Unzip: PASS * 
     3. Test_compile_log: PASS *
             No.of Compilation Warnings: 42636
 
     4. Test_CMworkarea_log: FAIL
             No.of Explicit Conflicts: 2
 
     5. Test_Install: PASS * 
     6. Test_Invokation: PASS * 
     7. Test_Deinstall: PASS * 
     8. Cleanup_Build: PASS 

           Passed : 7
           Failed : 1
           Total  : 8

 Product used for this test :  <product>.zip

 Note: * indicates mandatory TestCase.

          Build PASSED Sanity Test.

 Build Location: \\<share_name>\<Build_Share_Dir>


 Build Report: \\<share_name>\<Build_Share_Dir>\Build_Report.html


 Build Log Location: \\<share_name>\<Build_Share_Dir>\Build_Log


 Sanity Test Log Location: \\<share_name>\<Build_Share_Dir>\<product>.log

 *** AUTO GENERATED MAIL - Pls do not Reply***
 
 SDK Sanity Test Automation


The above test cases help us to determine the success or failure build.

How Software "Build Announcement" is useful?

Since the Build announcement and sanity testing is automated, it will happen over the night and everyone gets the build announcement before step in to office.

For Test Enginner: Successful Build Announcement makes sure that latest build can be taken forward for testing. So they can take it into test machines without worrying about the roll back and efforts spend to move to latest builds will not go waste.

For Developer: The test cases include analyzing log files and invoking the product. If both are fine, we can make sure that Compilation & Integration is successful. Developer will get to know the Integration status without waiting for testing results.

For Stakeholder: Build announcement is a Boolean type. It says, build is Successful or Failed. No need to look in to the dashboard and interpret multiple build job's status. It also helps to collects the metrics, for example how many broken builds in this particular sprint (in scrum).


Conclusion

Build announcement with a sanity test quality gate tests the builds even before it is announced (released) for consumption. It will improve quality because it finds issues as  early as possible. It is not just analyzing the compiler log files but it actually tests the product and it will be helpful to find out integration issues.

More test cases can be added for improving the build success confidence level. Since the test cases are automated, it avoids the human errors and improves the quality.

Build Announcements helps to reduce the engineering effort and improve quality!

Sunday, December 14, 2014

Get Hands Dirty with NoSQL + Cloud Data Storage - Part2 - Programming in NoSQL

Hello Readers,

Last week, I was talking about NoSQL Cloud Data Storage, MongoDB in the "Get Hands Dirty with NoSQL + Cloud Data Storage" post. (it shows the details about how to create a free 512MB, MongoDB NoSQL database in https://mongolab.com/signup/ also introduce few industry buzz words.)

I hope, you might have signed up in mongolab.com and created a test MongoDB for your expriment.

Database without programmatic interface is like a watching a Rajinikanth movie without Rajinkanth fans croud. What a boaring thing to do. Rajinikanth movies should be always enjoyed with fans croud in a normal big movie theatres (Not alone in home or in HiFi multiplexs) .

MongoDB provides lots of programming language integrations. Technically, the piece of software which helps your application to talk to Database is called " Database Driver".

Here is the list of MongoDB drivers for major programming languages like C, C++, Java, Perl, PHP, Python, etc...

As I have promised in the Part1, In this post, I will show you, How to connect to MongoDB which is hosted in clouds via Perl programming language.

Why Perl?

Hmm. Where do I start?, I started my career with C programming language, I also wrote applications in Java. I got introduced to Perl when I was working in Hewlett-Packard, initially Perl looks weird but when I was learning more and more, I realized its power. I was still working on Java but then I moved to Nokia, Where I got chance to learn Python mainly for PyS60 (Python for Symbian) project.

@work, I designed and developed multiple SW test and Build framework, Currently I am working in NXP Semiconductor, Where I got chance to design and develop a highly secure, centralized, cryptography key management, cryptography operations SOAP web services using Perl + SOAP::Lite + Apache + Gtk2.

So with these limited knowledge, I can say, Perl is super powerful for most of the application development areas.

I chose Perl to show the MongoDB database programming interface but the MongoDB API and programming flow is almost similar for all other programming languages.

Preparation

To get start, we need a PC with Perl + MongoDB driver installation+ MongoDB in the cloud. I am on Fedora 20 Linux PC. Almost all the linux distributions comes with pre installed Perl.

Note: For Windows PC, I highly recommend to install ActiveState perl and use activestate perl's nice feature called PPM to install the Perl Modules. I shall write a separate post on how to install perl modules in Linux and windows with different approaches.

There are multiple perl drivers for MongoDB. Officially  "MongoDB" Perl driver is supported by MongoDB development team. This Perl driver is a wrapper over C MongoDB APIs, So this driver gives good performance and mostly support latest MongoDB APIs.

You can install perl modules using CPAN but you need a local installation of MongoDB and its development package (header files and libs). Since we are talking about cloud, we dont have anything in local machine, So I use the yum tool to install perl-MongoDB driver.

sudo yum install perl-MongoDB

Once the installation is complete, You can check the status like below,


perl -MMongoDB -e ' print $MongoDB::VERSION'

For me, the above command shows,


0.702.2


Ok, Good, Driver is Sane and working.

Now, we need to login to our MongoDB cloud database in https://mongolab.com/ and get few details,

  1. MongoDB database host name and port - Get it in the "Database" page. Ex: ds063140.mongolab.com:63140
  2. MongoDB database name - Get it in the "Database" page. Ex: npointsolutionsmdb
  3. MongoDB collection name - Get it in the "Database" page. Ex: userDetailsCollection 
  4. MongoDB user name and password - Get it in the "Users" page. Ex: username=user1, password=user123
Here is my fully working Perl code to show how to connect to MongoDB running in the google cloud. I name this perl script as a mongoDB_test.pl


#!perl
use strict;
use warnings;
use Try::Tiny;
use MongoDB;
use Data::Dumper;

#Global Variables

$|=1; #Auto flush STDOUT

my $dbHost = 'ds063140.mongolab.com:63140';
my $dbUser = 'user1';
my $dbPassword = 'user123';
my $dbName = 'npointsolutionsmdb';
my $dbCollectionName = 'userDetailsCollection';
my $dbClientObj = '';
my $dbObj = '';
my $userDetailsCollectionObj = '';
my $dbCursor = '';
my $userDetailsRecordHashRef = '';

local $,= ' , '; #Make array prints nicer
my $now = '';

#1. Connect to MongoDB 
try
{
 $dbClientObj = MongoDB::MongoClient->new(host=>$dbHost,username=>$dbUser,password=>$dbPassword,
                                          db_name=>$dbName,query_timeout => 10000);
 print "\n INFO: MongoDB in $dbHost is connected.";
}
catch
{
 die 'ERROR: Can not create MongoDB client Object: ', $_;
};

#2. Get the Mongo DB object
$dbObj = $dbClientObj->get_database($dbName);

#3. Get all Collection Names
print "\n All Collections: ", $dbObj->collection_names();

#4. Get the Collection Object
$userDetailsCollectionObj = $dbObj->get_collection($dbCollectionName);

#5. Get all the documents / records from the collection
$dbCursor = $userDetailsCollectionObj->find();
$dbCursor->immortal(1);

#Loop through all the user documents
print "\n INFO: All documents in the Collection $dbCollectionName \n";
while ($userDetailsRecordHashRef = $dbCursor->next()) 
{
 #MongoDB Cursor retrives all the fields in the Document as a name-value pair hash reference
    print "\n", Dumper (\$userDetailsRecordHashRef);
}

#6. Adding a new user document into collection
$now = scalar localtime();
try
{
    print "\n INSERT ID: ", $userDetailsCollectionObj->insert(
                             { 
                              userName => 'testPerlUser'.int(rand(100)), 
                              OS => 'Fedora 20 Linux',
                              LastLogin => $now,
                              DeviceArch => "x86_64",
                              Score => int(rand(500))
                             }, {safe => 1});
}
catch
{
 print "\n ERROR: Can not insert a record into Collection. $_";
};

#7. Query our document is in collection or not
print "\n INFO: Find all perl users";
$dbCursor = $userDetailsCollectionObj->find({userName => qr/^testPerlUser/i}); #All the userName starts with testPerlUser
$dbCursor->immortal(1);

#Loop through all the user documents
while ($userDetailsRecordHashRef = $dbCursor->next()) 
{
    #MongoDB Cursor retrives all the fields in the Document as a name-value pair hash reference
    print "\n", Dumper (\$userDetailsRecordHashRef);
}

#8. All is well, CLose connection
undef $dbClientObj;
print "\n INFO: Done. Quit";
exit (0);


Here is the output from my PC when I ran the above code,


 INFO: MongoDB in ds063140.mongolab.com:63140 is connected.
 All Collections:  , system.indexes , userDetailsCollection , objectlabs-system , objectlabs-system.admin.collections
 INFO: All documents in the Collection userDetailsCollection 

 , $VAR1 = \{
            '_id' => bless( {
                            'value' => '54846970e4b0d2e1a43f8654'
                          }, 'MongoDB::OID' ),
            'LastLogin' => 'Dec 07, 2014',
            'DeviceArch' => 'x86_64',
            'Score' => 103,
            'OS' => 'Linux Fedora 20',
            'userName' => 'test1'
          };

 , $VAR1 = \{
            'DeviceArch' => 'x86_64',
            'LastLogin' => 'Dec 06, 2014',
            '_id' => bless( {
                            'value' => '548469bee4b0d2e1a43f8656'
                          }, 'MongoDB::OID' ),
            'userName' => 'test2',
            'OS' => 'Windows 7',
            'Score' => 54
          };

 , $VAR1 = \{
            'DeviceArch' => 'x86_64',
            'LastLogin' => 'Sun Dec 14 20:58:56 2014',
            '_id' => bless( {
                            'value' => '548dacb85c3cc20b44000000'
                          }, 'MongoDB::OID' ),
            'OS' => 'Fedora 20 Linux',
            'Score' => 480,
            'userName' => 'testPerlUser55'
          };

 , $VAR1 = \{
            'DeviceArch' => 'x86_64',
            'LastLogin' => 'Sun Dec 14 21:06:45 2014',
            '_id' => bless( {
                            'value' => '548dae8d98e64d8c45000000'
                          }, 'MongoDB::OID' ),
            'userName' => 'testPerlUser41',
            'OS' => 'Fedora 20 Linux',
            'Score' => 424
          };

 , $VAR1 = \{
            'OS' => 'Fedora 20 Linux',
            'Score' => 108,
            'userName' => 'testPerlUser67',
            'DeviceArch' => 'x86_64',
            'LastLogin' => 'Sun Dec 14 21:07:00 2014',
            '_id' => bless( {
                            'value' => '548dae9c2d09dc9845000000'
                          }, 'MongoDB::OID' )
          };

 , $VAR1 = \{
            '_id' => bless( {
                            'value' => '548db07a0f9cd12946000000'
                          }, 'MongoDB::OID' ),
            'LastLogin' => 'Sun Dec 14 21:14:58 2014',
            'DeviceArch' => 'x86_64',
            'Score' => 316,
            'OS' => 'Fedora 20 Linux',
            'userName' => 'testPerlUser57'
          };

 , $VAR1 = \{
            'DeviceArch' => 'x86_64',
            'LastLogin' => 'Sun Dec 14 21:15:30 2014',
            '_id' => bless( {
                            'value' => '548db09ae3528e9546000000'
                          }, 'MongoDB::OID' ),
            'OS' => 'Fedora 20 Linux',
            'Score' => 211,
            'userName' => 'testPerlUser57'
          };

 INSERT ID:  , 548db2c5cb53ab1b47000000
 INFO: Find all perl users
 , $VAR1 = \{
            '_id' => bless( {
                            'value' => '548dae8d98e64d8c45000000'
                          }, 'MongoDB::OID' ),
            'LastLogin' => 'Sun Dec 14 21:06:45 2014',
            'DeviceArch' => 'x86_64',
            'userName' => 'testPerlUser41',
            'Score' => 424,
            'OS' => 'Fedora 20 Linux'
          };

 , $VAR1 = \{
            'DeviceArch' => 'x86_64',
            '_id' => bless( {
                            'value' => '548dacb85c3cc20b44000000'
                          }, 'MongoDB::OID' ),
            'LastLogin' => 'Sun Dec 14 20:58:56 2014',
            'userName' => 'testPerlUser55',
            'OS' => 'Fedora 20 Linux',
            'Score' => 480
          };

 , $VAR1 = \{
            'userName' => 'testPerlUser57',
            'Score' => 211,
            'OS' => 'Fedora 20 Linux',
            '_id' => bless( {
                            'value' => '548db09ae3528e9546000000'
                          }, 'MongoDB::OID' ),
            'LastLogin' => 'Sun Dec 14 21:15:30 2014',
            'DeviceArch' => 'x86_64'
          };

 , $VAR1 = \{
            'userName' => 'testPerlUser57',
            'Score' => 316,
            'OS' => 'Fedora 20 Linux',
            'LastLogin' => 'Sun Dec 14 21:14:58 2014',
            '_id' => bless( {
                            'value' => '548db07a0f9cd12946000000'
                          }, 'MongoDB::OID' ),
            'DeviceArch' => 'x86_64'
          };

 , $VAR1 = \{
            'DeviceArch' => 'x86_64',
            '_id' => bless( {
                            'value' => '548dae9c2d09dc9845000000'
                          }, 'MongoDB::OID' ),
            'LastLogin' => 'Sun Dec 14 21:07:00 2014',
            'userName' => 'testPerlUser67',
            'OS' => 'Fedora 20 Linux',
            'Score' => 108
          };

 , $VAR1 = \{
            'Score' => 191,
            'OS' => 'Fedora 20 Linux',
            'userName' => 'testPerlUser75',
            '_id' => bless( {
                            'value' => '548db2c5cb53ab1b47000000'
                          }, 'MongoDB::OID' ),
            'LastLogin' => 'Sun Dec 14 21:24:45 2014',
            'DeviceArch' => 'x86_64'
          };

 INFO: Done. Quit

Assuming that you know basic of perl, I hope the mongoDB_test.pl code + comments is self explanatory.

Note: I have shown my database host, user name and password. So you can just copy paste and run the code. Please Do not abuse the credentials.

Let me know via comments if you have any questions.

Refer:

1. https://metacpan.org/pod/distribution/MongoDB/lib/MongoDB/Tutorial.pod

2. For more query examples -> https://metacpan.org/pod/distribution/MongoDB/lib/MongoDB/Examples.pod
 
Christmas is very near, Get ready for the festival and holidays... Merry Christmas... 

Sunday, December 7, 2014

Get Hands Dirty with NoSQL + Cloud Data Storage

NoSQL, Big Data, Cloud Data Storage, Scalability, Shards etc .. are buzzwords in the Data management industry. I thought to get my hands wet with these.

Let me quickly introduce them, (Ya very quick because you will find good intro in the Wikipedia)

  • NoSQL - Data management without traditional Table format, Without traditional SQL queries. 

  • Big Data - Huge Data Sets. Like weather details of the whole century.

  • Cloud Data Storage - Get the data storage from online cloud vendors instead of storing the data in your own servers / machines.

  • Scalability - When the Data grows, Easily upgrade the computing capacity so data base operations like read , search and writes are remain faster.

  • Shards - To achieve Scalability, Instead of increasing computing power (RAM, HDD Space etc..) on the single server, Split the Data base into smaller chunks and place them in a smaller servers / machines. These chunks are calles Shards and collection of Shards forms a logical single database.
Data storage and retrial needs changes over the time. Now, we are in the world where the application users are very impatience, Can not wait for 30 sec to get the data.

The motivation behind the NoSQL is for high performance, High availability, Simple to store / search / get data and easy administration.

For example, If you are developing a mobile game and you want to store few details like userid, gamescore, devicename in the database. The data itself is very simple, creating SQL schema, creating table, querying data in SQL way is too over kill for this usecase. What you need is a online connected data storage, easy to store and super raw speed.

No offence to SQL guys, SQL is too big for us.

Hey, Good usecase right, Let me use this usecase and create online, high available, cloud provided, NoSQL database (hubbbaa...)..

When we are talking about the NoSQL, there are multiple thought process and Databases types are available in the industry. Each type stores the data in different format but the goals of the the NoSQL DBs are same. (You might need to read NoSQL in Wikipedia, if you haven't done yet).

OK. Stop talking, This post suppose to be a hands on ...

The reason why I was talking so much because I am afraid to read the manual, download, install the Db engine, configure and the use ... I am too lazy.

This is a cloud era, So lets create a online, high available, cloud provided, NoSQL database without installing anything in your machine. (I can see smile and continue to read face :) )

I chose MongoDB NoSQL database.

  • MongoDB - Open Source NoSQL Database. Uses JSON like documents for storage. Gives super speeeeeeeeeeeeeeeed.
Multiple Cloud vendors are providing MongoDB as a hosted service. Most of them provide 512 MB , Non production grade MongoDB space for free to tryout. Awesome!! Lets start,

  1. Go to https://mongolab.com/signup/ and Sign up. Mongolab offers consolidated dashboard and tools for various data base hosting service provides (Like google cloud, Microsoft Azure, Amazon cloud etc..) 


 2. Fill the data and sign up. Once you Create account, You will get a mail in your provided mail address from Mongolab for Email verification. Check your mail Box and complete the Email verification process.

3. Go to https://mongolab.com/home  - This is your Database Dashboard

4. Click "Create New" button

5. Choose your favourite cloud computing provider, I Chose Amazon.

Note: Do not change the "Location" Its only for production, Paid databases. 

6. Under "Plan" choose Single-node, Then Choose "Sandbox" for free 512MB Mongo DB. 

7. Provide Database name (Mandatory for free databases)


8. Click "Create new MongoDB deployment"

9. Once its created, You can see the database in your home / dashboard view.

Note: You can create multiple MongoDBs from Multiple Cloud providers. All of them can be managed with Dashboard page. Each database comes with 512MB data limit. But its from non production area not suitable for real bussines.


10. Good. Now you have your own database.

11. Lets add some data. In NoSQL database, as I have mentioned above there is no scheme and no need to create a table / data storage structure. In MongoDB terms,

  • Collection - Like SQL Table. Collection of documents.
  • Document - Like SQL table row data. A data record.
12.  Click your newly created MongoDB database in the dashboard. My database name is npointsolutionsmdb.

13. mongolab will take you to the Database dashboard page. Click "Add collection" button and provide collection (SQL Table) name. I gave "userDetailsCollection" as a collection name to demonstrate my above mobile game usecase.

14. Now, collection might have created. In the Dashboard, Click the just created collection name so we can add the data into collection.

15. Once you click the collection, mongolab will take you to the collection administration page, Click "Add document" button

16. You will see a Create Document page. In MongoDB, Data is represented as a JSON style documents. We can add any vaild JSON document in the Create Document page. I have added following JSON data,


{
        "userName": "test1",
        "OS": "Linux Fedora 20",
        "DeviceArch": "x86_64",
        "LastLogin": "Dec 07, 2014",
        "Score": 103
}


17. If you like my data format, Just copy paste the above data into "Create document" area and Click "Create and go back" button.

18. You can add any number of documents (one by one, by following step #15, #17) into your database. But maximum size limit for whole database (Non productional, No backup) is 512MB.

19. You can check the Database size in the Top Dashboard https://mongolab.com/home

20. If you are adding your own Data, Check its JSON syntax validity in http://jsonlint.com/ before you paste in "Create document".

21.  You can see all the documents from the collections page


22. From the collections page, You can edit / delete each document.

23. Try edit one of the document, Using "Edit" button right most side of each document


Note: You can see "_id" field is added. This is unique object ID added for each document by the MongoDB. "_id" acts like a Primary Key for the document.

24. Click "Cancel and go back" button.

25. Lets try to create index for our collection, Index will make the query run faster.

26. Click on the "Indexes" tab parallel to "Documents" tab

27. In the Add new index, Add following code (almost all the data representaion in the MongoDB is a JSON format)


{
        "userName": 1,
        "Score": 1
        
}



28. Click "Create in background" button. MongoDB also supports creating index as a foreground operation but it will block all the database operations. Usually forground index is very fast but it will take long time if you have large data set. So always create index in background.

29. Go to your collections by clicking db: "<your db name>" link.

30. Click User tab parallel to Collections tab


31. Lets add Database users so they can access our data. Click "Add database user" button

32. Provide user details, I have created user name "user1" with password "user123"


33. READ ONLY? shows that the user can only read the documents or even update / insert documents. false indicates the user can update and insert the documents into collections.

34. Goto home / dashboard , https://mongolab.com/home



35. You can see your MongoDB database size is grown up because we have added few documents into the collections, created users and indexes.


Congrats !!! , Now you have your own online, high available, cloud provided, NoSQL database. 

Keep your  MongoDB read, I will show you how to access the Online, cloud provided, MongoDB via application program code (mostly Perl). Stay tune ...

Refer:



3. And google is your best friend.

Monday, December 1, 2014

Linux Tip: How to run GUI application as a other user

Its easy to run a command as other user in Linux.


sudo -u bakki id

uid=1000(bakki) gid=1000(bakki) groups=1000(bakki),10(wheel),18(dialout)




But when you try to run a GUI application as other user, its not as simple as commandline.


sudo -u bakki kwrite
No protocol specified
kwrite: cannot connect to X server :0

The above command does not work because user 'bakki' do not have necessary permission to work with X server running on other user.

Here is a difference, When compare to Windows OS, In Linux OS, X Server, which is responsible to draw in video hardware runs as a client in a given user with given permissions.

All the GUI applications sends the drawing request to the X server via X protocols. So if the X Server running user do not provide permission, No other user application can contact the X Server for display. This is the reason GUI applications fails to run as a other user using simple command line.

Solution: Provide X Server permission to users and run the command.


CMD="kwrite";
USER=bakki;xhost +SI:localuser:$USER; sudo -u $USER -H -b $CMD >/dev/null 2>&1 

It is particularly useful to run vlc media player under root account in linux. vlc will not run as a root but for some reason, if you need to run the vlc under root desktop login in linux, you can use following way,


CMD="vlc";USER=bakki;xhost +SI:localuser:$USER; sudo -u $USER -H -b $CMD >/dev/null 2>&1  
 
 
If you do not like to use the inbuilt commands, You can always use KDE / GNOME provided utilities to run Linux GUI applications as a other user. Its simple as well,

KDE:

kdesu -u bakki firefox 

Sunday, November 30, 2014

Blog development environment setup - A hello world post

Seriously, Yes. As a developer, I have been trained to,

1. Set up environment

2. Learn new things with "hello world"

I naturally followed the same above steps for this blog. I thought, I need a good desktop environment for blog development, so I spent close to 3 hours to find the right environment. My conclusion is,

Nothing !! No environment required.

I started with "Blogilo", KDE Desktop based blog client for Linux. It allows me to configure various blogger host services like blogger.com, wordpress.com etc..  allows to create content offline and upload it.

I thought, Its my IDE for blogs and literally started this blog in it with screen shots. When I submitted the blog, it was submitting ....  submitting... submitting ... I finished coffee and my mind strated working again. Hey! Why are you taking so long time?

I closed the Blogilo app its crashed and the post was not submitted to blogger.com. WTF?

I tried to debug, Found that, when you insert an image (in my case, screenshots), Blogilo app inserts following html code,

<html><head></head><body><img src="file:///tmp/And2.png"></body></html>


Looks normal, But when you look st the image source, it is pointing to local machine. So the Blogilo need to upload the image first and the upload my post But blogger.com API or Blogspot.com API doesn't support uploading media.



This explains the crash problem with Blogilo.  

I found a trick to overcome this problem. Open the Libreoffice Writter (equivalent to  MS Office Word) and copy paste the image / insert the image then copy the image (Ctrl+C) and paste in Blogilo in this case Blogilo adds the image with base64 encoded binary data, Not as a link to local machine.

But base64 bloats up the size and its a very cumbersome way of doing anything.

Ok, Its open source world, If not Blogilo, there should be something else.

Unfortunately, under linux, I did not find another good blog editing desktop client. I found one called ScribeFire, which is a firefox extension and runs under firefox. I installed it,

But, If I can open the firefox, I can browse to www.blogger.com and use its awesome online WYSWYG editor. Hey , its an experiment, dont put more thoughts..

ScribeFire also suffers the same problem of Blogilo. But
ScribeFire is little intelligent, when I try to insert an image, It tried to upload the image to Google Picasa and tried to insert a link than img src from local machine but this operation fails.
 

Hmm... What could be wrong, Why Blogilo is behaving this way. Why dont I find a good open source desktop blogger tool?

After some more readings and understanding, I found that the limitation comes from the blog hosting services. Unless they export the APIs, its impossible to develop the clients.

Looks like Wordpress supports most of the APIs so Blogilo would be more suitable to Wordpress.

I thought a moment to migrate the blog to Wordpress but decided to keep my blog in blogger because of the admin simplicity and its powerful web statistics.

Conclusion is that I am going to use blogger.com's web interface to add the blog posts and officially I have learned "Hello World" in www.blogger.com.


                                          "Hello World"
                                          "Hello Blogger"



How does its started????

Welcome 

You are one of my early reader. Thank you.

No. I am not gonna tell my love story again !!!. This blog is dedicated for the technology (at least its description says).

As the good old saying "A LOT can happen over a cup of coffee", we were having a half sleeping morning cup of coffee in office (I strongly believe coffee is waking up most of the software engineers mind in the morning without a hot cup of coffee in the morning, we would be continue to sleep... Hey come back to story man... Opps yes , Sorry first post, Read on ...)

I was with @Prabhu Desai and @Pavanesh Netrakar at the NXP coffee table in the morning. I don't think these guys needs a coffee to kick start their day (Ya, exception from above statement), These guys are always charged yet drinks Coffee just to be a social animals.

I was talking about my experiments with Android x86 in Linux KVM (I even posted a screen shot in Facebook.  Yes, Facebook !!! and even Pavanesh liked it !!). Though, they never mentioned, I think Pavanesh and Prabhu thought I need a better place to talk about technology not in Facebook.

They asked a important question, "Hey bakki, Have you updated this information about Android and KVM expriments in you blog?" but I never had a blog, Pavanesh said, "I am surprised !!, you should blog".

I took it seriously !! After a multiple lazy week ends. This blog born.

I thought to keep an update of my experiments and my thoughts in various software fields here. Mainly, if you wanna know more about Software Build and Test automation, Linux, Android, Perl, some times my crazy ideas, You wouldn't be disappointed.

@Prabhu Desai and @Pavanesh Netrakar - Thanks Guys.