{"action":"created","comment":{"url":"https://api.github.com/repos/elifesciences/builder/pulls/comments/183094747","pull_request_review_id":114032387,"id":183094747,"diff_hunk":"@@ -0,0 +1,128 @@\n+import os, json\n+from fabric.api import settings\n+from tests import base\n+from buildercore import bootstrap, cfngen, lifecycle, utils, core\n+from buildercore.config import BOOTSTRAP_USER\n+import cfn\n+import logging\n+\n+logging.disable(logging.NOTSET) # re-enables logging during integration testing\n+\n+# the intent here is:\n+# * launch an ec2 instance without running highstate\n+# * run any logic against it that needs a running ec2 instance\n+# * optionally leave the instance running while debugging happens\n+\n+class One(base.BaseCase):\n+    @classmethod\n+    def setUpClass(self): # cls, not self\n+        super(One, self).setUpClass()\n+\n+        # to re-use an existing stack, ensure self.reuse_existing_stack is True\n+        # this will read the instance name from a temporary file (if it exists) and\n+        # look for that, creating it if doesn't exist yet\n+        # also ensure self.cleanup is False so the instance isn't destroyed after tests complete\n+        self.reuse_existing_stack = False\n+        self.cleanup = True\n+\n+        self.stacknames = []\n+        self.environment = base.generate_environment_name()\n+        # self.temp_dir, self.rm_temp_dir = utils.tempdir()\n+\n+        # debugging only, where we keep an instance up between processes\n+        self.state, self.statefile = {}, '/tmp/.open-test-instances.txt'\n+        if self.reuse_existing_stack and os.path.exists(self.statefile):\n+            self.state = json.load(open(self.statefile, 'r'))\n+            self.environment = self.state.get('environment', self.environment)\n+\n+        self.state['environment'] = self.environment # will be saved later\n+\n+        with settings(abort_on_prompts=True):\n+            project = 'dummy1'\n+            self.stackname = '%s--%s' % (project, self.environment)\n+            self.stacknames.append(self.stackname)\n+\n+            if self.cleanup:\n+                cfn.ensure_destroyed(self.stackname)\n+\n+            self.context, self.cfn_template, _ = cfngen.generate_stack(project, stackname=self.stackname)\n+            self.region = self.context['project']['aws']['region']\n+            bootstrap.create_stack(self.stackname)\n+\n+            lifecycle.start(self.stackname)\n+\n+    @classmethod\n+    def tearDownClass(self): # cls, not self\n+        print('tearing down')\n+        super(One, self).tearDownClass()\n+        if self.reuse_existing_stack:\n+            print('dumping state')\n+            json.dump(self.state, open(self.statefile, 'w'))\n+        if self.cleanup:\n+            print('cleaning up')\n+            for stackname in self.stacknames:\n+                cfn.ensure_destroyed(stackname)\n+        print('removing temp dir')\n+        # self.rm_temp_dir()\n+        # self.assertFalse(os.path.exists(self.temp_dir), \"failed to delete path %r in tearDown\" % self.temp_dir)\n+\n+    def test_bootstrap_idempotence(self):\n+        \"the same stack cannot be created multiple times\"\n+        bootstrap.create_stack(self.stackname)\n+\n+    def test_bootstrap_wait_until_in_progress(self):\n+        bootstrap._wait_until_in_progress(self.stackname)\n+        bootstrap.setup_ec2(self.stackname, self.context)\n+\n+    def test_bootstrap_update_template_no_updates(self):\n+        \"a template with no changes can be updated with no problems\"\n+        bootstrap.update_template(self.stackname, json.load(open(self.cfn_template, 'r')))\n+\n+    def test_bootstrap_run_script(self):\n+        with core.stack_conn(self.stackname, username=BOOTSTRAP_USER):\n+            bootstrap.run_script('test.sh')\n+\n+    def test_core_find_ec2_instances(self):\n+        self.assertEqual(len(core.find_ec2_instances(self.stackname)), 1) # 1 node is running\n+        self.assertEqual(len(core.find_ec2_instances(self.stackname, state='stopped', allow_empty=True)), 0) # 0 nodes are stopped\n+\n+    def test_bootstrap_template_info(self):\n+        resp = bootstrap.template_info(self.stackname)\n+        expecting = {\n+            'stack_name': self.stackname,\n+            'stack_id': 'arn:aws:cloudformation:us-east-1:512686554592:stack/dummy1--luke-20180420025657-458624/afc10200-4459-11e8-8c52-500c2864aa35',\n+            'outputs': {\n+                'PublicIP1': '34.229.140.136',\n+                'AZ1': 'us-east-1d',\n+                'InstanceId1': 'i-027c0ae8fd9054cff',\n+                'PrivateIP1': '10.0.2.237'\n+            }\n+        }\n+        self.assertTrue(utils.hasallkeys(resp, expecting.keys()))\n+        self.assertTrue(utils.hasallkeys(resp['outputs'], expecting['outputs'].keys()))\n+\n+    def test_bootstrap_write_environment_info(self):\n+        with core.stack_conn(self.stackname, username=BOOTSTRAP_USER):\n+            bootstrap.write_environment_info(self.stackname, overwrite=False)\n+            bootstrap.write_environment_info(self.stackname, overwrite=True)\n+\n+    def test_delete_stack_file_while_still_active(self):\n+        self.assertEqual(None, bootstrap.delete_stack_file(self.stackname))\n+\n+    def test_core_describe_stack(self):\n+        core.describe_stack(self.stackname)","path":"src/integration_tests/test_with_instance.py","position":113,"original_position":113,"commit_id":"001dc9b505e67cf71d9862f1880dd52835e1048f","original_commit_id":"001dc9b505e67cf71d9862f1880dd52835e1048f","user":{"login":"giorgiosironi","id":160299,"avatar_url":"https://avatars3.githubusercontent.com/u/160299?v=4","gravatar_id":"","url":"https://api.github.com/users/giorgiosironi","html_url":"https://github.com/giorgiosironi","followers_url":"https://api.github.com/users/giorgiosironi/followers","following_url":"https://api.github.com/users/giorgiosironi/following{/other_user}","gists_url":"https://api.github.com/users/giorgiosironi/gists{/gist_id}","starred_url":"https://api.github.com/users/giorgiosironi/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/giorgiosironi/subscriptions","organizations_url":"https://api.github.com/users/giorgiosironi/orgs","repos_url":"https://api.github.com/users/giorgiosironi/repos","events_url":"https://api.github.com/users/giorgiosironi/events{/privacy}","received_events_url":"https://api.github.com/users/giorgiosironi/received_events","type":"User","site_admin":false},"body":"all these calls are very valuable as it would very difficult to exercise that code with stubs/mocks","created_at":"2018-04-20T15:51:56Z","updated_at":"2018-04-20T15:51:56Z","html_url":"https://github.com/elifesciences/builder/pull/265#discussion_r183094747","pull_request_url":"https://api.github.com/repos/elifesciences/builder/pulls/265","author_association":"COLLABORATOR","_links":{"self":{"href":"https://api.github.com/repos/elifesciences/builder/pulls/comments/183094747"},"html":{"href":"https://github.com/elifesciences/builder/pull/265#discussion_r183094747"},"pull_request":{"href":"https://api.github.com/repos/elifesciences/builder/pulls/265"}}},"pull_request":{"url":"https://api.github.com/repos/elifesciences/builder/pulls/265","id":179849577,"html_url":"https://github.com/elifesciences/builder/pull/265","diff_url":"https://github.com/elifesciences/builder/pull/265.diff","patch_url":"https://github.com/elifesciences/builder/pull/265.patch","issue_url":"https://api.github.com/repos/elifesciences/builder/issues/265","number":265,"state":"open","locked":false,"title":"[wip] boto2 removal","user":{"login":"lsh-0","id":2142748,"avatar_url":"https://avatars0.githubusercontent.com/u/2142748?v=4","gravatar_id":"","url":"https://api.github.com/users/lsh-0","html_url":"https://github.com/lsh-0","followers_url":"https://api.github.com/users/lsh-0/followers","following_url":"https://api.github.com/users/lsh-0/following{/other_user}","gists_url":"https://api.github.com/users/lsh-0/gists{/gist_id}","starred_url":"https://api.github.com/users/lsh-0/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lsh-0/subscriptions","organizations_url":"https://api.github.com/users/lsh-0/orgs","repos_url":"https://api.github.com/users/lsh-0/repos","events_url":"https://api.github.com/users/lsh-0/events{/privacy}","received_events_url":"https://api.github.com/users/lsh-0/received_events","type":"User","site_admin":false},"body":"* s3","created_at":"2018-04-06T03:58:46Z","updated_at":"2018-04-20T15:51:56Z","closed_at":null,"merged_at":null,"merge_commit_sha":"514ebd4587a4688d278820aa1d5b1b2c7f4d0f9a","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/elifesciences/builder/pulls/265/commits","review_comments_url":"https://api.github.com/repos/elifesciences/builder/pulls/265/comments","review_comment_url":"https://api.github.com/repos/elifesciences/builder/pulls/comments{/number}","comments_url":"https://api.github.com/repos/elifesciences/builder/issues/265/comments","statuses_url":"https://api.github.com/repos/elifesciences/builder/statuses/001dc9b505e67cf71d9862f1880dd52835e1048f","head":{"label":"elifesciences:feat-boto2-removal","ref":"feat-boto2-removal","sha":"001dc9b505e67cf71d9862f1880dd52835e1048f","user":{"login":"elifesciences","id":1777367,"avatar_url":"https://avatars2.githubusercontent.com/u/1777367?v=4","gravatar_id":"","url":"https://api.github.com/users/elifesciences","html_url":"https://github.com/elifesciences","followers_url":"https://api.github.com/users/elifesciences/followers","following_url":"https://api.github.com/users/elifesciences/following{/other_user}","gists_url":"https://api.github.com/users/elifesciences/gists{/gist_id}","starred_url":"https://api.github.com/users/elifesciences/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/elifesciences/subscriptions","organizations_url":"https://api.github.com/users/elifesciences/orgs","repos_url":"https://api.github.com/users/elifesciences/repos","events_url":"https://api.github.com/users/elifesciences/events{/privacy}","received_events_url":"https://api.github.com/users/elifesciences/received_events","type":"Organization","site_admin":false},"repo":{"id":56778863,"name":"builder","full_name":"elifesciences/builder","owner":{"login":"elifesciences","id":1777367,"avatar_url":"https://avatars2.githubusercontent.com/u/1777367?v=4","gravatar_id":"","url":"https://api.github.com/users/elifesciences","html_url":"https://github.com/elifesciences","followers_url":"https://api.github.com/users/elifesciences/followers","following_url":"https://api.github.com/users/elifesciences/following{/other_user}","gists_url":"https://api.github.com/users/elifesciences/gists{/gist_id}","starred_url":"https://api.github.com/users/elifesciences/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/elifesciences/subscriptions","organizations_url":"https://api.github.com/users/elifesciences/orgs","repos_url":"https://api.github.com/users/elifesciences/repos","events_url":"https://api.github.com/users/elifesciences/events{/privacy}","received_events_url":"https://api.github.com/users/elifesciences/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/elifesciences/builder","description":null,"fork":false,"url":"https://api.github.com/repos/elifesciences/builder","forks_url":"https://api.github.com/repos/elifesciences/builder/forks","keys_url":"https://api.github.com/repos/elifesciences/builder/keys{/key_id}","collaborators_url":"https://api.github.com/repos/elifesciences/builder/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/elifesciences/builder/teams","hooks_url":"https://api.github.com/repos/elifesciences/builder/hooks","issue_events_url":"https://api.github.com/repos/elifesciences/builder/issues/events{/number}","events_url":"https://api.github.com/repos/elifesciences/builder/events","assignees_url":"https://api.github.com/repos/elifesciences/builder/assignees{/user}","branches_url":"https://api.github.com/repos/elifesciences/builder/branches{/branch}","tags_url":"https://api.github.com/repos/elifesciences/builder/tags","blobs_url":"https://api.github.com/repos/elifesciences/builder/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/elifesciences/builder/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/elifesciences/builder/git/refs{/sha}","trees_url":"https://api.github.com/repos/elifesciences/builder/git/trees{/sha}","statuses_url":"https://api.github.com/repos/elifesciences/builder/statuses/{sha}","languages_url":"https://api.github.com/repos/elifesciences/builder/languages","stargazers_url":"https://api.github.com/repos/elifesciences/builder/stargazers","contributors_url":"https://api.github.com/repos/elifesciences/builder/contributors","subscribers_url":"https://api.github.com/repos/elifesciences/builder/subscribers","subscription_url":"https://api.github.com/repos/elifesciences/builder/subscription","commits_url":"https://api.github.com/repos/elifesciences/builder/commits{/sha}","git_commits_url":"https://api.github.com/repos/elifesciences/builder/git/commits{/sha}","comments_url":"https://api.github.com/repos/elifesciences/builder/comments{/number}","issue_comment_url":"https://api.github.com/repos/elifesciences/builder/issues/comments{/number}","contents_url":"https://api.github.com/repos/elifesciences/builder/contents/{+path}","compare_url":"https://api.github.com/repos/elifesciences/builder/compare/{base}...{head}","merges_url":"https://api.github.com/repos/elifesciences/builder/merges","archive_url":"https://api.github.com/repos/elifesciences/builder/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/elifesciences/builder/downloads","issues_url":"https://api.github.com/repos/elifesciences/builder/issues{/number}","pulls_url":"https://api.github.com/repos/elifesciences/builder/pulls{/number}","milestones_url":"https://api.github.com/repos/elifesciences/builder/milestones{/number}","notifications_url":"https://api.github.com/repos/elifesciences/builder/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/elifesciences/builder/labels{/name}","releases_url":"https://api.github.com/repos/elifesciences/builder/releases{/id}","deployments_url":"https://api.github.com/repos/elifesciences/builder/deployments","created_at":"2016-04-21T14:08:05Z","updated_at":"2018-04-20T07:52:15Z","pushed_at":"2018-04-20T15:16:36Z","git_url":"git://github.com/elifesciences/builder.git","ssh_url":"git@github.com:elifesciences/builder.git","clone_url":"https://github.com/elifesciences/builder.git","svn_url":"https://github.com/elifesciences/builder","homepage":null,"size":1771,"stargazers_count":2,"watchers_count":2,"language":"Python","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":8,"mirror_url":null,"archived":false,"open_issues_count":3,"license":{"key":"mit","name":"MIT License","spdx_id":"MIT","url":"https://api.github.com/licenses/mit"},"forks":8,"open_issues":3,"watchers":2,"default_branch":"master"}},"base":{"label":"elifesciences:master","ref":"master","sha":"bd92a0c36995b0f4bf6682c1eeaa3c8a43bfe1ca","user":{"login":"elifesciences","id":1777367,"avatar_url":"https://avatars2.githubusercontent.com/u/1777367?v=4","gravatar_id":"","url":"https://api.github.com/users/elifesciences","html_url":"https://github.com/elifesciences","followers_url":"https://api.github.com/users/elifesciences/followers","following_url":"https://api.github.com/users/elifesciences/following{/other_user}","gists_url":"https://api.github.com/users/elifesciences/gists{/gist_id}","starred_url":"https://api.github.com/users/elifesciences/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/elifesciences/subscriptions","organizations_url":"https://api.github.com/users/elifesciences/orgs","repos_url":"https://api.github.com/users/elifesciences/repos","events_url":"https://api.github.com/users/elifesciences/events{/privacy}","received_events_url":"https://api.github.com/users/elifesciences/received_events","type":"Organization","site_admin":false},"repo":{"id":56778863,"name":"builder","full_name":"elifesciences/builder","owner":{"login":"elifesciences","id":1777367,"avatar_url":"https://avatars2.githubusercontent.com/u/1777367?v=4","gravatar_id":"","url":"https://api.github.com/users/elifesciences","html_url":"https://github.com/elifesciences","followers_url":"https://api.github.com/users/elifesciences/followers","following_url":"https://api.github.com/users/elifesciences/following{/other_user}","gists_url":"https://api.github.com/users/elifesciences/gists{/gist_id}","starred_url":"https://api.github.com/users/elifesciences/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/elifesciences/subscriptions","organizations_url":"https://api.github.com/users/elifesciences/orgs","repos_url":"https://api.github.com/users/elifesciences/repos","events_url":"https://api.github.com/users/elifesciences/events{/privacy}","received_events_url":"https://api.github.com/users/elifesciences/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/elifesciences/builder","description":null,"fork":false,"url":"https://api.github.com/repos/elifesciences/builder","forks_url":"https://api.github.com/repos/elifesciences/builder/forks","keys_url":"https://api.github.com/repos/elifesciences/builder/keys{/key_id}","collaborators_url":"https://api.github.com/repos/elifesciences/builder/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/elifesciences/builder/teams","hooks_url":"https://api.github.com/repos/elifesciences/builder/hooks","issue_events_url":"https://api.github.com/repos/elifesciences/builder/issues/events{/number}","events_url":"https://api.github.com/repos/elifesciences/builder/events","assignees_url":"https://api.github.com/repos/elifesciences/builder/assignees{/user}","branches_url":"https://api.github.com/repos/elifesciences/builder/branches{/branch}","tags_url":"https://api.github.com/repos/elifesciences/builder/tags","blobs_url":"https://api.github.com/repos/elifesciences/builder/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/elifesciences/builder/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/elifesciences/builder/git/refs{/sha}","trees_url":"https://api.github.com/repos/elifesciences/builder/git/trees{/sha}","statuses_url":"https://api.github.com/repos/elifesciences/builder/statuses/{sha}","languages_url":"https://api.github.com/repos/elifesciences/builder/languages","stargazers_url":"https://api.github.com/repos/elifesciences/builder/stargazers","contributors_url":"https://api.github.com/repos/elifesciences/builder/contributors","subscribers_url":"https://api.github.com/repos/elifesciences/builder/subscribers","subscription_url":"https://api.github.com/repos/elifesciences/builder/subscription","commits_url":"https://api.github.com/repos/elifesciences/builder/commits{/sha}","git_commits_url":"https://api.github.com/repos/elifesciences/builder/git/commits{/sha}","comments_url":"https://api.github.com/repos/elifesciences/builder/comments{/number}","issue_comment_url":"https://api.github.com/repos/elifesciences/builder/issues/comments{/number}","contents_url":"https://api.github.com/repos/elifesciences/builder/contents/{+path}","compare_url":"https://api.github.com/repos/elifesciences/builder/compare/{base}...{head}","merges_url":"https://api.github.com/repos/elifesciences/builder/merges","archive_url":"https://api.github.com/repos/elifesciences/builder/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/elifesciences/builder/downloads","issues_url":"https://api.github.com/repos/elifesciences/builder/issues{/number}","pulls_url":"https://api.github.com/repos/elifesciences/builder/pulls{/number}","milestones_url":"https://api.github.com/repos/elifesciences/builder/milestones{/number}","notifications_url":"https://api.github.com/repos/elifesciences/builder/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/elifesciences/builder/labels{/name}","releases_url":"https://api.github.com/repos/elifesciences/builder/releases{/id}","deployments_url":"https://api.github.com/repos/elifesciences/builder/deployments","created_at":"2016-04-21T14:08:05Z","updated_at":"2018-04-20T07:52:15Z","pushed_at":"2018-04-20T15:16:36Z","git_url":"git://github.com/elifesciences/builder.git","ssh_url":"git@github.com:elifesciences/builder.git","clone_url":"https://github.com/elifesciences/builder.git","svn_url":"https://github.com/elifesciences/builder","homepage":null,"size":1771,"stargazers_count":2,"watchers_count":2,"language":"Python","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":8,"mirror_url":null,"archived":false,"open_issues_count":3,"license":{"key":"mit","name":"MIT License","spdx_id":"MIT","url":"https://api.github.com/licenses/mit"},"forks":8,"open_issues":3,"watchers":2,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/elifesciences/builder/pulls/265"},"html":{"href":"https://github.com/elifesciences/builder/pull/265"},"issue":{"href":"https://api.github.com/repos/elifesciences/builder/issues/265"},"comments":{"href":"https://api.github.com/repos/elifesciences/builder/issues/265/comments"},"review_comments":{"href":"https://api.github.com/repos/elifesciences/builder/pulls/265/comments"},"review_comment":{"href":"https://api.github.com/repos/elifesciences/builder/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/elifesciences/builder/pulls/265/commits"},"statuses":{"href":"https://api.github.com/repos/elifesciences/builder/statuses/001dc9b505e67cf71d9862f1880dd52835e1048f"}},"author_association":"CONTRIBUTOR"}}
{"actor":{"display_login":"giorgiosironi"}}