In this project, we'll develop and demonstrate our skills in using a variety of industry leading tools, especially Microsoft Azure, to create disposable test environments and run a variety of automated tests with the click of a button. Additionally, we'll monitor and provide insight into our application's behavior, and determine root causes by querying the application’s custom log files.
Instructions for how to get a copy of the project running on your local machine.
The following dependecies of the project are needed;
-
Download the latest Chrome driver. You will also need to add the chromedriver to PATH.
pip install -U selenium sudo apt-get install -y chromium-browser
Execute the
/automatedtesting/selenium/login.py
file to open the demo site.
Altogether, our pipeline will create a number of resources:
✅ A resource group
✅ An App Service
✅ A Virtual Network
✅ A Network Security Group
✅ A Virtual Machine
Our demo REST API is deployed as part of our App Service, and our tests are executed against the REST API from the virtual machine created by Terraform as part of the CI/CD pipeline.
Step by step explanation of how to get a dev environment running.
List out the steps
To get started, we have firstly to loging to azure over
az login
1- Replace the subscription variable values in the Terraform/terraform.tfvars based on the provided information by Azure Credentials:
subscription_id = "xxxx"
client_id = "xxxx"
client_secret = "xxxx"
tenant_id = "xxxx"
2- Update the resource Group and Location variables in Terraform/terraform.tfvars:
location = "East US"
resource_group_name = "Azuredevops"
application_type = "myApplication"
for Terraform to save its state when run as a part of the CI/CD pipeline later. Here are the commands for Mac/Linux users:
chmod +x configure-tfstate-storage-account.sh
./configure-tfstate-storage-account.sh
Replace the values below in main.tf with the output from the Azure CLI.
terraform {
backend "azurerm" {
storage_account_name = "tstatexxxx"
container_name = "tfstate"
key = "test.terraform.tfstate"
access_key = "xxxx"
}
}
Update the terraform/modules/vm/input.tf file with the variables/values. Verify/update the terraform/modules/vm/vm.tf file with the variables declared in the input.tf. Once your VM will be ready using the final pipeline, you will have to SSH log into the machine to run Selenium functional (UI) tests. For SSH into the VM, either have an "admin_username/admin_password" pair in the vm.tf file or use SSH key pair, as explained in the next point.
Run Terraform Commands Ensure the variables in the input.tf files are properly referenced in the modules and main.tf file. Ensure the values from the terraform.tfvars file are properly referenced in the main.tf file.
After you have checked the main.tf and all modules in the terraform/modules/ directory, you can run these commands in your local terminal to deploy an Ubuntu Linux VM and the associated resources (vNetwork, security group, app service, and a public IP):
## Assuming you are in the terraform/environments/test/ directory
terraform init
## Run "terraform init -upgrade" if you have changed the file contents/path
terraform plan
terraform apply
You should see a successful deployment message, and your Azure portal should have the following resources, as shown in the snapshot below.
Here, we have the deployment message.
Here, we destroy the resources as we will deploy them again using the CI/CD Pieline.
terraform destroy
The objective of this step is to set up a minimalistic DevOps pipeline to ensure the pipeline is set up correctly, before adding multiple stages to it.
The main steps are:
- create Azure project and Service Connection
- Create an Agent Pool and an Agent
- Configure the Agent (VM) - Install Docker
- Configure the Agent (VM) - Install Agent Services
- Create a DevOps Pipeline (Connect to GitHub repository, Select the GitHub Repository, Configure the Existing Azure Pipelines YAML file, and Edit/Review the azure-pipeline.yaml)
Explain the steps needed to run any automated tests
Explain what each test does and why
Examples here
This section should contain all the student deliverables for this project.
Include all items used to build project.