Advertisement
Guest User

Untitled

a guest
Sep 21st, 2016
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.44 KB | None | 0 0
  1. - name: Run DB/API integration test suite
  2. hosts: localhost
  3. become: True
  4. become_method: sudo
  5.  
  6. tasks:
  7.  
  8. - name: Use PSQL to Close Postgres DB connection to the master database
  9. become: True
  10. become_user: postgres
  11. shell: psql -U postgres -c "SELECT pg_terminate_backend(pid) FROM pg_stat_activity WHERE pid <> pg_backend_pid() AND datname = '<master-db-name>';"
  12. ignore_errors: True
  13.  
  14. - name: Delete integration test database (last copy of master), if it exists
  15. postgresql_db:
  16. name: <integration-test-db-name>
  17. state: absent
  18. login_password: "{{ postgres_user_password }}"
  19. become_user: postgres
  20. ignore_errors: True
  21.  
  22. - name: Create the new integration test DB, using the master DB as a template
  23. postgresql_db:
  24. name: <integration-test-db-name>
  25. state: present
  26. template: "<master-db-name>"
  27. login_password: "{{ postgres_user_password }}"
  28. become_user: postgres
  29.  
  30. - name: Execute SQL scripts integration database that truncate/insert data and provide a "known-state"
  31. become: True
  32. become_user: postgres
  33. shell: psql -U postgres -d to_app_integration_tests -q -f /home/postgres/integration-test-setup.sql
  34. register: shell_output
  35.  
  36. - name: Search the stderr for PSQL errors, and exit if any found
  37. fail: msg="THERE WAS A PSQL ERROR"
  38. when: '"ERROR" in shell_output.stderr'
  39.  
  40. - name: Execute Mocha.js Integration Tests
  41. shell: (cd /path/to/your/api/installation && mocha )
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement