Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test with localstack and github actions #59

Merged
merged 41 commits into from
Aug 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
eaa5121
testing
samuelpcabral Aug 17, 2024
1c5a954
test
samuelpcabral Aug 17, 2024
69c7d2b
test
samuelpcabral Aug 17, 2024
81e120c
improve tests
samuelpcabral Aug 17, 2024
bdc5dc1
new format for tests
samuelpcabral Aug 17, 2024
abdb9d4
structure to keyword tests
samuelpcabral Aug 18, 2024
5db6279
fix
samuelpcabral Aug 18, 2024
4c48dbe
update s3 tests
samuelpcabral Aug 18, 2024
ca1124f
fix
samuelpcabral Aug 18, 2024
9e3daef
fix txt
samuelpcabral Aug 18, 2024
8c6da50
More test
samuelpcabral Aug 18, 2024
ce40259
fix
samuelpcabral Aug 18, 2024
2051d38
remove
samuelpcabral Aug 18, 2024
a6e3a32
new file
samuelpcabral Aug 18, 2024
3bda9c4
update metadata test
samuelpcabral Aug 18, 2024
fe3a742
update test and gitignore
samuelpcabral Aug 18, 2024
789fc19
remove old files and add contributions guidelines
samuelpcabral Aug 18, 2024
e08b4ca
to-do ticks
samuelpcabral Aug 18, 2024
a616968
more contributing guidelines
samuelpcabral Aug 18, 2024
0950e92
add GATEWAY_LISTEN in localstack and improve s3 and sqs tests
Aug 19, 2024
78cf133
test to create dynamo table
Aug 19, 2024
2819972
add dynamo tests
Aug 19, 2024
a73b3d5
test new table
Aug 20, 2024
ef6ac53
fix
Aug 20, 2024
7d8f7b0
update dynamo tests
Aug 20, 2024
a523958
Update dynamo tests
Aug 20, 2024
c1244ca
add logs in localstack
Aug 20, 2024
e905934
add cloudwatch tests
Aug 20, 2024
dcdce9c
fix
samuelpcabral Aug 20, 2024
56e154b
Finish version 1.0.0 tests
Aug 20, 2024
69bd16e
Merge pull request #1 from samuelpcabral/improve_localstack
samuelpcabral Aug 20, 2024
c7b7bae
Merge pull request #2 from samuelpcabral/improve_localstack
samuelpcabral Aug 20, 2024
e5e3f13
test github actions
Aug 20, 2024
08aeb9d
add apt-get
Aug 20, 2024
3b75772
add robot tests
Aug 20, 2024
f27fa29
fix
Aug 20, 2024
78c0231
fix 2
Aug 20, 2024
bb4c5df
update actions and fix test
Aug 20, 2024
0cfe927
fix robot report
Aug 20, 2024
21baab3
Merge pull request #3 from samuelpcabral/github_actions
samuelpcabral Aug 21, 2024
8b7eabd
update todo list
Aug 21, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions .flake8

This file was deleted.

57 changes: 57 additions & 0 deletions .github/workflows/run-tests.yml
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/[email protected]
with:
gh_access_token: ${{ secrets.GITHUB_TOKEN }}
report_path: /robot_reports
78 changes: 1 addition & 77 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,6 @@ __pycache__/
*.py[cod]
*$py.class

# C extensions
*.so

# Distribution / packaging
.Python
build/
Expand All @@ -34,16 +31,6 @@ share/python-wheels/
*.egg
MANIFEST

# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec

# Installer logs
pip-log.txt
pip-delete-this-directory.txt

# Unit test / coverage reports
htmlcov/
.tox/
Expand All @@ -57,79 +44,16 @@ coverage.xml
.hypothesis/
.pytest_cache/

# Translations
*.mo
*.pot

# Django stuff:
*.log
local_settings.py
db.sqlite3
db.sqlite3-journal

# Flask stuff:
instance/
.webassets-cache

# Scrapy stuff:
.scrapy

# Sphinx documentation
docs/_build/

# PyBuilder
target/

# Jupyter Notebook
.ipynb_checkpoints

# IPython
profile_default/
ipython_config.py

# pyenv
.python-version

# pipenv
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
# However, in case of collaboration, if having platform-specific dependencies or dependencies
# having no cross-platform support, pipenv may install dependencies that don't work, or not
# install all needed dependencies.
#Pipfile.lock

# celery beat schedule file
celerybeat-schedule

# SageMath parsed files
*.sage.py

# Environments
.env
.venv
env/
venv/
virtual_env/
ENV/
env.bak/
venv.bak/

# Spyder project settings
.spyderproject
.spyproject

# Rope project settings
.ropeproject

# mkdocs documentation
/site

# mypy
.mypy_cache/
.dmypy.json
dmypy.json

# Pyre type checker
.pyre/

#Pycharm
.idea
tests/robot/local_tests.robot
Expand Down
9 changes: 0 additions & 9 deletions .pre-commit-config.yaml

This file was deleted.

25 changes: 0 additions & 25 deletions .travis.yml

This file was deleted.

125 changes: 48 additions & 77 deletions CONTRIBUTING.md
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
Loading
Loading