Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Manage Selenium Grid with Terraform by Omkar Khatavkar (https://www.linkedin.com/in/omkar-khatavkar-3bba6b22/)

304 views

Published on

Manage the Selenium Grid with Terraform by Omkar Khatavkar (https://www.linkedin.com/in/omkar-khatavkar-3bba6b22/)

Published in: Education
  • Be the first to comment

  • Be the first to like this

Manage Selenium Grid with Terraform by Omkar Khatavkar (https://www.linkedin.com/in/omkar-khatavkar-3bba6b22/)

  1. 1. OMKAROMKAR KHATAVKARKHATAVKAR Senior Quality Engineer Red Hat Pune India    MANAGE DISTRIBUTED TESTING WITH SELENIUM GRIDMANAGE DISTRIBUTED TESTING WITH SELENIUM GRID AND TERRAFORM AND TERRAFORM     1
  2. 2. It was Internet Explorer! Need for Distribution Testing?        Validate the application works in Multiple Cross Browser/OS  Give an early feedback to Developer Reducing time, as tests are running distributed and Concurrently  More Test Coverage 2
  3. 3.  Why Selenium GRID ? open Source ! Selenium Grid gives the flexibility to distribute your test cases for execution Cross platform testing (Multiple OS/Browser Combination) Helps to Running tests in parallel Problem Statement : How to Distribute UI Tests ?   Selenium GRID 3
  4. 4. How Selenium Grid Works ? java -jar selenium-server-standalone-3.14.0.jar -role hub java -Dwebdriver.chrome.driver="chromedriver.exe" -Dwebdriver.ie.driver="IEDriverServer.exe" -Dwebdriver.gecko.driver="geckodriver.exe" -jar selenium-server-standalone-3.14.0.jar -role node browser binaries browser binaries browser binaries 4
  5. 5. What are the Problems with Selenium Server Running on Local Physical hardware Update in browser versions, binaries are Painful Scaling Selenium Nodes will be issues with more tests SaaS alternatives (Browser Stack, Sauce Labs) Pricing is steep (2 concurrent sessions is priced at $199 monthly) Good for less number of tests/multiple browser versions Running on Container/Docker Containers are Linux. (Cannot run on IE) Running on Cloud (AWS) with Terraform All infra can be managed by terraform (Create to Destroy)  We can scale up nodes any time. Cost can be less than SaaS alternatives 5
  6. 6. What is Terraform? Infrastructure as code Open Source, written in Golang by Hashicorp build, change, version infrastructure through a common config file One command to create, update infrastructure. A single tool to manage Multiple Providers such as (AWS, Azure, OpenStack ) configuration files are in the .tf format Config PlanApply Infrastructure Life  Cycle 6
  7. 7. Terraform Config Files Selenium_hub_node.tf // setting aws credentials and region provider "aws" { access_key = "${var.aws_access_key}" secret_key = "${var.aws_secret_key}" region = "${var.aws_region}" } // Creating AWS EC2 Instance resource "aws_instance" "selenium_node_instance" { instance_type = "${var.aws_instance_type}" vpc_security_group_ids = [ "${aws_security_group.selenium_hub_s associate_public_ip_address = true tags { Name = "selenium_node_instance" } key_name = "admin_key" ami = "${var.aws_ami}" # This is currently vpc from the account subnet_id = "subnet-b81c8cf3" depends_on = ["aws_instance.selenium_hub_instance"] provisioner "file" { source = "files/selenium_node.sh" destination = "/tmp/selenium_node.sh" } resource "aws_security_group" "selenium_hub_sg" { name = "selenium-grid-hub-sg" description = "This is selenium grid hub" terraform.tfvars aws_ssh_admin_key_file = "keys/aws_terraform.pub" aws_ssh_private_key = "keys/aws_terraform" aws_region = "us-east-1" aws_ami="ami-9887c6e7" #centos Image for Hub aws_instance_type="t2.micro" 7
  8. 8. Basic CLI usage + aws_security_group.selenium_hub_sg id: <computed> arn: <computed> description: "This is selenium grid egress.#: "1" egress.482069346.cidr_blocks.#: "1" egress.482069346.cidr_blocks.0: "0.0.0.0/0" egress.482069346.description: "" egress.482069346.from_port: "0" egress.482069346.ipv6_cidr_blocks.#: "0" egress.482069346.prefix_list_ids.#: "0" egress.482069346.protocol: "-1" egress.482069346.security_groups.#: "0" egress.482069346.self: "false" egress.482069346.to_port: "0" ingress.#: <computed> name: "selenium-grid-hub-sg" owner_id: <computed> revoke_rules_on_delete: "false" vpc_id: "vpc-1c3dae64" Plan: 6 to add, 0 to change, 0 to destroy. terraform plan aws_instance.winrm: Still creating... (10s elapsed) aws_instance.winrm: Still creating... (20s elapsed) aws_instance.winrm: Still creating... (30s elapsed) aws_instance.winrm: Still creating... (40s elapsed) aws_instance.winrm: Still creating... (50s elapsed) aws_instance.winrm: Still creating... (1m0s elapsed) aws_instance.winrm: Still creating... (1m10s elapsed) aws_instance.winrm: Still creating... (1m20s elapsed) aws_instance.winrm: Creation complete after 1m23s (ID: i-0b Apply complete! Resources: 1 added, 0 changed, 0 destroyed. terraform apply terraform destory aws_instance.winrm: Destroying... (ID: i-0ba353fa054 aws_instance.winrm: Still destroying... (ID: i-0ba35 aws_instance.winrm: Still destroying... (ID: i-0ba35 aws_instance.winrm: Still destroying... (ID: i-0ba35 aws_instance.winrm: Still destroying... (ID: i-0ba35 aws_instance.winrm: Still destroying... (ID: i-0ba35 aws_instance.winrm: Still destroying... (ID: i-0ba35 aws_instance.winrm: Still destroying... (ID: i-0ba35 aws_instance.winrm: Still destroying... (ID: i-0ba35 aws_instance.winrm: Destruction complete after 1m28s Destroy complete! Resources: 1 destroyed. terraform destroy 8
  9. 9. Problem Statement: How to manage Selenium Grid using Terraform? 9
  10. 10. selenium hub and nodes  jenkins->packer->ansible->terrafrom->aws->selenium 10
  11. 11. DEMODEMO 11
  12. 12.  YouTube: Link 12
  13. 13. References 1. https://github.com/SeleniumHQ/selenium/wiki/Grid2 2. https://www.seleniumhq.org/docs/07_selenium_grid.jsp 3. https://www.terraform.io/ 4. https://github.com/omkarkhatavkar/terraform-selenium- aws 13
  14. 14. THANK YOUTHANK YOU Questions ?   14

×