{"action":"created","issue":{"url":"https://api.github.com/repos/twingly/ecco/issues/3","labels_url":"https://api.github.com/repos/twingly/ecco/issues/3/labels{/name}","comments_url":"https://api.github.com/repos/twingly/ecco/issues/3/comments","events_url":"https://api.github.com/repos/twingly/ecco/issues/3/events","html_url":"https://github.com/twingly/ecco/pull/3","id":116140648,"number":3,"title":"Add integration tests","user":{"login":"roback","id":2803721,"avatar_url":"https://avatars.githubusercontent.com/u/2803721?v=3","gravatar_id":"","url":"https://api.github.com/users/roback","html_url":"https://github.com/roback","followers_url":"https://api.github.com/users/roback/followers","following_url":"https://api.github.com/users/roback/following{/other_user}","gists_url":"https://api.github.com/users/roback/gists{/gist_id}","starred_url":"https://api.github.com/users/roback/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/roback/subscriptions","organizations_url":"https://api.github.com/users/roback/orgs","repos_url":"https://api.github.com/users/roback/repos","events_url":"https://api.github.com/users/roback/events{/privacy}","received_events_url":"https://api.github.com/users/roback/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":7,"created_at":"2015-11-10T16:16:57Z","updated_at":"2015-11-18T09:40:28Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/twingly/ecco/pulls/3","html_url":"https://github.com/twingly/ecco/pull/3","diff_url":"https://github.com/twingly/ecco/pull/3.diff","patch_url":"https://github.com/twingly/ecco/pull/3.patch"},"body":"Tested it with freebsd-mysql vagrant machine from ansible.\r\n\r\nRequires the environment variables `DATABASE_URL`, `DATABASE_USER` and `DATABASE_PASS` because the JDBC adapter for sequel didn't like `username:password` inside the url for some reason :confused:.\r\n\r\n* Add #stop method to Ecco::Client to be able to stop it when testing.\r\n* Two helper classes:\r\n  * DatabaseHelper - Inserts/updates/deletes table rows\r\n  * TestHelper - Starts/stops ecco and returns the received row event\r\n* Integration tests which checks that #on_row_event receives the correct type.\r\n\r\n### Todo\r\n\r\n- [x] MySQL with replication enabled on Travis\r\n- [x] Vagrantfile\r\n- [x] Documentation\r\n- [x] Do not run integration tests by default\r\n- [x] More tests\r\n  - [x] Ensure that database/table information is correct\r\n  - [x] Ensure that we can handle file rotations\r\n  - [x] Set and get public properties\r\n- [x] Remove duplicated code if possible\r\n- [ ] Test for `client.stop`, `client.start` and `client.start_in_thread` (they are already tested implicitly in most of the tests)\r\n\r\nclose #2 "},"comment":{"url":"https://api.github.com/repos/twingly/ecco/issues/comments/157657911","html_url":"https://github.com/twingly/ecco/pull/3#issuecomment-157657911","issue_url":"https://api.github.com/repos/twingly/ecco/issues/3","id":157657911,"user":{"login":"roback","id":2803721,"avatar_url":"https://avatars.githubusercontent.com/u/2803721?v=3","gravatar_id":"","url":"https://api.github.com/users/roback","html_url":"https://github.com/roback","followers_url":"https://api.github.com/users/roback/followers","following_url":"https://api.github.com/users/roback/following{/other_user}","gists_url":"https://api.github.com/users/roback/gists{/gist_id}","starred_url":"https://api.github.com/users/roback/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/roback/subscriptions","organizations_url":"https://api.github.com/users/roback/orgs","repos_url":"https://api.github.com/users/roback/repos","events_url":"https://api.github.com/users/roback/events{/privacy}","received_events_url":"https://api.github.com/users/roback/received_events","type":"User","site_admin":false},"created_at":"2015-11-18T09:40:28Z","updated_at":"2015-11-18T09:40:28Z","body":"Tried adding a test for the blocking `client#start` method:\r\n\r\n```ruby\r\n  describe \"#start\" do\r\n    let(:sleep_seconds) { 3 }\r\n    let(:seconds_blocked) do\r\n      Benchmark.realtime { subject.start }\r\n    end\r\n\r\n    it \"should block the current thread until its stopped\" do\r\n      event_thread = Thread.new do\r\n        sleep sleep_seconds\r\n        DatabaseHelper.insert(table_name, mysql_row)\r\n      end\r\n\r\n      # Stop client on first event\r\n      subject.on_row_event do\r\n        subject.stop\r\n      end\r\n\r\n      expect(seconds_blocked.round).to eq(sleep_seconds)\r\n\r\n      event_thread.join\r\n    end\r\n  end\r\n```\r\n\r\nbut that failed:\r\n\r\n```\r\n  1) Ecco::Client#start should block the current thread until its stopped\r\n     Failure/Error: expect(seconds_blocked.round).to eq(sleep_seconds)\r\n\r\n       expected: 3\r\n            got: 16\r\n\r\n       (compared using ==)\r\n     # ./spec/integration/client_spec.rb:49:in `block in (root)'\r\n```\r\n\r\nIt looks like the `DatabaseHelper.insert` method doesn't work correctly when using threads. I timed it and it took between `1-30` seconds to run. :confused: "}}