fbpx

A4CloudStack

Introduction:

A4CloudStack is an easy to use python-based automation framework that can be used for performing cloud sysops functions as well as testing AWS cloud platform services.

Features:

A4CloudStack has inbuilt functions that can be leveraged for performing most of the routine functions for the below-listed services

  • IAM
  • S3
  • EC2
  • VPC
  • SSM
  • CloudWatch
  • Lambda
  • API Gateway
  • DynamoDB

Architecture:

Framework architecture

 

Libraries include the python library based on each AWS managed service. The library method calls for the functions available for the AWS service using boto3 client/resource.

There are 2 methods for one operation – the first method will call the boto function and return the response. The second method will process the response from the first method and validate the response.

Test Suites are test files with multiple test methods written. Each test method can be considered as a test script.

The test script will take the test data written in JSON format and pass on to the library methods as input arguments.

Modules have the project-specific library files.

Automation Procedure:

Let’s do automation of a test: Create an EC2 instance, check instance state as 2/2.

  1. Create test data: AWS config file has AWS credentials & EC2 test data do have data required for launching a new EC2 instance like AMI id, instance type, key name, etc. Test data files can be json files.
  2.  Driver code in the conftest file reads the test data i.e. config file and ec2 test data file. It loads the required test data files only. If there are n number of test data files, this will load only the test data files which are called from the test file.
  3. Test file: This calls for the methods written in the library file & pass on the required arguments read from test data.
  4. Library file: This has two methods for creating an instance. 
  • The first method create_instance_from_image” calls the ec2 boto client function “run_instances” and returns the response.
  • Second method “create_validate_instance_from_image” calls the first method “create_instance_from_image” and validates the response.

Two levels of validation will be implemented.

  • The first level is to validate the response from the create instance. This validates the response code as well as validates whether the response has the instance ID.
  • The second level is to get the instance information using ec2 boto client function “describe_instances” and validate the instance ID as well as for instance state as running.

Let’s see one more example of S3 service: Create an s3 bucket.

  1. Create test data: AWS config file has AWS credentials & the S3 test data file has data required for creating a new S3 bucket like bucket name, create Bucket Configuration, etc. Test data files can be json files
  2. Driver code in the conftest file reads the test data i.e. config file and S3 test data file.
  3. It loads the required test data files only. If there are n number of test data files, this will load only the test data files which are called from the test file.
  4. Test file: It calls for the methods written in the library file & pass on the required arguments read from test data
  5. Library file: This has two methods for creating S3 bucket 
  • The first method create_s3_bucket” calls the S3 boto client function “create_bucket” and it returns the response.
  • The second method “create_validate_s3_bucket” calls the first method “create_s3_bucket” and it validates the response.

Two levels of validation will be implemented.

  • The first level is to validate the response from the create S3 bucket method. This validates the response code.
  • The second level is to get the created S3 bucket using S3 boto client function and validate the bucket which is present on AWS.


Author: Tanvir
An aspiring digital marketer, a passionate singer, a guitarist and a mechanical engineer by degree. It would be so cool if I had lots of fans but the ceiling space is limited. You can find me on LinkedIn.

Leave a Reply