diff --git a/.flake8 b/.flake8 deleted file mode 100644 index 98bed35..0000000 --- a/.flake8 +++ /dev/null @@ -1,4 +0,0 @@ -[flake8] -ignore = E203, E266, E501, W503, F403, F401, W292, E402, W391, W293 -max-line-length = 79 -max-complexity = 18 diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml deleted file mode 100644 index 5da0114..0000000 --- a/.pre-commit-config.yaml +++ /dev/null @@ -1,9 +0,0 @@ -repos: - - repo: https://github.com/pre-commit/pre-commit-hooks - rev: v2.3.0 - hooks: - - id: check-yaml - - id: trailing-whitespace - - id: flake8 - - id: check-merge-conflict - - id: detect-aws-credentials \ No newline at end of file diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index becfdef..0000000 --- a/.travis.yml +++ /dev/null @@ -1,25 +0,0 @@ -language: python - -dist: - - "xenial" - -python: - - "3.7" - -install: - - pip install -r requirements.txt - -script: - - tox -v -e py - -after_success: - - python deploy-ghpages.py - -deploy: - provider: pypi - user: teaglebuilt - password: - secure: "lOVVg02Ipe1sSvWQG3CxOyLKnaYR7MvUXEhT7aB8DhvdA9jf2hDlKrdsYDkj6usr7nHQPvKU+k4Cayqo1cE6L1gnvpgCCdolOgXzBP6mF12+PL0eTw5U4F3J4XuOgCziZJpFARDILjR2r34t1ZgWEvv/DpXbufuIGapNumS5TMuB9sbRWReBfil8z7bepytBVoJbR20cpdhgLvL/bp79OOcKZxPlLDU0X36HkXLsBRahWDgTopfsJzPao+YD2n9NmAcKrzAxt3Xv6Es4AiTLBErdQSUAnCv0OfQTkjLTAYp6cflpK64CLUVLLqjqmWt3Hn/PjOsgvkEoc4aolQZQfCruPIwpc2M61vY/sC1egj1Hof+btBNpGO2F1UrUHHLaIX/se/XPwb9lo3tgeViNxI3Ef4o5MS3Lc7kpJnechg/y5zKn85t5dp9vEKQFirKO7l68xeuHQYdupD8/uvOAed9YsMTWOLsaY/YkXDtJFI9q8UDVvi5amEtoPvv+lWeD+FJDz7vXe8JEGvSh2+iU7j/MoG3Fru4tKdhm4+1V/qNDJqs8Sl13A8EJ0bP0L0cgNz18tfPg1PXfpUvQAF2ZQ3UHUO48qtHQ1gtdNCnsWBr4PFpHyJOQ9GzeeJVZB6eKw3+7b6668l+OTLTj6QJq128CD3zIOMNhx15G7oUll3I=" - skip_cleanup: true - on: - tags: true \ No newline at end of file diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 1c2f50d..ff673f9 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -1,113 +1,71 @@ -# ***** 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. +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. - -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 ``` +Then you can use inside robot, the endpoint http://localhost:4566 -set environment variables for aws as ACCESS_KEY and SECRET_KEY +### Robot Framework -install package development setup from root directory where setup.py is +The tests suites are inside tests/robot folder -```sh -pip install -e . -``` - -## TESTING +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. -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. +Any extra file like txt, json, csv or similar should be inside data folder. -Robot Tests will need a configuration file added to the root of robot/ for tests to run. - -`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 - -## VIRTUAL DISPLAY --v USE_XVFB:True - -## PROXY --v USE_PROXY:False --v PROXY_TYPE:socks --v PROXY_HOST:localhost --v PROXY_PORT:9999 - -## VARIABLES --v ACCESS_KEY: --v SECRET_KEY: - -testsuites/ -``` - -## Local AWS Services with Localstack - -```sh -docker-compose up -d - +*** Settings *** +Resource common.resource +Suite Setup Create Session And Set Endpoint +Suite Teardown Delete All Sessions ``` - +All the libraries import should be in common.resource, as the suite setup. -Make sure and add your aws credentials in the variables section. +```robotframework +*** Settings *** +Library ${CURDIR}/../../src/AWSLibrary +Library Collections +Library OperatingSystem -Unit tests and Robot Tests are automated with tox. You can run tox to test your build before committing your changes -```sh -tox +*** 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 ``` -Upon pushing your branch. Tox will run and travis ci will run the reports - -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 +### TO-DO -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 +* Create CloudWatch and DynamoDB in localstack and create robot tests +* Add more services in library and in localstack +* Add robot tests for this new services +* Create GitHub actions to run the tests in push and merges. diff --git a/Dockerfile b/Dockerfile deleted file mode 100644 index 02460bd..0000000 --- a/Dockerfile +++ /dev/null @@ -1,76 +0,0 @@ - -FROM localstack/java-maven-node-python - -# install basic tools -RUN pip install awscli awscli-local requests --upgrade -RUN apk add iputils - -# add files required to run "make install" -ADD Makefile requirements.txt ./ -RUN mkdir -p localstack/utils/kinesis/ && mkdir -p localstack/services/ && \ - touch localstack/__init__.py localstack/utils/__init__.py localstack/services/__init__.py localstack/utils/kinesis/__init__.py -ADD localstack/constants.py localstack/config.py localstack/ -ADD localstack/services/install.py localstack/services/ -ADD localstack/utils/common.py localstack/utils/bootstrap.py localstack/utils/ -ADD localstack/utils/aws/ localstack/utils/aws/ -ADD localstack/utils/kinesis/ localstack/utils/kinesis/ -ADD localstack/ext/ localstack/ext/ - -# install dependencies -RUN make install - -# add files required to run "make init" -ADD localstack/package.json localstack/package.json -ADD localstack/services/__init__.py localstack/services/install.py localstack/services/ - -# initialize installation (downloads remaining dependencies) -RUN make init - -# (re-)install web dashboard dependencies (already installed in base image) -ADD localstack/dashboard/web localstack/dashboard/web -RUN make install-web - -# install supervisor config file and entrypoint script -ADD bin/supervisord.conf /etc/supervisord.conf -ADD bin/docker-entrypoint.sh /usr/local/bin/ - -# expose service & web dashboard ports -EXPOSE 4567-4597 8080 - -# define command at startup -ENTRYPOINT ["docker-entrypoint.sh"] - -# expose default environment (required for aws-cli to work) -ENV MAVEN_CONFIG=/opt/code/localstack \ - USER=localstack \ - PYTHONUNBUFFERED=1 - -# clean up and prepare for squashing the image -RUN apk del --purge git -RUN pip uninstall -y awscli boto3 botocore localstack_client idna s3transfer -RUN rm -rf /tmp/* /root/.cache /opt/yarn-v1.15.2; mkdir -p /tmp/localstack -RUN ln -s /opt/code/localstack/.venv/bin/aws /usr/bin/aws -ENV PYTHONPATH=/opt/code/localstack/.venv/lib/python3.7/site-packages - -# add rest of the code -ADD localstack/ localstack/ -ADD bin/localstack bin/localstack - -# fix some permissions and create local user -RUN mkdir -p /.npm && \ - mkdir -p localstack/infra/elasticsearch/data && \ - mkdir -p localstack/infra/elasticsearch/logs && \ - chmod 777 . && \ - chmod 755 /root && \ - chmod -R 777 /.npm && \ - chmod -R 777 localstack/infra/elasticsearch/config && \ - chmod -R 777 localstack/infra/elasticsearch/data && \ - chmod -R 777 localstack/infra/elasticsearch/logs && \ - chmod -R 777 /tmp/localstack && \ - adduser -D localstack && \ - chown -R localstack:localstack . /tmp/localstack && \ - ln -s `pwd` /tmp/localstack_install_dir - -# run tests (to verify the build before pushing the image) -ADD tests/ tests/ -RUN LAMBDA_EXECUTOR=local make test \ No newline at end of file diff --git a/README.md b/README.md index 8dc2b77..56fe012 100644 --- a/README.md +++ b/README.md @@ -68,7 +68,4 @@ Test Case ### Attention Contributors -The project development contribution session and local testing with "localstack" is under construction and needs to be -reviewed, contributions are welcome. - [Contribution guidelines for this project](CONTRIBUTING.md) diff --git a/deploy-ghpages.py b/deploy-ghpages.py deleted file mode 100644 index 64f4534..0000000 --- a/deploy-ghpages.py +++ /dev/null @@ -1,39 +0,0 @@ -""" -Travis CI Script For generating libdoc for robotpageobjects.Page and publishing it -""" -from os import getenv, chdir -from re import sub -from subprocess import check_output, check_call -from tempfile import mkdtemp -from shutil import rmtree -import os - -if getenv('TRAVIS_REPO_SLUG') != 'teaglebuilt/robotframework-AWS': - print("Repo is a fork, not building docs") - exit() - -if getenv('TRAVIS_BRANCH') != 'master': - print("Branch is not master, not building docs") - exit() - -if getenv('TRAVIS_PULL_REQUEST') != 'false': - print("Pull request detected, not building docs") - exit() - -repo = check_output("git config remote.origin.url", shell=True) -repo = sub(r'^git:', 'https:', repo.decode()).strip() -deploy_url = sub(r'https://', 'https://%s@' % getenv('GIT_TOKEN'), repo) -deploy_branch = 'gh-pages' -rev = check_output("git rev-parse HEAD", shell=True).strip() -dir = mkdtemp() -check_call("git clone --branch %s %s %s" % (deploy_branch, repo, dir), shell=True) -chdir(dir) -check_call("python -m robot.libdoc -n robotframework-aws AWSLibrary index.html", shell=True) -print("Docs built successfully") -check_call("git config user.name '%s'" % getenv('GIT_NAME'), shell=True) -check_call("git config user.email '%s'" % getenv('GIT_EMAIL'), shell=True) -check_call("git commit -m 'Built from %s' index.html" % rev, shell=True) -check_call("git push -q %s %s" % (deploy_url, deploy_branch), shell=True) -chdir(getenv('TRAVIS_BUILD_DIR')) -rmtree(dir) -print("Docs pushed successfully") diff --git a/tests/robot/data.resource b/tests/robot/common.resource similarity index 99% rename from tests/robot/data.resource rename to tests/robot/common.resource index 3ca3623..142fba9 100644 --- a/tests/robot/data.resource +++ b/tests/robot/common.resource @@ -3,6 +3,7 @@ Library ${CURDIR}/../../src/AWSLibrary Library Collections Library OperatingSystem + *** Variables *** ${REGION} us-east-1 ${ACCESS_KEY} dummy diff --git a/tests/robot/s3.robot b/tests/robot/s3.robot index 02ad38f..a7a9f48 100644 --- a/tests/robot/s3.robot +++ b/tests/robot/s3.robot @@ -1,5 +1,5 @@ *** Settings *** -Resource data.resource +Resource common.resource Suite Setup Create Session And Set Endpoint Suite Teardown Delete All Sessions diff --git a/tests/robot/sqs.robot b/tests/robot/sqs.robot index 4594900..d8854c4 100644 --- a/tests/robot/sqs.robot +++ b/tests/robot/sqs.robot @@ -1,5 +1,5 @@ *** Settings *** -Resource data.resource +Resource common.resource Suite Setup Create Session And Set Endpoint Suite Teardown Delete All Sessions @@ -11,6 +11,7 @@ ${INVALID_QUEUE} invalid-queueName *** Test Cases *** Send and Recieve Message + [Tags] sqs Send Message To SQS ${QUEUE_NAME} Hello world! Sleep 2 ${messages} Receive Messages From SQS ${QUEUE_NAME} @@ -20,6 +21,7 @@ Send and Recieve Message Should Be Equal ${actual_value} Hello world! Invalid Queue Name + [Tags] sqs TRY Send Message To SQS ${INVALID_QUEUE} Hello world! EXCEPT AS ${error} @@ -28,6 +30,7 @@ Invalid Queue Name Should Be Equal ${error} Queue name '${INVALID_QUEUE}' not found. Delete Messages + [Tags] sqs Delete All Messages In SQS ${QUEUE_NAME} ${messages} Receive Messages From SQS ${QUEUE_NAME} ${count} Get Length ${messages}