-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #59 from MarketSquare/samuelpcabral-test_localstac…
…k_linux test with localstack and github actions
- Loading branch information
Showing
32 changed files
with
473 additions
and
550 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
name: Run LocalStack And Execute Keyword Tests | ||
|
||
on: | ||
push: | ||
pull_request: | ||
|
||
jobs: | ||
run-localstack-and-robot: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v4 | ||
- name: Set up Docker | ||
uses: docker/setup-buildx-action@v3 | ||
- name: Install Docker Compose | ||
run: | | ||
sudo apt-get update | ||
sudo apt-get install docker-compose -y | ||
- name: Start Localstack docker | ||
working-directory: ./localstack | ||
run: | | ||
docker-compose up -d | ||
- name: Wait for LocalStack to be ready | ||
run: sleep 10 | ||
- name: Set up Python 3.10 | ||
uses: actions/setup-python@v4 | ||
env: | ||
ROBOT_TESTS_DIR: ${{ github.workspace }}/Tests | ||
ROBOT_REPORTS_DIR: ${{ github.workspace }}/reports | ||
with: | ||
python-version: '3.10' | ||
- name: Install Dependencies | ||
working-directory: ./ | ||
run: pip install -r requirements.txt | ||
- name: Run Robot Framework | ||
run: robot -d ./reports ./tests/robot | ||
- name: Upload test results | ||
uses: actions/upload-artifact@v1 | ||
if: always() | ||
with: | ||
name: robot_reports | ||
path: reports | ||
|
||
generate-robot-report: | ||
if: always() | ||
needs: [ run-localstack-and-robot ] | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Download reports | ||
uses: actions/download-artifact@v1 | ||
with: | ||
name: robot_reports | ||
- name: Send report to commit | ||
uses: joonvena/robotframework-reporter-action@v2.4 | ||
with: | ||
gh_access_token: ${{ secrets.GITHUB_TOKEN }} | ||
report_path: /robot_reports |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,113 +1,84 @@ | ||
# ***** UNDER CONSTRUCTION ***** | ||
# Development environment | ||
|
||
Feel free to create issues for ideas for new functionality with other aws services | ||
|
||
We are working to create an environment with tests in localstack https://github.com/localstack/localstack if you have | ||
experience with this tool and time, any help will be appreciated. | ||
|
||
|
||
## Contributing to RobotFramework-AWS | ||
|
||
Thank you for considering contributing to a library for interacting with AWS Services in RobotFramework for Test Automation. | ||
|
||
Let's go over setting up the development environment. | ||
Thank you for considering contributing to a library for interacting with AWS services in RobotFramework | ||
for test automation. | ||
|
||
Setup virtualenvironment: | ||
Configure your environment as desired, the requirements are in the requirements.txt file | ||
|
||
```sh | ||
python -m venv venv | ||
pip install -r requirements.txt | ||
``` | ||
|
||
activate | ||
## Testing | ||
|
||
```sh | ||
source venv/bin/activate | ||
``` | ||
### Localstack | ||
|
||
install dependencies | ||
For now, we have inside the folder localstack the docker compose file and in the init-aws.sh the commands to send | ||
for localstack. | ||
|
||
To start localstack just run inside localstack folder: | ||
```sh | ||
pip install -r requirements.txt | ||
docker-compose up -d | ||
``` | ||
Then you can use inside robot, the endpoint http://localhost:4566 | ||
|
||
set environment variables for aws as ACCESS_KEY and SECRET_KEY | ||
|
||
install package development setup from root directory where setup.py is | ||
|
||
```sh | ||
pip install -e . | ||
``` | ||
### Robot Framework | ||
|
||
## TESTING | ||
The tests suites are inside tests/robot folder | ||
|
||
For every keyword or method created, will be followed with two different tests. Unit and Robot tests. | ||
Located in the tests directory are separated tests by type unit/robot. | ||
The common variables, keywords and libraries should be in common.resource file. The tests suites have the | ||
aws module name like s3.robot or sqs.robot then we can run it separately. | ||
|
||
Robot Tests will need a configuration file added to the root of robot/ for tests to run. | ||
Any extra file like txt, json, csv or similar should be inside data folder. | ||
|
||
`run_arguments.robot` | ||
The robot files should import only the common.resource. | ||
|
||
```robotframework | ||
## SUITE NAME | ||
--name AWS Library Testing | ||
## SETTINGS | ||
# tools must be in same directory as run_arguments.robot | ||
--pythonpath ./AWSLibrary | ||
--pythonpath . | ||
# LOG LEVEL | ||
# --loglevel DEBUG | ||
--loglevel INFO | ||
# put all logs into directory | ||
--outputdir reports | ||
# --timestampoutputs | ||
--debugfile debug.log | ||
*** Settings *** | ||
Resource common.resource | ||
Suite Setup Create Session And Set Endpoint | ||
Suite Teardown Delete All Sessions | ||
``` | ||
|
||
## VIRTUAL DISPLAY | ||
-v USE_XVFB:True | ||
All the libraries import should be in common.resource, as the suite setup. The import to AWSLibrary is relative to | ||
project source, because then you can test the new keywords or changes just running locally the tests | ||
|
||
## PROXY | ||
-v USE_PROXY:False | ||
-v PROXY_TYPE:socks | ||
-v PROXY_HOST:localhost | ||
-v PROXY_PORT:9999 | ||
```robotframework | ||
*** Settings *** | ||
Library ${CURDIR}/../../src/AWSLibrary | ||
Library Collections | ||
Library OperatingSystem | ||
## VARIABLES | ||
-v ACCESS_KEY: | ||
-v SECRET_KEY: | ||
testsuites/ | ||
*** Keywords *** | ||
Create Session And Set Endpoint | ||
Create Session With Keys ${REGION} ${ACCESS_KEY} ${SECRET_KEY} | ||
SQS Set Endpoint Url http://localhost:4566 # Point to localstack sqs instance | ||
S3 Set Endpoint Url http://localhost:4566 # Point to localstack s3 instance | ||
``` | ||
|
||
## Local AWS Services with Localstack | ||
|
||
To run with debug level all tests, from the main folder: | ||
```sh | ||
docker-compose up -d | ||
|
||
robot -d log -L TRACE tests/robot | ||
``` | ||
|
||
<http://localhost:8055/> | ||
|
||
Make sure and add your aws credentials in the variables section. | ||
|
||
Unit tests and Robot Tests are automated with tox. You can run tox to test your build before committing your changes | ||
|
||
To run just one module, like s3: | ||
```sh | ||
tox | ||
robot -d log -L TRACE tests/robot/s3.robot | ||
# or | ||
robot -d log -L TRACE -i s3 tests/robot | ||
``` | ||
|
||
Upon pushing your branch. Tox will run and travis ci will run the reports | ||
### TO-DO | ||
|
||
Tox will grab the AWS environment variables that you set. which you can see in tox.ini | ||
|
||
### Pre Commit | ||
|
||
We use flake8 for checking for linting errors | ||
|
||
Git Secrets will run on commit to make sure there are no hardcoded credentials in any files | ||
|
||
Upon pushing your branch. Tox will run and travis ci will run the reports | ||
|
||
### Issues | ||
|
||
Feel free to create issues for ideas for new functionality with other aws services | ||
- [x] Create CloudWatch and DynamoDB in localstack and create robot tests | ||
- [x] Create GitHub actions to run the tests in push and merges. | ||
- [ ] Add more services in library and in localstack | ||
- [ ] Add robot tests for this new services |
Oops, something went wrong.
0bb1b6f
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Robot Results
Passed Tests
Cloudwatch
Cloudwatch
Dynamo
Dynamo
Dynamo
Dynamo
Dynamo
Dynamo
Dynamo
S3
S3
S3
S3
S3
S3
S3
Sqs
Sqs
Sqs
Sqs