{"action":"created","comment":{"url":"https://api.github.com/repos/mozilla/telemetry-analysis-service/pulls/comments/85102516","pull_request_review_id":5836543,"id":85102516,"diff_hunk":"@@ -246,3 +246,55 @@ def test_spark_job_second_run(now, test_user):\n         created_by=test_user,\n     )\n     assert spark_job_second_run.should_run(at_time=now)\n+\n+\n+def test_spark_job_is_expired(now, test_user):\n+    spark_job = models.SparkJob.objects.create(\n+        identifier='test-spark-job-6',\n+        notebook_s3_key=u's3://test/test-notebook.ipynb',\n+        result_visibility='private',\n+        size=5,\n+        interval_in_hours=1,\n+        job_timeout=12,\n+        start_date=now - timedelta(days=1),\n+        created_by=test_user,\n+    )\n+    # A spark job cannot expire if:\n+    # it doesn't have a jobflow_id OR\n+    # it doesn't have a a last_run_date OR\n+    # its most_recent_status is not RUNNING OR\n+    # it hasn't run for more than its timeout\n+\n+    timeout_run_date = now - timedelta(hours=12)\n+    jobflow_id = 'my-jobflow-id'\n+    running_status = 'RUNNING'\n+\n+    # No jobflow_id\n+    spark_job.current_run_jobflow_id = ''\n+    spark_job.last_run_date = timeout_run_date\n+    spark_job.most_recent_status = running_status\n+    assert not spark_job.is_expired(at_time=now)\n+\n+    # No last_run_date\n+    spark_job.current_run_jobflow_id = jobflow_id\n+    spark_job.last_run_date = None\n+    spark_job.most_recent_status = running_status\n+    assert not spark_job.is_expired(at_time=now)\n+\n+    # Most_recent_status != RUNNING\n+    spark_job.current_run_jobflow_id = jobflow_id\n+    spark_job.last_run_date = timeout_run_date\n+    spark_job.most_recent_status = \"NOT RUNNING\"\n+    assert not spark_job.is_expired(at_time=now)\n+\n+    # It hasn't run for more than its timeout\n+    spark_job.current_run_jobflow_id = jobflow_id\n+    spark_job.last_run_date = timeout_run_date + timedelta(seconds=1)\n+    spark_job.most_recent_status = running_status\n+    assert not spark_job.is_expired(at_time=now)\n+\n+    # All the conditions are met\n+    spark_job.current_run_jobflow_id = jobflow_id\n+    spark_job.last_run_date = timeout_run_date\n+    spark_job.most_recent_status = running_status\n+    assert spark_job.is_expired(at_time=now)","path":"tests/test_jobs.py","position":100,"original_position":100,"commit_id":"223c6481e868644b74b2928c4fd6df979daa03ce","original_commit_id":"223c6481e868644b74b2928c4fd6df979daa03ce","user":{"login":"jezdez","id":1610,"avatar_url":"https://avatars.githubusercontent.com/u/1610?v=3","gravatar_id":"","url":"https://api.github.com/users/jezdez","html_url":"https://github.com/jezdez","followers_url":"https://api.github.com/users/jezdez/followers","following_url":"https://api.github.com/users/jezdez/following{/other_user}","gists_url":"https://api.github.com/users/jezdez/gists{/gist_id}","starred_url":"https://api.github.com/users/jezdez/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jezdez/subscriptions","organizations_url":"https://api.github.com/users/jezdez/orgs","repos_url":"https://api.github.com/users/jezdez/repos","events_url":"https://api.github.com/users/jezdez/events{/privacy}","received_events_url":"https://api.github.com/users/jezdez/received_events","type":"User","site_admin":false},"body":"A test is missing for not passing in `at_time`","created_at":"2016-10-26T11:35:39Z","updated_at":"2016-10-26T11:36:53Z","html_url":"https://github.com/mozilla/telemetry-analysis-service/pull/60#discussion_r85102516","pull_request_url":"https://api.github.com/repos/mozilla/telemetry-analysis-service/pulls/60","_links":{"self":{"href":"https://api.github.com/repos/mozilla/telemetry-analysis-service/pulls/comments/85102516"},"html":{"href":"https://github.com/mozilla/telemetry-analysis-service/pull/60#discussion_r85102516"},"pull_request":{"href":"https://api.github.com/repos/mozilla/telemetry-analysis-service/pulls/60"}}},"pull_request":{"url":"https://api.github.com/repos/mozilla/telemetry-analysis-service/pulls/60","id":90985123,"html_url":"https://github.com/mozilla/telemetry-analysis-service/pull/60","diff_url":"https://github.com/mozilla/telemetry-analysis-service/pull/60.diff","patch_url":"https://github.com/mozilla/telemetry-analysis-service/pull/60.patch","issue_url":"https://api.github.com/repos/mozilla/telemetry-analysis-service/issues/60","number":60,"state":"open","locked":false,"title":"Bug 1313008 - Don't delete expired jobs","user":{"login":"maurodoglio","id":508377,"avatar_url":"https://avatars.githubusercontent.com/u/508377?v=3","gravatar_id":"","url":"https://api.github.com/users/maurodoglio","html_url":"https://github.com/maurodoglio","followers_url":"https://api.github.com/users/maurodoglio/followers","following_url":"https://api.github.com/users/maurodoglio/following{/other_user}","gists_url":"https://api.github.com/users/maurodoglio/gists{/gist_id}","starred_url":"https://api.github.com/users/maurodoglio/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/maurodoglio/subscriptions","organizations_url":"https://api.github.com/users/maurodoglio/orgs","repos_url":"https://api.github.com/users/maurodoglio/repos","events_url":"https://api.github.com/users/maurodoglio/events{/privacy}","received_events_url":"https://api.github.com/users/maurodoglio/received_events","type":"User","site_admin":false},"body":"No jobs should be deleted without their owner's consent.\nThis patch also fixes a couple of issues with the expiration logic,\nnamely:\n - the last_run_date vs timeout check was wrong\n - only RUNNING jobs should be terminated because of a timeout","created_at":"2016-10-26T11:25:44Z","updated_at":"2016-10-26T11:36:53Z","closed_at":null,"merged_at":null,"merge_commit_sha":"97191fd5f16971d5c6aaaca9ab8c6c92a84c7581","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/mozilla/telemetry-analysis-service/pulls/60/commits","review_comments_url":"https://api.github.com/repos/mozilla/telemetry-analysis-service/pulls/60/comments","review_comment_url":"https://api.github.com/repos/mozilla/telemetry-analysis-service/pulls/comments{/number}","comments_url":"https://api.github.com/repos/mozilla/telemetry-analysis-service/issues/60/comments","statuses_url":"https://api.github.com/repos/mozilla/telemetry-analysis-service/statuses/223c6481e868644b74b2928c4fd6df979daa03ce","head":{"label":"mozilla:bug-1313008-terminate-expired-jobs","ref":"bug-1313008-terminate-expired-jobs","sha":"223c6481e868644b74b2928c4fd6df979daa03ce","user":{"login":"mozilla","id":131524,"avatar_url":"https://avatars.githubusercontent.com/u/131524?v=3","gravatar_id":"","url":"https://api.github.com/users/mozilla","html_url":"https://github.com/mozilla","followers_url":"https://api.github.com/users/mozilla/followers","following_url":"https://api.github.com/users/mozilla/following{/other_user}","gists_url":"https://api.github.com/users/mozilla/gists{/gist_id}","starred_url":"https://api.github.com/users/mozilla/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mozilla/subscriptions","organizations_url":"https://api.github.com/users/mozilla/orgs","repos_url":"https://api.github.com/users/mozilla/repos","events_url":"https://api.github.com/users/mozilla/events{/privacy}","received_events_url":"https://api.github.com/users/mozilla/received_events","type":"Organization","site_admin":false},"repo":{"id":51290886,"name":"telemetry-analysis-service","full_name":"mozilla/telemetry-analysis-service","owner":{"login":"mozilla","id":131524,"avatar_url":"https://avatars.githubusercontent.com/u/131524?v=3","gravatar_id":"","url":"https://api.github.com/users/mozilla","html_url":"https://github.com/mozilla","followers_url":"https://api.github.com/users/mozilla/followers","following_url":"https://api.github.com/users/mozilla/following{/other_user}","gists_url":"https://api.github.com/users/mozilla/gists{/gist_id}","starred_url":"https://api.github.com/users/mozilla/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mozilla/subscriptions","organizations_url":"https://api.github.com/users/mozilla/orgs","repos_url":"https://api.github.com/users/mozilla/repos","events_url":"https://api.github.com/users/mozilla/events{/privacy}","received_events_url":"https://api.github.com/users/mozilla/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/mozilla/telemetry-analysis-service","description":"Telemetry Analysis Service","fork":false,"url":"https://api.github.com/repos/mozilla/telemetry-analysis-service","forks_url":"https://api.github.com/repos/mozilla/telemetry-analysis-service/forks","keys_url":"https://api.github.com/repos/mozilla/telemetry-analysis-service/keys{/key_id}","collaborators_url":"https://api.github.com/repos/mozilla/telemetry-analysis-service/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/mozilla/telemetry-analysis-service/teams","hooks_url":"https://api.github.com/repos/mozilla/telemetry-analysis-service/hooks","issue_events_url":"https://api.github.com/repos/mozilla/telemetry-analysis-service/issues/events{/number}","events_url":"https://api.github.com/repos/mozilla/telemetry-analysis-service/events","assignees_url":"https://api.github.com/repos/mozilla/telemetry-analysis-service/assignees{/user}","branches_url":"https://api.github.com/repos/mozilla/telemetry-analysis-service/branches{/branch}","tags_url":"https://api.github.com/repos/mozilla/telemetry-analysis-service/tags","blobs_url":"https://api.github.com/repos/mozilla/telemetry-analysis-service/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/mozilla/telemetry-analysis-service/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/mozilla/telemetry-analysis-service/git/refs{/sha}","trees_url":"https://api.github.com/repos/mozilla/telemetry-analysis-service/git/trees{/sha}","statuses_url":"https://api.github.com/repos/mozilla/telemetry-analysis-service/statuses/{sha}","languages_url":"https://api.github.com/repos/mozilla/telemetry-analysis-service/languages","stargazers_url":"https://api.github.com/repos/mozilla/telemetry-analysis-service/stargazers","contributors_url":"https://api.github.com/repos/mozilla/telemetry-analysis-service/contributors","subscribers_url":"https://api.github.com/repos/mozilla/telemetry-analysis-service/subscribers","subscription_url":"https://api.github.com/repos/mozilla/telemetry-analysis-service/subscription","commits_url":"https://api.github.com/repos/mozilla/telemetry-analysis-service/commits{/sha}","git_commits_url":"https://api.github.com/repos/mozilla/telemetry-analysis-service/git/commits{/sha}","comments_url":"https://api.github.com/repos/mozilla/telemetry-analysis-service/comments{/number}","issue_comment_url":"https://api.github.com/repos/mozilla/telemetry-analysis-service/issues/comments{/number}","contents_url":"https://api.github.com/repos/mozilla/telemetry-analysis-service/contents/{+path}","compare_url":"https://api.github.com/repos/mozilla/telemetry-analysis-service/compare/{base}...{head}","merges_url":"https://api.github.com/repos/mozilla/telemetry-analysis-service/merges","archive_url":"https://api.github.com/repos/mozilla/telemetry-analysis-service/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/mozilla/telemetry-analysis-service/downloads","issues_url":"https://api.github.com/repos/mozilla/telemetry-analysis-service/issues{/number}","pulls_url":"https://api.github.com/repos/mozilla/telemetry-analysis-service/pulls{/number}","milestones_url":"https://api.github.com/repos/mozilla/telemetry-analysis-service/milestones{/number}","notifications_url":"https://api.github.com/repos/mozilla/telemetry-analysis-service/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/mozilla/telemetry-analysis-service/labels{/name}","releases_url":"https://api.github.com/repos/mozilla/telemetry-analysis-service/releases{/id}","deployments_url":"https://api.github.com/repos/mozilla/telemetry-analysis-service/deployments","created_at":"2016-02-08T10:13:40Z","updated_at":"2016-10-24T12:35:57Z","pushed_at":"2016-10-26T11:25:45Z","git_url":"git://github.com/mozilla/telemetry-analysis-service.git","ssh_url":"git@github.com:mozilla/telemetry-analysis-service.git","clone_url":"https://github.com/mozilla/telemetry-analysis-service.git","svn_url":"https://github.com/mozilla/telemetry-analysis-service","homepage":"","size":994,"stargazers_count":3,"watchers_count":3,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":5,"mirror_url":null,"open_issues_count":3,"forks":5,"open_issues":3,"watchers":3,"default_branch":"master"}},"base":{"label":"mozilla:master","ref":"master","sha":"4b9b4a04ba8930e3a2f1f08f14e320a42216291d","user":{"login":"mozilla","id":131524,"avatar_url":"https://avatars.githubusercontent.com/u/131524?v=3","gravatar_id":"","url":"https://api.github.com/users/mozilla","html_url":"https://github.com/mozilla","followers_url":"https://api.github.com/users/mozilla/followers","following_url":"https://api.github.com/users/mozilla/following{/other_user}","gists_url":"https://api.github.com/users/mozilla/gists{/gist_id}","starred_url":"https://api.github.com/users/mozilla/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mozilla/subscriptions","organizations_url":"https://api.github.com/users/mozilla/orgs","repos_url":"https://api.github.com/users/mozilla/repos","events_url":"https://api.github.com/users/mozilla/events{/privacy}","received_events_url":"https://api.github.com/users/mozilla/received_events","type":"Organization","site_admin":false},"repo":{"id":51290886,"name":"telemetry-analysis-service","full_name":"mozilla/telemetry-analysis-service","owner":{"login":"mozilla","id":131524,"avatar_url":"https://avatars.githubusercontent.com/u/131524?v=3","gravatar_id":"","url":"https://api.github.com/users/mozilla","html_url":"https://github.com/mozilla","followers_url":"https://api.github.com/users/mozilla/followers","following_url":"https://api.github.com/users/mozilla/following{/other_user}","gists_url":"https://api.github.com/users/mozilla/gists{/gist_id}","starred_url":"https://api.github.com/users/mozilla/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mozilla/subscriptions","organizations_url":"https://api.github.com/users/mozilla/orgs","repos_url":"https://api.github.com/users/mozilla/repos","events_url":"https://api.github.com/users/mozilla/events{/privacy}","received_events_url":"https://api.github.com/users/mozilla/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/mozilla/telemetry-analysis-service","description":"Telemetry Analysis Service","fork":false,"url":"https://api.github.com/repos/mozilla/telemetry-analysis-service","forks_url":"https://api.github.com/repos/mozilla/telemetry-analysis-service/forks","keys_url":"https://api.github.com/repos/mozilla/telemetry-analysis-service/keys{/key_id}","collaborators_url":"https://api.github.com/repos/mozilla/telemetry-analysis-service/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/mozilla/telemetry-analysis-service/teams","hooks_url":"https://api.github.com/repos/mozilla/telemetry-analysis-service/hooks","issue_events_url":"https://api.github.com/repos/mozilla/telemetry-analysis-service/issues/events{/number}","events_url":"https://api.github.com/repos/mozilla/telemetry-analysis-service/events","assignees_url":"https://api.github.com/repos/mozilla/telemetry-analysis-service/assignees{/user}","branches_url":"https://api.github.com/repos/mozilla/telemetry-analysis-service/branches{/branch}","tags_url":"https://api.github.com/repos/mozilla/telemetry-analysis-service/tags","blobs_url":"https://api.github.com/repos/mozilla/telemetry-analysis-service/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/mozilla/telemetry-analysis-service/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/mozilla/telemetry-analysis-service/git/refs{/sha}","trees_url":"https://api.github.com/repos/mozilla/telemetry-analysis-service/git/trees{/sha}","statuses_url":"https://api.github.com/repos/mozilla/telemetry-analysis-service/statuses/{sha}","languages_url":"https://api.github.com/repos/mozilla/telemetry-analysis-service/languages","stargazers_url":"https://api.github.com/repos/mozilla/telemetry-analysis-service/stargazers","contributors_url":"https://api.github.com/repos/mozilla/telemetry-analysis-service/contributors","subscribers_url":"https://api.github.com/repos/mozilla/telemetry-analysis-service/subscribers","subscription_url":"https://api.github.com/repos/mozilla/telemetry-analysis-service/subscription","commits_url":"https://api.github.com/repos/mozilla/telemetry-analysis-service/commits{/sha}","git_commits_url":"https://api.github.com/repos/mozilla/telemetry-analysis-service/git/commits{/sha}","comments_url":"https://api.github.com/repos/mozilla/telemetry-analysis-service/comments{/number}","issue_comment_url":"https://api.github.com/repos/mozilla/telemetry-analysis-service/issues/comments{/number}","contents_url":"https://api.github.com/repos/mozilla/telemetry-analysis-service/contents/{+path}","compare_url":"https://api.github.com/repos/mozilla/telemetry-analysis-service/compare/{base}...{head}","merges_url":"https://api.github.com/repos/mozilla/telemetry-analysis-service/merges","archive_url":"https://api.github.com/repos/mozilla/telemetry-analysis-service/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/mozilla/telemetry-analysis-service/downloads","issues_url":"https://api.github.com/repos/mozilla/telemetry-analysis-service/issues{/number}","pulls_url":"https://api.github.com/repos/mozilla/telemetry-analysis-service/pulls{/number}","milestones_url":"https://api.github.com/repos/mozilla/telemetry-analysis-service/milestones{/number}","notifications_url":"https://api.github.com/repos/mozilla/telemetry-analysis-service/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/mozilla/telemetry-analysis-service/labels{/name}","releases_url":"https://api.github.com/repos/mozilla/telemetry-analysis-service/releases{/id}","deployments_url":"https://api.github.com/repos/mozilla/telemetry-analysis-service/deployments","created_at":"2016-02-08T10:13:40Z","updated_at":"2016-10-24T12:35:57Z","pushed_at":"2016-10-26T11:25:45Z","git_url":"git://github.com/mozilla/telemetry-analysis-service.git","ssh_url":"git@github.com:mozilla/telemetry-analysis-service.git","clone_url":"https://github.com/mozilla/telemetry-analysis-service.git","svn_url":"https://github.com/mozilla/telemetry-analysis-service","homepage":"","size":994,"stargazers_count":3,"watchers_count":3,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":5,"mirror_url":null,"open_issues_count":3,"forks":5,"open_issues":3,"watchers":3,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/mozilla/telemetry-analysis-service/pulls/60"},"html":{"href":"https://github.com/mozilla/telemetry-analysis-service/pull/60"},"issue":{"href":"https://api.github.com/repos/mozilla/telemetry-analysis-service/issues/60"},"comments":{"href":"https://api.github.com/repos/mozilla/telemetry-analysis-service/issues/60/comments"},"review_comments":{"href":"https://api.github.com/repos/mozilla/telemetry-analysis-service/pulls/60/comments"},"review_comment":{"href":"https://api.github.com/repos/mozilla/telemetry-analysis-service/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/mozilla/telemetry-analysis-service/pulls/60/commits"},"statuses":{"href":"https://api.github.com/repos/mozilla/telemetry-analysis-service/statuses/223c6481e868644b74b2928c4fd6df979daa03ce"}}}}
{"actor":{"display_login":"jezdez"}}