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

Including Hub Server for integration tests #13

Closed
4 tasks
th0mas opened this issue Aug 5, 2020 · 10 comments
Closed
4 tasks

Including Hub Server for integration tests #13

th0mas opened this issue Aug 5, 2020 · 10 comments
Labels
enhancement New feature or request priority-2 Second highest priority, should be worked on as soon as the Priority-1 issues are finished

Comments

@th0mas
Copy link
Collaborator

th0mas commented Aug 5, 2020

To be able to properly run integration tests against the dwyl/smart-home-* stack we should include the Hub server in our test environment so we can test against it.

This has several benefits:

  • No need to mock a hub client. We can use our actual hub client and run tests to make sure this is functioning as expected. This avoids any errors with our Mock implementation and makes the tests less complex to maintain.

  • Test the internal API. By testing against our actual hub server, we have the added benefit of checking our internal websocket api still works and we haven't accidentally created any breaking changes.

  • Integration tests across the whole stack. We can make sure our entire stack functions as expected by running integration tests that encompass the whole stack.


TODO:

  • Add Hub dependencies to travis - postgresql, dwyl_auth key etc.
  • Add hub server to travis through git(?)
  • Rewrite existing unit tests to use the real hub not our mock client
  • Write thorough integration tests across the whole stack.
@th0mas th0mas added the enhancement New feature or request label Aug 5, 2020
@th0mas
Copy link
Collaborator Author

th0mas commented Aug 5, 2020

Notes:

We don't have to run our hub as a separate process -- we can import the Phoenix endpoint and run in the same BEAM instance - this will give us more control over the tests. It does, however, tie the tests together and means the projects can no longer be tested "separately"

@nelsonic nelsonic added the priority-2 Second highest priority, should be worked on as soon as the Priority-1 issues are finished label Aug 6, 2020
@th0mas th0mas linked a pull request Aug 6, 2020 that will close this issue
@th0mas
Copy link
Collaborator Author

th0mas commented Aug 6, 2020

We need to remember to give our install scripts executable permissions with chmod +x $SCRIPT.sh

@th0mas
Copy link
Collaborator Author

th0mas commented Aug 6, 2020

Installing the hub server on travis results in a hang after database migrations:

No output has been received in the last 10m0s, this potentially indicates a stalled build or something wrong with the build itself.
Check the details on how to adjust your build configuration on: https://docs.travis-ci.com/user/common-build-problems/#build-times-out-because-no-output-was-received

I'm not sure why
We use exactly the same install process for the hub server tests and that works

@th0mas
Copy link
Collaborator Author

th0mas commented Aug 6, 2020

We need to run the hub server as a background process: mix phx.server &.

This means that travis doesn't exit however as it waits for background processes to finish first...

@th0mas
Copy link
Collaborator Author

th0mas commented Aug 6, 2020

Caching our hub deps breaks git clone as you must clone into an empty directory.

To get around this I'm copying the cached deps in and out of a temporary directory and runtime. E.g. to cache the dependencies at the end of the build process:

- mkdir smart-home-auth-server-deps
- cp -R smart-home-auth-server/deps/* smart-home-auth-server-deps

@th0mas
Copy link
Collaborator Author

th0mas commented Aug 6, 2020

creating directory /home/travis/build/dwyl/smart-home-firmware/smart-home-auth-server-deps
...
cp: cannot stat 'smart-home-auth-server-deps/*': No such file or directory

what

@th0mas
Copy link
Collaborator Author

th0mas commented Aug 6, 2020

The hub client process can't connect on travis, i'm not sure why as all ports etc should be the same....

@th0mas
Copy link
Collaborator Author

th0mas commented Aug 6, 2020

Going to try and read our hub logs with tail -f /proc/$SERVER_PID/fd/1

@th0mas
Copy link
Collaborator Author

th0mas commented Aug 6, 2020

Multi-container workflows seem to be supported on Circle Ci....

https://circleci.com/blog/setting-up-tricky-containers-in-circle-2-0-multi-image/

@th0mas
Copy link
Collaborator Author

th0mas commented Aug 19, 2020

Worked around with dwyl/smart-home-auth-server#14

@th0mas th0mas closed this as completed Aug 19, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request priority-2 Second highest priority, should be worked on as soon as the Priority-1 issues are finished
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants