Friday, 19 October 2018

How to handle SSL Certificate Error using Selenium Webdriver\

Image result for ssl certificate



\

Suppose we have written test scripts and while running those script, if you encounter situation like "Untrusted Connection" then how do we handle such exception in Selenium automation.

In such cases we have to adjust our script in such way that, it will take care of SSL exception by itself.

Some desired capabilities being used to configure webdriver instance. Through this capabililties one can configure all driver instances like ChromeDriver, FireFoxDriver and Internet Explorer.

SSL Certificate Error Handling in Chrome
To handle such case in Chrome, one needs to use desired capabilities of Selenium webdriver. Below snippet will help to accept all SSL certificate in Chrome. 
DesiredCapabilities handlSSLErr = DesiredCapabilities.chrome ()       
handlSSLErr.setCapability (CapabilityType.ACCEPT_SSL_CERTS, true) 
WebDriver driver = new ChromeDriver (handlSSLErr); 

SSL Certificate Error Handling in Firefox

To handle such case in Chrome, one needs to use desired capabilities of Selenium webdriver. Below snippet will help to accept all SSL certificate in Chrome. 

1) Pre-requisite is, one needs to create new firefox profile say "myProfile" 
2) Now access myProfile in the script as below and create it's object.

ProfilesIni prof = new ProfilesIni()    
FirefoxProfile ffProfile= prof.getProfile ("myProfile")
3) Now we need to configure "SetAcceptUntrustedCertificates" and "setAssumeUntrustedCertificateIssuer" properties in the FireFox  profile

ffProfile.setAcceptUntrustedCertificates(true) 
ffProfile.setAssumeUntrustedCertificateIssuer(false)
4) Now use FireFox profile in FireFox driver instance.

WebDriver driver = new FirefoxDriver (ffProfile)   
Note: "setAcceptUntrustedCertificates" and "setAssumeUntrustedCertificateIssuer" are capabilities to handle the certificate errors in web browsers.


---------------------------

Saturday, 15 September 2018

How to install Jenkins on CentOS/RHEL

How to install Jenkins on CentOS/RHEL


Jenkins gives consistent integration services to programming improvement. It is server based framework running in servlet holder, for e,g, Apache Tomcat. It support SCM devices including CVS, Git, SVN, RTC, Perforce etc...and can execute Apache Ant and Apache Maven based task. 


Jenkins is opensource and most famous persistent joining device written in Java. There are numerous plugins accessible to make it more simpler. You can design built with different means like, activated by a submit in variant control framework scheduling by cron-jobs etc..

Step 1: Check Java Version
First, we have to check that Java has been installed on the server or not. Jenkins require Java 1.6 or more than. If Java version is less than 1.6 than we have to upgrade the Java. Use following command to check Java Version.
# java -version
openjdk version "1.8.0_45"
OpenJDK Runtime Environment (build 1.8.0_45-b13)
OpenJDK 64-Bit Server VM (build 25.45-b02, mixed mode)
Step 2: Jenkins Repository
After checking the version of Java we need to add Jenkins repositories on the server.
# wget -O /etc/yum.repos.d/jenkins.repo   http://jenkins-ci.org/redhat/jenkins.repo
# rpm --import http://pkg.jenkins-ci.org/redhat/jenkins-ci.org.key

Step 3: Install Jenkins
Use following command to install Jenkins.
# yum install jenkins
Step 4: Start Jenkins
Start Jenkins Service uses following command.
# /etc/init.d/jenkins start | stop | restart
# chkconfig jenkins on
Step 5: Verify Jenkins
By default Jenkins use 8080 port. We use following command to check Jenkins is running or not.
 
# netstat -ntulp | grep 8080
Step 8: Change Jenkins HTTP port number
By default, Jenkins runs on port 8080. If you want to change the default port for Jenkins you need to change the file /etc/sysconfig/jenkins
# vim /etc/sysconfig/jenkins
Default:
JENKINS_PORT="8080"
New:
JENKINS_PORT="8443"
Step 9: Access Jenkins
Go to your browser and type http://localhost:8080/. Presently you ought to ready to see the Jenkins dashboard like below image:

I hope this tutorial will help you to install Jenkins on CentOS.

Thank You...!

Tuesday, 6 June 2017

Bi-Directional Replication for PostgreSQL 9.4 on Centos 64bit using 2ndQuadrant

Bi-Directional Replication for PostgreSQL 9.4 on Centos 64bit using 2ndQuadrant
Node 1: 192.168.1.10 Node 2: 192.168.1.11 Step 2: Installing BDR Node1 and 2 database
yum install http://packages.2ndquadrant.com/postgresql-bdr94-2ndquadrant/yum-repo-rpms/postgresql-bdr94-2ndquadrant-redhat-latest.noarch.rpm
 
Step 3: Install the BDR packages
yum install postgresql-bdr94-bdr
  
Step 4: Initialize Node1 and 2 database  
/usr/pgsql-9.4/bin/postgresql94-setup initdb
  
Step 5: Edit the postgresql.conf (/var/lib/pgsql/9.4-bdr/data/postgresql.conf) file for both nodes/instances:
Node 1

listen_addresses = '*' 
port = 5598  
shared_preload_libraries = 'bdr'
wal_level = 'logical'
track_commit_timestamp = on
max_connections = 100
max_wal_senders = 10
max_replication_slots = 10
# Make sure there are enough background worker slots for BDR to run
max_worker_processes = 10
 
Node 2

listen_addresses = '*' 
port = 5599  
shared_preload_libraries = 'bdr'
wal_level = 'logical'
track_commit_timestamp = on
max_connections = 100
max_wal_senders = 10
max_replication_slots = 10
# Make sure there are enough background worker slots for BDR to run
max_worker_processes = 10
 
Step 6: Set the IP addresse in file (/var/lib/pgsql/9.4-bdr/data/pg_hba.conf)

Node 1:

host replication postgres 123.12.1.10/32 trust
host replication postgres 123.12.1.11/32 trust
host all postgres 123.12.1.10/32 trust
host all postgres 123.12.1.11/32 trust

Node 2: 

host replication postgres 123.12.1.11/32 trust
host replication postgres 123.12.1.10/32 trust
host all postgres 123.12.1.11/32 trust
host all postgres 123.12.1.10/32 trust

Step 7: Reboot the server and Restart the Postgres and disable IPTables algorithm:

Disable IPtable using following command to get access to outside world.
'iptables -F'

/etc/init.d/postgresql-9.4 status
/etc/init.d/postgresql-9.4 stop
/etc/init.d/postgresql-9.4 start
/etc/init.d/postgresql-9.4 restart

Login to postgres `su - postgres` and then enter the command.

Step 8: Create DB on Node 1
createdb -p 5432 -U postgres dbDuiIVR

Note: One can use different port on two different nodes. i.e. here you may want to use 5598

Step 9: Create DB on Node 2
createdb -p 5432 -U postgres dbDuiIVR

Note: One can use different port on two different nodes. i.e. here you may want to use 5599
Step 10: Enabling BDR in SQL sessions for both of your nodes/instances
Node 1:
psql -p 5432 -U postgres dbDuiIVR
CREATE EXTENSION btree_gist;
CREATE EXTENSION bdr;


Node -2:
psql -p 5432 -U postgres dbDuiIVR
CREATE EXTENSION btree_gist;
CREATE EXTENSION bdr;
    
Step 11: Then you run a function that identifies a BDR group that delineates a connection string for other nodes to communicate 
with (for the first node, we will use port 5432) from the same SQL session as above on port 5432:    
Node 1: 

SELECT bdr.bdr_group_create(
      local_node_name := 'node1',
      node_external_dsn := 'port=5432 dbname=dbDuiIVR host=192.168.1.10'
);
Note: To make sure, issue following query
SELECT * FROM bdr.bdr_nodes;
Step 12: To ensure that the node is ready to replicate, run this function from the same SQL session as above on port 5432:

Node 1: 

 SELECT bdr.bdr_node_join_wait_for_ready();
    
Step 13: Then run a function that joins this node/instance to your BDR group you created above (for the second node, we will use port 5599) 
from the same SQL session as above on port 5599:

Node 2:

SELECT bdr.bdr_group_join(
      local_node_name := 'node2',
      node_external_dsn := 'port=5432 dbname=dbDuiIVR host=192.168.1.11',
      join_using_dsn := 'port=5432 dbname=dbDuiIVR host=192.168.1.10'
);

Note: To make sure, issue following query
SELECT * FROM bdr.bdr_nodes;
Step 14: To ensure that the node/instance is ready to replicate, run this function from the same SQL session as above on port 5599:

Node 2:
    SELECT bdr.bdr_node_join_wait_for_ready();
Step 15: Create a table and insert rows from your first node/instance:

Node 1:
      CREATE TABLE t2bdr (c1 INT, PRIMARY KEY (c1));
      INSERT INTO t1bdr VALUES (1);
      INSERT INTO t1bdr VALUES (2);
      -- you will see two rows
      SELECT * FROM t1bdr;

Step 16: Check that the rows are there on your second node/instance. Now, delete a row:

Node -2:
      -- you will see two rows
      SELECT * FROM t1bdr;
      DELETE FROM t1bdr WHERE c1 = 2;
      -- you will see one row
      SELECT * FROM t1bdr;

Step 18: Check that one row has been deleted from the first node/instance::

      -- you will see one row
      SELECT * FROM t1bdr;

----------------------------------------------------------------------------------------


How to remove BDR postgreSQL from the same server. (This has been done on 62 & 63)

1) First check what rpm are installed on the server (192.168.1.10)

[root@linsys1b ~]# rpm -qa | grep postgres
postgresql-bdr94-bdr-1.0.2-1_2ndQuadrant.el6.x86_64
postgresql-bdr94-2ndquadrant-redhat-1.0-3.noarch
postgresql-bdr94-contrib-9.4.12_bdr1-1_2ndQuadrant.el6.x86_64
postgresql-bdr94-9.4.12_bdr1-1_2ndQuadrant.el6.x86_64
postgresql-bdr94-libs-9.4.12_bdr1-1_2ndQuadrant.el6.x86_64
postgresql-bdr94-server-9.4.12_bdr1-1_2ndQuadrant.el6.x86_64

2) To remove above rpm, use following command,

rpm -e postgresql-bdr94-bdr-1.0.2-1_2ndQuadrant.el6.x86_64
rpm -e postgresql-bdr94-contrib-9.4.12_bdr1-1_2ndQuadrant.el6.x86_64
rpm -e postgresql-bdr94-server-9.4.12_bdr1-1_2ndQuadrant.el6.x86_64
rpm -e postgresql-bdr94-2ndquadrant-redhat-1.0-3.noarch
yum remove postgresql
rpm -e postgresql-bdr94-libs-9.4.12_bdr1-1_2ndQuadrant.el6.x86_64

----------------------------------------------------------------------------------------

Select Language