The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

App::Validation::Automation

VERSION

Version 0.01

SYNOPSIS

    use App::Validation::Automation;

    my $obj = App::Validation::Automation->new(
        config          => \%config,
        log_file_handle => $log_handle,
        user_name       => $config{'COMMON.USER'},     #Optional Parameter
        password        => $config{'COMMON.PASSWORD'}, #Optional Parameter
        site            => $config{'COMMON.SITE'},     #Optional Parameter
        zone            => $config{'COMMON.ZONE'},     #Optional Parameter
        secret_pphrase  => $secret_pphrase,            #Optional Parameter
    );

    $success = $obj->validate_urls();
    $success = $obj->test_dnsrr_lb();
    $success = $obj->validate_processes_mountpoints();

    #Or, If config is small

    my $obj = App::Validation::Automation->new(
        config          => {
            'COMMON.SSH_PROTO'    => '2,1',
            'COMMON.ID_RSA'       => [
                                        /home/user/.ssh/id_rsa1, 
                                        /home/user/.ssh/id_rsa2
                                     ],
            'COMMON.DEFAULT_HOME' => /home/user/App/Validation,
            'COMMON.LOG_DIR'      => /home/user/App/Validation/log,
            'COMMON.LINK'         => http://ap.xyz.com/loginproxy_servlet,
            'COMMON.PROCESS_TMPL' => ps -eaf |grep -i %s|grep -v grep|wc -l
            'COMMON.FILESYS_TMPL' => cd %s
            'HOSTNAME1.PROCESSES' => [BBL:1, DMADM:],
            'HOSTNAME1.FILE_SYS'  => [/home, /],
            'HOSTNAME2.PROCESSES' => [BL:1, DADM:],
            'HOSTNAME2.FILE_SYS'  => [/home, /],
            'HOSTNAME2.LINKS'     => [
                                        http://hostname2.xyz.com:6666,
                                        http://hostname2.xyz.com:6667, 
                                     ]
        },
        log_file_handle => $log_handle,
        user_name       => $config{'COMMON.USER'},     #Optional Parameter
        password        => $config{'COMMON.PASSWORD'}, #Optional Parameter
        site            => $config{'COMMON.SITE'},     #Optional Parameter
        zone            => $config{'COMMON.ZONE'},     #Optional Parameter
        secret_pphrase  => $secret_pphrase,            #Optional Parameter
    );
   
   #Verify All links - calls validate_url for all links under each host
   $ret = $obj->validate_urls();
   #Verify filesystems and processes on remote hosts- calls connect,validate_process
   #and validate_mount for all processes and filesystems on all remote hosts 
   $ret = $obj->validate_processes_mountpoints();
   #DNS Round Robin and Load Balancing functionality Check - Calls dnsrr and lb 
   #for common link
   $ret = $obj->test_dnsrr_lb();

   #Or,do most of the stuff yourself and based on success/failure log/mail
   $ret = $obj->validate_url("http://cpan.org");
   $ret = $obj->dnsrr("http://abc.com",10,2);
   $ret = $obj->lb("http://abc.com",10,2);

   $ret = $obj->connect("abc.xyz.com","user");
   $ret = $obj->validate_process("BBL:4","ps -eaf|grep %s|wc -l");
   $ret = $obj->validate_mountpoint("/home","cd %s");
   

DESCRIPTION

A Validation Framework to check if your Application is running fine or not.This module can be used for Applications that are built on Unix and have a Web interface. The suite has the capabilty to check Application web urls for accessiblity,and also login into each of those urls to ascertain database connectivity along with sub url accessbility.One can also verfiy processes and mountpoints on the remote hosts which house the application. The password for logging into the web urls is stored in an encrypted file.The Module also has capability to test if Load Balancing and DNS Round Robin is funtioning.High Availabilty Web applications use Load Balancing and DNS Round Robin to add redundancy,high availability, and effective load distribution among the various servers(Web,Application, and Database servers).Further to frontend validations the module provides methods to validate the backend.To carryout backend verification it connects to remote hosts using SSH.Backend verfication involves checking if correct not of processe are running and file systems are accessible.App::Validation::Automation is driven by a tunable configuration file(sample config bundled with this distribution)which is formated in Windows .ini format.Please take a look at the configuration file under config/.

INHERITANCE,ATTRIBUTES AND ROLES

App::Validation::Automation Class leverages App::Validation::Automation::Web and App::Validation::Automation::Unix to perform Web and Unix level validations.It also acts as an application logger,alarmer and log purger.

METHODS

validate_urls

Check various web links stored in config file for accessibility.The real work is done by validate_url method of App::Validation::Automation::Web class.Returns true on success and false on failure.Handles password expiration along with authentication failure.On password expiry calls change_web_pwd and change_unix_pwd to change password at both Web and Unix level.Notifies via text page and email and also logs the error message.

test_dnsrr_lb

Validates if DNS Round Robin and Load Balancing feature is working fine or not.

validate_processes_mountpoints

Checks various processes and filesystems on remote servers.The method establishes connection to the remote server.this pre-cooked connection is used by validate_process and validate_mountpoint to do the real work.The connection is establised using Net::SSH::Perl. Please note to generate and store the Private and Public key pairs for password less SSH login.Refer HOWTO section down below to generate Public/Private key pairs.

HOWTO

Generate Public/Private key pairs for SSH

ssh-keygen is used to generate that Public/Private key pair:

user@localhost>ssh-keygen -t rsa

Generating public/private rsa key pair.

Enter file in which to save the key (/home/user/.ssh/id_rsa):

Enter passphrase (empty for no passphrase):

Enter same passphrase again:

Your identification has been saved in /home/user/.ssh/id_rsa.

Your public key has been saved in /home/user/.ssh/id_rsa.pub.

The key fingerprint is: f6:61:a8:27:35:cf:4c:6d:13:22:70:cf:4c:c8:a0:23 user@localhost

The command ssh-keygen -t rsa initiated the creation of the key pair.Adding a passphrase is not required so just press enter.The private key gets saved in .ssh/id_rsa. This file is read-only and only for you. No one else must see the content of that file, as it is used to decrypt all correspondence encrypted with the public key. The public key gets stored in .ssh/id_rsa.pub.The content of the id_rsa.pub needs to be copied in the file .ssh/authorized_keys of the system you wish to SSH to without being prompted for a password. Here are the steps:

Create .ssh dir on remote host(The dir may already exist,No issues):

user@localhost>ssh user@remotehost mkdir -p .ssh user@remotehost's password:

Append user's new public key to user@remotehost : .ssh/authorized_keys and enter user's password:

user@localhost>cat .ssh/id_rsa.pub | ssh user@remotehost 'cat >> .ssh/authorized_keys' user@remotehost's password:

Test login without password:

user@localhost>ssh user@remotehost user@remotehost>hostname

remotehost

Use configuration file

App::Validation::Automation is driven by a tunable configuration file.The configuration file is in Windows .ini format.The wrapper script using App::Validation::Automation needs to either read the configuration file or build the configuration itself.The configuration file is broadly divided into two parts COMMON and Remote host specific.The COMMON part contains generic info used by App::Validation::Automation not specific to any host.

Example:

[COMMON]

#User to login into Web links

USER = web_user

#Common User to login into remote host

REMOTE_USER = user

#Post link MAX_REQ no of times, used while testing Load #Balancing and DNS round robin functionality

MAX_REQ = 10

#Minimum distinct redirected uris to ascertain Load Balancing #and DNS round robin is working fine

MIN_UNQ = 2

#Log file extension

LOG_EXTN = log

#Print SSH debugging info to STDOUT

DEBUG_SSH = 1

#Try SSH2 protocol first and then SSH1

SSH_PROTO = '2,1'

#Private keys for each server(AA,KA...) used for SSH

ID_RSA = /home/user/.ssh/id_rsa_AA,/home/user/.ssh/id_rsa_KA

MAIL_TO = 'xyz@yahoo.com,123@gmail.com'

PAGE_TO = '8168168164@vodafone.in'

FROM = xy@localhost.com

SMTP = localhost.com

#Text file containing Encrypted password for USER

ENC_PASS_FILE = pass.txt

DEFAULT_HOME = /home/App/Validation

LOG_DIR = /home/App/Validation/log

#Log file retention period, delete log file older than 5 days

RET_PERIOD = 5

#Main Weblink used for Load Balancing and DNS round robin test

LINK = http://cpan.org

#Remote command fired to get process count.%s is replaced process name

PROCESS_TMPL = ps -eaf | grep -i %s | grep -v grep | wc -l

#Remote command fired to check filesystem.%s is replaced by filesystem name

FILESYS_TMPL = cd %s

#FQDN of remote server

[AA.xyz.com]

#Processes to verify on remote hosts along with their minimum quantity

PROCESSES = BBL:1, EPsrv:1, WEBLEPsrv:1

#Filesystems to verify on remote hosts

FILE_SYS = /test, /export/home

#FQDN of remote server

[KA.xyz.com]

#Processes to verify on remote hosts along with their minimum quantity

PROCESSES = BBL:1, EPsrv:1, WEBLEPsrv:1

#Filesystems to verify on remote hosts

FILE_SYS = /test, /export/home

#Links specific to KA server these links are checked for accessibility

LINKS = http://KA.xyz.com:7000,http://KA.xyz.com:7100

AUTHOR

Varun Juyal, <varunjuyal123@yahoo.com>

BUGS

Please report any bugs or feature requests to bug-app-validation-automation at rt.cpan.org, or through the web interface at http://rt.cpan.org/NoAuth/ReportBug.html?Queue=App-Validation-Automation. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.

SUPPORT

You can find documentation for this module with the perldoc command.

    perldoc App::Validation::Automation

Also check out the script under script/ for a full blown example on how to use this suite.

You can also look for information at:

ACKNOWLEDGEMENTS

LICENSE AND COPYRIGHT

Copyright 2011 Varun Juyal.

This program is free software; you can redistribute it and/or modify it under the terms of either: the GNU General Public License as published by the Free Software Foundation; or the Artistic License.

See http://dev.perl.org/licenses/ for more information.