Tuesday, March 18, 2014

How to get current user on Windows from command line

Windows provides lot many commands and one of them is to get the current logged in user name.
The command to view the current user is

whoami

This command comes in handy when you are working in Hyper-V cores or Windows Core servers.
Hope that helps someone out there on internet :-)

Wednesday, December 4, 2013

Starting a new Command Console on Hyper-V 2012 core

Normally when you log into Hyper-V core you will find only two consoles to operate. 
One would be a normal console where you can type in dos or Windows commands and other would be Server Configuration console, which you can use to make configuration changes to your Hyper-V server


Normal command console

Server configuration



There may be times when you need to have additional consoles , say to verify inputs or outputs simultaneously on Hyper-V core.
You can do so by running the command "start cmd" at one of the consoles. This command would trigger a new command console and will shift focus to new console


Tuesday, June 18, 2013

Setting up FTP on Ubuntu

We often need to transfer files from one machine to another. There are several ways we can do this , however in case you need to transfer files across the machines which are located in different geographic locations, then the only way is over internet.

Transferring files over http can be slow, so the best option would be to transfer using FTP. So lets get started setting up FTP on Ubuntu.


Boot up your Ubuntu box and login
Open your Terminal window and type in the following commands

sudo apt-get update
sudo apt-get install vsftpd

Once installed you will need to edit /etc/vsftpd.conf file.

pico /etc/vsftpd.conf

Make the following changes in the vsftpd.conf file 

Disable Anonymous login
anonymous_enable=NO

Allow local user to login to FTP
local_enable=YES

Enable write to the FTP server in case you need to upload some data to ftp server
write_enable=YES

Restrict users to their home directories
chroot_local_user=YES

Enable the list of users for chroot
chroot_list_enable=YES

Set the list for user to chroot. You will need to create this file manually under /etc or other location where you intend to place this file
chroot_list_file = /etc/vsftpd.chroot_list

Save the file and restart the vsftpd service from your terminal
sudo service vsftpd restart

From other machine try connecting to your new FTP server using any FTP client.



Friday, June 7, 2013

Removing Bluetooth devices from your Windows 7 machine

Many a times I connect my laptop to my friends mobile phones over bluetooth to share images and music.

After sharing the Bluetooth devices are present in Explorer when I browse Computer. I need to clean them up so they don't clutter the explorer. Nor having them impact normal usage. Its just personal. I like my machine clean.













Wednesday, April 25, 2012

Test Automation Framework

In past few years I have designed and developed Test Automation Framework for several of our customers. At times there have been customers and testers who wanted me to just have Record and Play (R&P) kind of automation and I had hard time convincing them for TAF. They did agree to my advice of having TAF over R&P only after few months down the line of getting test automation introduced and realizing the cost of maintenance taking over new script development and existing automation execution.


This post describes in details why Test Automation Framework (TAF) is essential for better returns on investment (ROI) over bunch of standard record and play scripts.


R&P

R&P has limitations and may not always work. Let me explain how R&P will fail. In R&P you simply record the scripts and play them when you want to test your application after every bug fix or addition of new functionality over a period of time. Your application will have several forms where user need to provide information. Based on these user inputs your application will provide unique identities to inputs and also there will be change of states of several objects in your application. Now every time you execute these recorded scripts you will not get same unique identities and your verification for recorded objects relying on recorded identities will fail the verification causing automated scripts to fail and build being marked as failed build.


TAF helps in taking care of such objects and their obsolete states. It will ensure that every time you execute the automated script correct test data goes into your application and the application output provides the correct results. Any failed test script should provide valid application failure. TAF also assists in ensuring the consistency and accuracy of the application is well maintained. 


How TAF looks like ?

TAF consists of automation driver, test scripts, test data, application configuration data, test results/report and automation tool. They work hand in hand in smooth execution of test scripts,  creating test data before hand, cleaning up any test data after test execution, analysis of results and compiling reports. The real value added to test automation is from test application library handling verification and actions on objects.




Advantages

Robustness:
There should be minimum impact on automated scripts after there is change in application.
At times Automation engine is way too fast on acting on controls on AUT. So it’s necessary to synchronize test script performs actions on controls when they are actually loaded. Framework allows us to do synchronization and make it robust test scripts


Maintainable:
It should be easy to fix if there are automation test script defects and QA should be able to add new automated test scripts. Framework makes test automation maintainable.


Extensible:
Having framework helps in adding new features and modules to existing test automation suite without having to worry about the impact on the existing test scripts


Reusable/Modular:
With good framework in place helps in reusing the same verification/validation code to be used across the test scripts bringing down the time to develop new test cases


Disadvantages

Test team needs to have moderate development skills. Any tester with knowledge of developing programs using OOPs concepts and SQL should be able to write a strong automation framework.





Tuesday, April 24, 2012

Resolving MySql Error 1049

Recently while trying to run a db query on mysql server from mysql client I faced Error 1049.
I finally managed to resolve the issue by modifying the ruby script that I was trying to execute.

Here is what it was before
mysql -u root -p 'password' -h host.mydomain.com

Upon execution it asked for password and after entering password here is what the terminal spitted at me

ERROR 1049 (42000) : Unknown database ''password''

Here is what I did to mysql command in my ruby script

mysql -u root -ppassword -h host.mydomain.com

Executed the script again and it worked fine.


What really solved the issues was removal of " ' " before and after the password and white space between the -p and password.


Hope that helps someone looking for solution to similar problem

Monday, September 19, 2011

Connecting MySql over SSH using C#

I am sure many of you are looking for C# code to connect to MySql server over SSH.
I hope you are aware of SSH , if not please google SSH and know more about the SSH in details.


.Net does not have its own inbuilt methods or classes for connecting to MySql over SSH.
Hence you will need to download few open source dlls for the implementing your code to connect to MqSql over SSH.


I am going to use sharpSSH here. Thanks to Tamir for writing the code and sharing with the world.
You can download the library from here. Also you will need the secret key file in openSSH format to connect. You can get the key in openSSH format generated from puttygen.


Here is the code for MySql Connection over SSH using C#

using System;

using System.Collections;
using MySql.Data.MySqlClient;
using Tamir.SharpSsh.jsch;


namespace MySQLSSHConnection
{
class Program
{
static void Main(string[] args)
{
 MySqlConnection myConnection = null;
 Session sshSession = null;
 try
 {
  JSch jsch = new JSch();
                
  //Setting the secret key file
  jsch.addIdentity(@"D:\...\key-file");
  sshSession = jsch.getSession("username", hostname, 22);
                                
  Hashtable config = new Hashtable();
  config.Add("StrictHostKeyChecking", "No");            
  sshSession.setConfig(config);


  //Setting the SSH connection
  sshSession.connect();
                
  //Forwarding the remote port to local port over the connected session
  sshSession.setPortForwardingL(3306, "localhost", 3306);


  //Connecting to Mysql 
  string connstring = "Server=localhost;Port=3306;database=Account;Uid=****;Password=****";
  myConnection = new MySqlConnection(connstring);
  myConnection.Open();                
  Console.WriteLine("Open OK");
  Console.ReadLine();                
 }
 catch(Exception ex)
 {
   Console.WriteLine(ex.ToString());
   Console.ReadLine();
 }
 finally
 {
  //Closing database connection
  myConnection.Close();


  //Closing SSH connection
  sshSession.disconnect();
 }
}
}
}


Hope this post is helpful.