{"action":"created","comment":{"url":"https://api.github.com/repos/google/citest/pulls/comments/79460058","id":79460058,"diff_hunk":"@@ -0,0 +1,195 @@\n+# Copyright 2016 Google Inc. All Rights Reserved.\n+#\n+# Licensed under the Apache License, Version 2.0 (the 'License');\n+# you may not use this file except in compliance with the License.\n+# You may obtain a copy of the License at\n+#\n+#     http://www.apache.org/licenses/LICENSE-2.0\n+#\n+# Unless required by applicable law or agreed to in writing, software\n+# distributed under the License is distributed on an 'AS IS' BASIS,\n+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n+# See the License for the specific language governing permissions and\n+# limitations under the License.\n+\n+\n+# See testable_service/integration_test.py and spinnaker_testing/spinnaker.py\n+# for more details.\n+#\n+# The Http(s) test will be used to (more) thoroughly test the GCP L7 load\n+# balancer Upsert and Delete commands, and will eventually be expanded to\n+# include server group tests.\n+\n+# Standard python modules.\n+from OpenSSL import crypto\n+import copy\n+import json\n+import sys\n+import time\n+import uuid\n+import google_http_upsert_test as upsert\n+\n+# citest modules.\n+from citest.base import ExecutionContext\n+import citest\n+import citest.gcp_testing as gcp\n+import citest.json_predicate as jp\n+import citest.service_testing as st\n+\n+# Spinnaker modules.\n+import spinnaker_testing as sk\n+import spinnaker_testing.gate as gate\n+\n+\n+SCOPES = [gcp.COMPUTE_READ_WRITE_SCOPE]\n+\n+class GoogleHttpLoadBalancerTest(st.AgentTestCase):\n+  '''Test fixture for Http LB test.\n+  '''\n+\n+  FIRST_CERT = ''\n+  SECOND_CERT = ''\n+\n+  @classmethod\n+  def setUpClass(cls):\n+    cls.FIRST_CERT = 'first-cert' + str(uuid.uuid4())\n+    cls.SECOND_CERT = 'second-cert' + str(uuid.uuid4())\n+    runner = citest.base.TestRunner.global_runner()\n+    bindings = runner.bindings\n+    scenario = runner.get_shared_data(upsert.GoogleHttpLoadBalancerTestScenario)\n+    managed_region = runner.bindings['TEST_GCE_REGION']\n+    title = 'Check Quota for {0}'.format(scenario.__class__.__name__)\n+\n+    verify_results = gcp.verify_quota(\n+      title,\n+      scenario.gcp_observer,\n+      project_quota=upsert.GoogleHttpLoadBalancerTestScenario.MINIMUM_PROJECT_QUOTA,\n+      regions=[(managed_region,\n+                upsert.GoogleHttpLoadBalancerTestScenario.MINIMUM_REGION_QUOTA)]\n+    )\n+    if not verify_results:\n+      raise RuntimeError('Insufficient Quota: {0}'.format(verify_results))\n+\n+    key = crypto.PKey()\n+    key.generate_key(crypto.TYPE_RSA, 2048)\n+    cert = crypto.X509()\n+    cert.get_subject().C = \"US\"\n+    cert.get_subject().ST = \"New York\"\n+    cert.get_subject().L = \"New York City\"\n+    cert.get_subject().O = \"Google\"\n+    cert.get_subject().OU = \"Spinnaker\"\n+    cert.get_subject().CN = \"localhost\"\n+    cert.set_serial_number(4096)\n+    cert.gmtime_adj_notBefore(0)\n+    cert.gmtime_adj_notAfter(24 * 60 * 60)\n+    cert.set_issuer(cert.get_subject())\n+    cert.set_pubkey(key)\n+    cert.sign(key, 'sha1')\n+\n+    compute_agent = gcp.GcpComputeAgent.make_agent(scopes=SCOPES,\n+                                                   credentials_path=bindings['GCE_CREDENTIALS_PATH'])\n+    context = ExecutionContext()\n+    ssl_cert = {\n+      'name': cls.FIRST_CERT,\n+      'privateKey': crypto.dump_privatekey(crypto.FILETYPE_PEM, key),\n+      'certificate': crypto.dump_certificate(crypto.FILETYPE_PEM, cert)\n+    }\n+    compute_agent.invoke_resource(context, # No predicates against this agent, context is empty.\n+                                  'insert',\n+                                  resource_type='sslCertificates',\n+                                  project=bindings['GCE_PROJECT'],\n+                                  body=ssl_cert)\n+    ssl_cert['name'] = cls.SECOND_CERT\n+    compute_agent.invoke_resource(context,\n+                                  'insert',\n+                                  resource_type='sslCertificates',\n+                                  project=bindings['GCE_PROJECT'],\n+                                  body=ssl_cert)\n+\n+\n+  @classmethod\n+  def tearDownClass(cls):\n+    runner = citest.base.TestRunner.global_runner()\n+    bindings = runner.bindings\n+    context = ExecutionContext()\n+    compute_agent = gcp.GcpComputeAgent.make_agent(scopes=SCOPES,\n+                                                   credentials_path=bindings['GCE_CREDENTIALS_PATH'])\n+    compute_agent.invoke_resource(context,\n+                                  'delete',\n+                                  resource_type='sslCertificates',\n+                                  project=bindings['GCE_PROJECT'],\n+                                  sslCertificate=cls.FIRST_CERT)\n+    compute_agent.invoke_resource(context,\n+                                  'delete',\n+                                  resource_type='sslCertificates',\n+                                  project=bindings['GCE_PROJECT'],\n+                                  sslCertificate=cls.SECOND_CERT)\n+\n+\n+  @property\n+  def scenario(self):\n+    return citest.base.TestRunner.global_runner().get_shared_data(\n+        upsert.GoogleHttpLoadBalancerTestScenario)\n+\n+  def test_a_upsert_lb(self):\n+    self.run_test_case(self.scenario.upsert_full_load_balancer())\n+","path":"spinnaker/spinnaker_system/google_http_upsert_server_test.py","position":136,"original_position":136,"commit_id":"44806b769477826856bfe0bddb0bb448206f66ad","original_commit_id":"44806b769477826856bfe0bddb0bb448206f66ad","user":{"login":"ewiseblatt","id":4367384,"avatar_url":"https://avatars.githubusercontent.com/u/4367384?v=3","gravatar_id":"","url":"https://api.github.com/users/ewiseblatt","html_url":"https://github.com/ewiseblatt","followers_url":"https://api.github.com/users/ewiseblatt/followers","following_url":"https://api.github.com/users/ewiseblatt/following{/other_user}","gists_url":"https://api.github.com/users/ewiseblatt/gists{/gist_id}","starred_url":"https://api.github.com/users/ewiseblatt/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ewiseblatt/subscriptions","organizations_url":"https://api.github.com/users/ewiseblatt/orgs","repos_url":"https://api.github.com/users/ewiseblatt/repos","events_url":"https://api.github.com/users/ewiseblatt/events{/privacy}","received_events_url":"https://api.github.com/users/ewiseblatt/received_events","type":"User","site_admin":false},"body":"I thought we'd agreed that test_a and test_b were redundant to test_d and test_o","created_at":"2016-09-19T18:40:52Z","updated_at":"2016-09-19T18:40:52Z","html_url":"https://github.com/google/citest/pull/208#discussion_r79460058","pull_request_url":"https://api.github.com/repos/google/citest/pulls/208","_links":{"self":{"href":"https://api.github.com/repos/google/citest/pulls/comments/79460058"},"html":{"href":"https://github.com/google/citest/pull/208#discussion_r79460058"},"pull_request":{"href":"https://api.github.com/repos/google/citest/pulls/208"}}},"pull_request":{"url":"https://api.github.com/repos/google/citest/pulls/208","id":85306917,"html_url":"https://github.com/google/citest/pull/208","diff_url":"https://github.com/google/citest/pull/208.diff","patch_url":"https://github.com/google/citest/pull/208.patch","issue_url":"https://api.github.com/repos/google/citest/issues/208","number":208,"state":"open","locked":false,"title":"Added L7 LB upsert test.","user":{"login":"jtk54","id":5456773,"avatar_url":"https://avatars.githubusercontent.com/u/5456773?v=3","gravatar_id":"","url":"https://api.github.com/users/jtk54","html_url":"https://github.com/jtk54","followers_url":"https://api.github.com/users/jtk54/followers","following_url":"https://api.github.com/users/jtk54/following{/other_user}","gists_url":"https://api.github.com/users/jtk54/gists{/gist_id}","starred_url":"https://api.github.com/users/jtk54/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jtk54/subscriptions","organizations_url":"https://api.github.com/users/jtk54/orgs","repos_url":"https://api.github.com/users/jtk54/repos","events_url":"https://api.github.com/users/jtk54/events{/privacy}","received_events_url":"https://api.github.com/users/jtk54/received_events","type":"User","site_admin":false},"body":"@ewiseblatt please review. @duftler FYI. This is a pretty comprehensive test on L7 load balancer upsert without associated server groups. I'll add another set of tests in the future that test the L7 server group operations and validates L7 upsert when there are server groups attached.","created_at":"2016-09-14T21:17:40Z","updated_at":"2016-09-19T18:58:17Z","closed_at":null,"merged_at":null,"merge_commit_sha":"1af8e2b0a865d6cb90302be09e495ab2fb81a3a4","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/google/citest/pulls/208/commits","review_comments_url":"https://api.github.com/repos/google/citest/pulls/208/comments","review_comment_url":"https://api.github.com/repos/google/citest/pulls/comments{/number}","comments_url":"https://api.github.com/repos/google/citest/issues/208/comments","statuses_url":"https://api.github.com/repos/google/citest/statuses/44806b769477826856bfe0bddb0bb448206f66ad","head":{"label":"jtk54:l7-test","ref":"l7-test","sha":"44806b769477826856bfe0bddb0bb448206f66ad","user":{"login":"jtk54","id":5456773,"avatar_url":"https://avatars.githubusercontent.com/u/5456773?v=3","gravatar_id":"","url":"https://api.github.com/users/jtk54","html_url":"https://github.com/jtk54","followers_url":"https://api.github.com/users/jtk54/followers","following_url":"https://api.github.com/users/jtk54/following{/other_user}","gists_url":"https://api.github.com/users/jtk54/gists{/gist_id}","starred_url":"https://api.github.com/users/jtk54/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jtk54/subscriptions","organizations_url":"https://api.github.com/users/jtk54/orgs","repos_url":"https://api.github.com/users/jtk54/repos","events_url":"https://api.github.com/users/jtk54/events{/privacy}","received_events_url":"https://api.github.com/users/jtk54/received_events","type":"User","site_admin":false},"repo":{"id":55710672,"name":"citest","full_name":"jtk54/citest","owner":{"login":"jtk54","id":5456773,"avatar_url":"https://avatars.githubusercontent.com/u/5456773?v=3","gravatar_id":"","url":"https://api.github.com/users/jtk54","html_url":"https://github.com/jtk54","followers_url":"https://api.github.com/users/jtk54/followers","following_url":"https://api.github.com/users/jtk54/following{/other_user}","gists_url":"https://api.github.com/users/jtk54/gists{/gist_id}","starred_url":"https://api.github.com/users/jtk54/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jtk54/subscriptions","organizations_url":"https://api.github.com/users/jtk54/orgs","repos_url":"https://api.github.com/users/jtk54/repos","events_url":"https://api.github.com/users/jtk54/events{/privacy}","received_events_url":"https://api.github.com/users/jtk54/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/jtk54/citest","description":null,"fork":true,"url":"https://api.github.com/repos/jtk54/citest","forks_url":"https://api.github.com/repos/jtk54/citest/forks","keys_url":"https://api.github.com/repos/jtk54/citest/keys{/key_id}","collaborators_url":"https://api.github.com/repos/jtk54/citest/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/jtk54/citest/teams","hooks_url":"https://api.github.com/repos/jtk54/citest/hooks","issue_events_url":"https://api.github.com/repos/jtk54/citest/issues/events{/number}","events_url":"https://api.github.com/repos/jtk54/citest/events","assignees_url":"https://api.github.com/repos/jtk54/citest/assignees{/user}","branches_url":"https://api.github.com/repos/jtk54/citest/branches{/branch}","tags_url":"https://api.github.com/repos/jtk54/citest/tags","blobs_url":"https://api.github.com/repos/jtk54/citest/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/jtk54/citest/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/jtk54/citest/git/refs{/sha}","trees_url":"https://api.github.com/repos/jtk54/citest/git/trees{/sha}","statuses_url":"https://api.github.com/repos/jtk54/citest/statuses/{sha}","languages_url":"https://api.github.com/repos/jtk54/citest/languages","stargazers_url":"https://api.github.com/repos/jtk54/citest/stargazers","contributors_url":"https://api.github.com/repos/jtk54/citest/contributors","subscribers_url":"https://api.github.com/repos/jtk54/citest/subscribers","subscription_url":"https://api.github.com/repos/jtk54/citest/subscription","commits_url":"https://api.github.com/repos/jtk54/citest/commits{/sha}","git_commits_url":"https://api.github.com/repos/jtk54/citest/git/commits{/sha}","comments_url":"https://api.github.com/repos/jtk54/citest/comments{/number}","issue_comment_url":"https://api.github.com/repos/jtk54/citest/issues/comments{/number}","contents_url":"https://api.github.com/repos/jtk54/citest/contents/{+path}","compare_url":"https://api.github.com/repos/jtk54/citest/compare/{base}...{head}","merges_url":"https://api.github.com/repos/jtk54/citest/merges","archive_url":"https://api.github.com/repos/jtk54/citest/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/jtk54/citest/downloads","issues_url":"https://api.github.com/repos/jtk54/citest/issues{/number}","pulls_url":"https://api.github.com/repos/jtk54/citest/pulls{/number}","milestones_url":"https://api.github.com/repos/jtk54/citest/milestones{/number}","notifications_url":"https://api.github.com/repos/jtk54/citest/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/jtk54/citest/labels{/name}","releases_url":"https://api.github.com/repos/jtk54/citest/releases{/id}","deployments_url":"https://api.github.com/repos/jtk54/citest/deployments","created_at":"2016-04-07T16:34:06Z","updated_at":"2016-04-07T16:34:07Z","pushed_at":"2016-09-19T14:40:05Z","git_url":"git://github.com/jtk54/citest.git","ssh_url":"git@github.com:jtk54/citest.git","clone_url":"https://github.com/jtk54/citest.git","svn_url":"https://github.com/jtk54/citest","homepage":null,"size":904,"stargazers_count":0,"watchers_count":0,"language":"Python","has_issues":false,"has_downloads":false,"has_wiki":false,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"google:master","ref":"master","sha":"1866beed9ee3a82f3ee5fed6a9aca0e1a88c92a3","user":{"login":"google","id":1342004,"avatar_url":"https://avatars.githubusercontent.com/u/1342004?v=3","gravatar_id":"","url":"https://api.github.com/users/google","html_url":"https://github.com/google","followers_url":"https://api.github.com/users/google/followers","following_url":"https://api.github.com/users/google/following{/other_user}","gists_url":"https://api.github.com/users/google/gists{/gist_id}","starred_url":"https://api.github.com/users/google/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/google/subscriptions","organizations_url":"https://api.github.com/users/google/orgs","repos_url":"https://api.github.com/users/google/repos","events_url":"https://api.github.com/users/google/events{/privacy}","received_events_url":"https://api.github.com/users/google/received_events","type":"Organization","site_admin":false},"repo":{"id":40497615,"name":"citest","full_name":"google/citest","owner":{"login":"google","id":1342004,"avatar_url":"https://avatars.githubusercontent.com/u/1342004?v=3","gravatar_id":"","url":"https://api.github.com/users/google","html_url":"https://github.com/google","followers_url":"https://api.github.com/users/google/followers","following_url":"https://api.github.com/users/google/following{/other_user}","gists_url":"https://api.github.com/users/google/gists{/gist_id}","starred_url":"https://api.github.com/users/google/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/google/subscriptions","organizations_url":"https://api.github.com/users/google/orgs","repos_url":"https://api.github.com/users/google/repos","events_url":"https://api.github.com/users/google/events{/privacy}","received_events_url":"https://api.github.com/users/google/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/google/citest","description":null,"fork":false,"url":"https://api.github.com/repos/google/citest","forks_url":"https://api.github.com/repos/google/citest/forks","keys_url":"https://api.github.com/repos/google/citest/keys{/key_id}","collaborators_url":"https://api.github.com/repos/google/citest/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/google/citest/teams","hooks_url":"https://api.github.com/repos/google/citest/hooks","issue_events_url":"https://api.github.com/repos/google/citest/issues/events{/number}","events_url":"https://api.github.com/repos/google/citest/events","assignees_url":"https://api.github.com/repos/google/citest/assignees{/user}","branches_url":"https://api.github.com/repos/google/citest/branches{/branch}","tags_url":"https://api.github.com/repos/google/citest/tags","blobs_url":"https://api.github.com/repos/google/citest/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/google/citest/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/google/citest/git/refs{/sha}","trees_url":"https://api.github.com/repos/google/citest/git/trees{/sha}","statuses_url":"https://api.github.com/repos/google/citest/statuses/{sha}","languages_url":"https://api.github.com/repos/google/citest/languages","stargazers_url":"https://api.github.com/repos/google/citest/stargazers","contributors_url":"https://api.github.com/repos/google/citest/contributors","subscribers_url":"https://api.github.com/repos/google/citest/subscribers","subscription_url":"https://api.github.com/repos/google/citest/subscription","commits_url":"https://api.github.com/repos/google/citest/commits{/sha}","git_commits_url":"https://api.github.com/repos/google/citest/git/commits{/sha}","comments_url":"https://api.github.com/repos/google/citest/comments{/number}","issue_comment_url":"https://api.github.com/repos/google/citest/issues/comments{/number}","contents_url":"https://api.github.com/repos/google/citest/contents/{+path}","compare_url":"https://api.github.com/repos/google/citest/compare/{base}...{head}","merges_url":"https://api.github.com/repos/google/citest/merges","archive_url":"https://api.github.com/repos/google/citest/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/google/citest/downloads","issues_url":"https://api.github.com/repos/google/citest/issues{/number}","pulls_url":"https://api.github.com/repos/google/citest/pulls{/number}","milestones_url":"https://api.github.com/repos/google/citest/milestones{/number}","notifications_url":"https://api.github.com/repos/google/citest/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/google/citest/labels{/name}","releases_url":"https://api.github.com/repos/google/citest/releases{/id}","deployments_url":"https://api.github.com/repos/google/citest/deployments","created_at":"2015-08-10T18:04:21Z","updated_at":"2016-09-03T02:57:00Z","pushed_at":"2016-09-19T14:40:05Z","git_url":"git://github.com/google/citest.git","ssh_url":"git@github.com:google/citest.git","clone_url":"https://github.com/google/citest.git","svn_url":"https://github.com/google/citest","homepage":null,"size":913,"stargazers_count":15,"watchers_count":15,"language":"Python","has_issues":false,"has_downloads":false,"has_wiki":false,"has_pages":false,"forks_count":13,"mirror_url":null,"open_issues_count":1,"forks":13,"open_issues":1,"watchers":15,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/google/citest/pulls/208"},"html":{"href":"https://github.com/google/citest/pull/208"},"issue":{"href":"https://api.github.com/repos/google/citest/issues/208"},"comments":{"href":"https://api.github.com/repos/google/citest/issues/208/comments"},"review_comments":{"href":"https://api.github.com/repos/google/citest/pulls/208/comments"},"review_comment":{"href":"https://api.github.com/repos/google/citest/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/google/citest/pulls/208/commits"},"statuses":{"href":"https://api.github.com/repos/google/citest/statuses/44806b769477826856bfe0bddb0bb448206f66ad"}}}}
{"actor":{"display_login":"ewiseblatt"}}