Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- - name: Run DB/API integration test suite
- hosts: localhost
- become: True
- become_method: sudo
- tasks:
- - name: Use PSQL to Close Postgres DB connection to the master database
- become: True
- become_user: postgres
- shell: psql -U postgres -c "SELECT pg_terminate_backend(pid) FROM pg_stat_activity WHERE pid <> pg_backend_pid() AND datname = '<master-db-name>';"
- ignore_errors: True
- - name: Delete integration test database (last copy of master), if it exists
- postgresql_db:
- name: <integration-test-db-name>
- state: absent
- login_password: "{{ postgres_user_password }}"
- become_user: postgres
- ignore_errors: True
- - name: Create the new integration test DB, using the master DB as a template
- postgresql_db:
- name: <integration-test-db-name>
- state: present
- template: "<master-db-name>"
- login_password: "{{ postgres_user_password }}"
- become_user: postgres
- - name: Execute SQL scripts integration database that truncate/insert data and provide a "known-state"
- become: True
- become_user: postgres
- shell: psql -U postgres -d to_app_integration_tests -q -f /home/postgres/integration-test-setup.sql
- register: shell_output
- - name: Search the stderr for PSQL errors, and exit if any found
- fail: msg="THERE WAS A PSQL ERROR"
- when: '"ERROR" in shell_output.stderr'
- - name: Execute Mocha.js Integration Tests
- shell: (cd /path/to/your/api/installation && mocha )
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement