{"action":"created","comment":{"url":"https://api.github.com/repos/mambocab/cassandra-dtest/pulls/comments/48203941","id":48203941,"diff_hunk":"@@ -970,60 +793,91 @@ def _multidc_schema_create(self):\n                 PRIMARY KEY (k1, k2)\n                 );\"\"\")\n \n-# create test classes for upgrading from latest tag on branch to the head of that same branch\n-for from_ver in UPGRADE_PATH:\n-    # we only want to do single upgrade tests for 1.2+\n-    # and trunk is the final version, so there's no test where trunk is upgraded to something else\n-    if make_ver_str(from_ver) >= '1.2' and from_ver != TRUNK_VER:\n-        cls_name = ('TestUpgrade_from_' + make_ver_str(from_ver) + '_latest_tag_to_' + make_ver_str(from_ver) + '_HEAD').replace('-', '_').replace('.', '_')\n-        start_ver_latest_tag = latest_tag_matching(from_ver)\n-        debug('Creating test upgrade class: {} with start tag of: {} ({})'.format(cls_name, start_ver_latest_tag, sha_for_ref_name(start_ver_latest_tag)))\n-        vars()[cls_name] = type(\n-            cls_name,\n-            (PointToPointUpgradeBase,),\n-            {'test_versions': [start_ver_latest_tag, make_branch_str(from_ver)], '__test__': True})\n-\n-# build a list of tuples like so:\n-# [(A, B), (B, C) ... ]\n-# each pair in the list represents an upgrade test (A, B)\n-# where we will upgrade from the latest *tag* matching A, to the HEAD of branch B\n-POINT_UPGRADES = []\n-points = [v for v in UPGRADE_PATH if make_ver_str(v) >= '1.2']\n-for i, _ in enumerate(points):\n-    verslice = tuple(points[i:i + 2])\n-    if len(verslice) == 2:  # exclude dangling version at end\n-        POINT_UPGRADES.append(tuple(points[i:i + 2]))\n-\n-# create test classes for upgrading from latest tag on one branch, to head of the next branch (see comment above)\n-for (from_ver, to_branch) in POINT_UPGRADES:\n-    cls_name = ('TestUpgrade_from_' + make_ver_str(from_ver) + '_latest_tag_to_' + make_branch_str(to_branch) + '_HEAD').replace('-', '_').replace('.', '_')\n-    from_ver_latest_tag = latest_tag_matching(from_ver)\n-    debug('Creating test upgrade class: {} with start tag of: {} ({})'.format(cls_name, from_ver_latest_tag, sha_for_ref_name(from_ver_latest_tag)))\n-    vars()[cls_name] = type(\n-        cls_name,\n-        (PointToPointUpgradeBase,),\n-        {'test_versions': [from_ver_latest_tag, make_branch_str(to_branch)], '__test__': True})\n-\n-# create test classes for upgrading from HEAD of one branch to HEAD of next.\n-for (from_branch, to_branch) in POINT_UPGRADES:\n-    cls_name = ('TestUpgrade_from_' + make_branch_str(from_branch) + '_HEAD_to_' + make_branch_str(to_branch) + '_HEAD').replace('-', '_').replace('.', '_')\n-    debug('Creating test upgrade class: {}'.format(cls_name))\n-    vars()[cls_name] = type(\n-        cls_name,\n-        (PointToPointUpgradeBase,),\n-        {'test_versions': [make_branch_str(from_branch), make_branch_str(to_branch)], '__test__': True})\n-\n-# create test classes for upgrading from HEAD of one branch, to latest tag of next branch\n-for (from_branch, to_branch) in POINT_UPGRADES:\n-    cls_name = ('TestUpgrade_from_' + make_branch_str(from_branch) + '_HEAD_to_' + make_branch_str(to_branch) + '_latest_tag').replace('-', '_').replace('.', '_')\n-    to_ver_latest_tag = latest_tag_matching(to_branch)\n-    # in some cases we might not find a tag (like when the to_branch is trunk)\n-    # so these will be skipped.\n-    if to_ver_latest_tag is None:\n-        continue\n-    debug('Creating test upgrade class: {} with end tag of: {} ({})'.format(cls_name, to_ver_latest_tag, sha_for_ref_name(to_ver_latest_tag)))\n-\n-    vars()[cls_name] = type(\n+\n+# used by function def immediately below\n+created_class_scope = vars()\n+\n+\n+def create_upgrade_class(version_list, protocol_version=DEFAULT_PROTOCOL_VERSION, bootstrap_test=False):\n+    \"\"\"\n+    Dynamically creates a test subclass for testing the given versions.\n+\n+    'version_list' should be a list of versions ccm will recognize.\n+    'bootstrap_test' is a boolean, if True bootstrap testing will be included.\n+    \"\"\"\n+    if bootstrap_test:\n+        parent_classes = (UpgradeTester, BootstrapMixin)\n+    else:\n+        parent_classes = (UpgradeTester,)\n+\n+    cls_name = 'TestUpgradeDynamicClass__' + \"__\".join(version_list).replace(':', '_').replace('-', '').replace('.', '_')\n+    debug(\"Creating test class {}, parent classes: {}\".format(cls_name, parent_classes))\n+    created_class_scope[cls_name] = type(\n         cls_name,\n-        (PointToPointUpgradeBase,),\n-        {'test_versions': [make_branch_str(from_branch), to_ver_latest_tag], '__test__': True})\n+        parent_classes,\n+        {'test_versions': version_list, '__test__': True, 'protocol_version': protocol_version}\n+    )\n+\n+# maps protocol version to c* version(s)\n+# Versions are tuples of (major_ver, minor_ver)\n+# PROTOCOL_PATHS = {\n+#     1: [(2, 0), (2, 1), (2, 2)],\n+#     2: [(2, 0), (2, 1), (2, 2)],\n+#     3: [(2, 1), (2, 2), (3, 0), (3, 1), TRUNK_VER],\n+#     4: [(2, 2), (3, 0), (3, 1), TRUNK_VER]\n+# }\n+\n+create_upgrade_class(['git:cassandra-2.0', 'git:cassandra-2.1'], bootstrap_test=True)","path":"upgrade_through_versions_test.py","position":null,"original_position":530,"commit_id":"2540441659569fc30916d21d3e8dd4779eef498f","original_commit_id":"6c3dfb7bebfc4145a4ad720154e1b4772362fd7e","user":{"login":"mambocab","id":3753769,"avatar_url":"https://avatars.githubusercontent.com/u/3753769?v=3","gravatar_id":"","url":"https://api.github.com/users/mambocab","html_url":"https://github.com/mambocab","followers_url":"https://api.github.com/users/mambocab/followers","following_url":"https://api.github.com/users/mambocab/following{/other_user}","gists_url":"https://api.github.com/users/mambocab/gists{/gist_id}","starred_url":"https://api.github.com/users/mambocab/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mambocab/subscriptions","organizations_url":"https://api.github.com/users/mambocab/orgs","repos_url":"https://api.github.com/users/mambocab/repos","events_url":"https://api.github.com/users/mambocab/events{/privacy}","received_events_url":"https://api.github.com/users/mambocab/received_events","type":"User","site_admin":false},"body":"Now that I see how this is used, it might be better have `create_upgrade_class` be a pure function returning a class, leaving attaching the class to the module at the module level:\r\n\r\n```python\r\nUpgrade20HEAD21Bootstrap = create_upgrade_class(name='Upgrade20HEAD21Bootstrap',\r\n                                                test_versions=['git:cassandra-2.0', 'git:cassandra-2.1'],\r\n                                                bootstrap_test=True)\r\n```\r\n\r\nYou could implement the existing `create_upgrade_class` on top of that, so if you want, e.g., automatic class name generation and/or automatic insertion into `globals()`, you could write that on top of a function implementing the pure-function interface. At the very least, this makes the code a little more decomposed and reusable.","created_at":"2015-12-21T23:08:53Z","updated_at":"2015-12-21T23:08:53Z","html_url":"https://github.com/mambocab/cassandra-dtest/pull/3#discussion_r48203941","pull_request_url":"https://api.github.com/repos/mambocab/cassandra-dtest/pulls/3","_links":{"self":{"href":"https://api.github.com/repos/mambocab/cassandra-dtest/pulls/comments/48203941"},"html":{"href":"https://github.com/mambocab/cassandra-dtest/pull/3#discussion_r48203941"},"pull_request":{"href":"https://api.github.com/repos/mambocab/cassandra-dtest/pulls/3"}}},"pull_request":{"url":"https://api.github.com/repos/mambocab/cassandra-dtest/pulls/3","id":54309479,"html_url":"https://github.com/mambocab/cassandra-dtest/pull/3","diff_url":"https://github.com/mambocab/cassandra-dtest/pull/3.diff","patch_url":"https://github.com/mambocab/cassandra-dtest/pull/3.patch","issue_url":"https://api.github.com/repos/mambocab/cassandra-dtest/issues/3","number":3,"state":"open","locked":false,"title":"upgrade test simplification","user":{"login":"mambocab","id":3753769,"avatar_url":"https://avatars.githubusercontent.com/u/3753769?v=3","gravatar_id":"","url":"https://api.github.com/users/mambocab","html_url":"https://github.com/mambocab","followers_url":"https://api.github.com/users/mambocab/followers","following_url":"https://api.github.com/users/mambocab/following{/other_user}","gists_url":"https://api.github.com/users/mambocab/gists{/gist_id}","starred_url":"https://api.github.com/users/mambocab/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mambocab/subscriptions","organizations_url":"https://api.github.com/users/mambocab/orgs","repos_url":"https://api.github.com/users/mambocab/repos","events_url":"https://api.github.com/users/mambocab/events{/privacy}","received_events_url":"https://api.github.com/users/mambocab/received_events","type":"User","site_admin":false},"body":"just opening this one for initial discussion","created_at":"2015-12-21T22:13:39Z","updated_at":"2015-12-21T23:08:53Z","closed_at":null,"merged_at":null,"merge_commit_sha":"38213afa65bebfe8bb68de31fd6b2265ea023a9b","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/mambocab/cassandra-dtest/pulls/3/commits","review_comments_url":"https://api.github.com/repos/mambocab/cassandra-dtest/pulls/3/comments","review_comment_url":"https://api.github.com/repos/mambocab/cassandra-dtest/pulls/comments{/number}","comments_url":"https://api.github.com/repos/mambocab/cassandra-dtest/issues/3/comments","statuses_url":"https://api.github.com/repos/mambocab/cassandra-dtest/statuses/2540441659569fc30916d21d3e8dd4779eef498f","head":{"label":"riptano:remove_upgrade_ver_magic","ref":"remove_upgrade_ver_magic","sha":"2540441659569fc30916d21d3e8dd4779eef498f","user":{"login":"riptano","id":275430,"avatar_url":"https://avatars.githubusercontent.com/u/275430?v=3","gravatar_id":"","url":"https://api.github.com/users/riptano","html_url":"https://github.com/riptano","followers_url":"https://api.github.com/users/riptano/followers","following_url":"https://api.github.com/users/riptano/following{/other_user}","gists_url":"https://api.github.com/users/riptano/gists{/gist_id}","starred_url":"https://api.github.com/users/riptano/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/riptano/subscriptions","organizations_url":"https://api.github.com/users/riptano/orgs","repos_url":"https://api.github.com/users/riptano/repos","events_url":"https://api.github.com/users/riptano/events{/privacy}","received_events_url":"https://api.github.com/users/riptano/received_events","type":"Organization","site_admin":false},"repo":{"id":2674774,"name":"cassandra-dtest","full_name":"riptano/cassandra-dtest","owner":{"login":"riptano","id":275430,"avatar_url":"https://avatars.githubusercontent.com/u/275430?v=3","gravatar_id":"","url":"https://api.github.com/users/riptano","html_url":"https://github.com/riptano","followers_url":"https://api.github.com/users/riptano/followers","following_url":"https://api.github.com/users/riptano/following{/other_user}","gists_url":"https://api.github.com/users/riptano/gists{/gist_id}","starred_url":"https://api.github.com/users/riptano/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/riptano/subscriptions","organizations_url":"https://api.github.com/users/riptano/orgs","repos_url":"https://api.github.com/users/riptano/repos","events_url":"https://api.github.com/users/riptano/events{/privacy}","received_events_url":"https://api.github.com/users/riptano/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/riptano/cassandra-dtest","description":"Cassandra Distributed Tests","fork":false,"url":"https://api.github.com/repos/riptano/cassandra-dtest","forks_url":"https://api.github.com/repos/riptano/cassandra-dtest/forks","keys_url":"https://api.github.com/repos/riptano/cassandra-dtest/keys{/key_id}","collaborators_url":"https://api.github.com/repos/riptano/cassandra-dtest/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/riptano/cassandra-dtest/teams","hooks_url":"https://api.github.com/repos/riptano/cassandra-dtest/hooks","issue_events_url":"https://api.github.com/repos/riptano/cassandra-dtest/issues/events{/number}","events_url":"https://api.github.com/repos/riptano/cassandra-dtest/events","assignees_url":"https://api.github.com/repos/riptano/cassandra-dtest/assignees{/user}","branches_url":"https://api.github.com/repos/riptano/cassandra-dtest/branches{/branch}","tags_url":"https://api.github.com/repos/riptano/cassandra-dtest/tags","blobs_url":"https://api.github.com/repos/riptano/cassandra-dtest/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/riptano/cassandra-dtest/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/riptano/cassandra-dtest/git/refs{/sha}","trees_url":"https://api.github.com/repos/riptano/cassandra-dtest/git/trees{/sha}","statuses_url":"https://api.github.com/repos/riptano/cassandra-dtest/statuses/{sha}","languages_url":"https://api.github.com/repos/riptano/cassandra-dtest/languages","stargazers_url":"https://api.github.com/repos/riptano/cassandra-dtest/stargazers","contributors_url":"https://api.github.com/repos/riptano/cassandra-dtest/contributors","subscribers_url":"https://api.github.com/repos/riptano/cassandra-dtest/subscribers","subscription_url":"https://api.github.com/repos/riptano/cassandra-dtest/subscription","commits_url":"https://api.github.com/repos/riptano/cassandra-dtest/commits{/sha}","git_commits_url":"https://api.github.com/repos/riptano/cassandra-dtest/git/commits{/sha}","comments_url":"https://api.github.com/repos/riptano/cassandra-dtest/comments{/number}","issue_comment_url":"https://api.github.com/repos/riptano/cassandra-dtest/issues/comments{/number}","contents_url":"https://api.github.com/repos/riptano/cassandra-dtest/contents/{+path}","compare_url":"https://api.github.com/repos/riptano/cassandra-dtest/compare/{base}...{head}","merges_url":"https://api.github.com/repos/riptano/cassandra-dtest/merges","archive_url":"https://api.github.com/repos/riptano/cassandra-dtest/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/riptano/cassandra-dtest/downloads","issues_url":"https://api.github.com/repos/riptano/cassandra-dtest/issues{/number}","pulls_url":"https://api.github.com/repos/riptano/cassandra-dtest/pulls{/number}","milestones_url":"https://api.github.com/repos/riptano/cassandra-dtest/milestones{/number}","notifications_url":"https://api.github.com/repos/riptano/cassandra-dtest/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/riptano/cassandra-dtest/labels{/name}","releases_url":"https://api.github.com/repos/riptano/cassandra-dtest/releases{/id}","created_at":"2011-10-30T11:15:44Z","updated_at":"2015-12-10T22:39:33Z","pushed_at":"2015-12-21T23:03:40Z","git_url":"git://github.com/riptano/cassandra-dtest.git","ssh_url":"git@github.com:riptano/cassandra-dtest.git","clone_url":"https://github.com/riptano/cassandra-dtest.git","svn_url":"https://github.com/riptano/cassandra-dtest","homepage":"","size":13757,"stargazers_count":69,"watchers_count":69,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":52,"mirror_url":null,"open_issues_count":50,"forks":52,"open_issues":50,"watchers":69,"default_branch":"master"}},"base":{"label":"mambocab:master","ref":"master","sha":"93a498e6740a487fb6708a802b8070215bf5593c","user":{"login":"mambocab","id":3753769,"avatar_url":"https://avatars.githubusercontent.com/u/3753769?v=3","gravatar_id":"","url":"https://api.github.com/users/mambocab","html_url":"https://github.com/mambocab","followers_url":"https://api.github.com/users/mambocab/followers","following_url":"https://api.github.com/users/mambocab/following{/other_user}","gists_url":"https://api.github.com/users/mambocab/gists{/gist_id}","starred_url":"https://api.github.com/users/mambocab/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mambocab/subscriptions","organizations_url":"https://api.github.com/users/mambocab/orgs","repos_url":"https://api.github.com/users/mambocab/repos","events_url":"https://api.github.com/users/mambocab/events{/privacy}","received_events_url":"https://api.github.com/users/mambocab/received_events","type":"User","site_admin":false},"repo":{"id":31236640,"name":"cassandra-dtest","full_name":"mambocab/cassandra-dtest","owner":{"login":"mambocab","id":3753769,"avatar_url":"https://avatars.githubusercontent.com/u/3753769?v=3","gravatar_id":"","url":"https://api.github.com/users/mambocab","html_url":"https://github.com/mambocab","followers_url":"https://api.github.com/users/mambocab/followers","following_url":"https://api.github.com/users/mambocab/following{/other_user}","gists_url":"https://api.github.com/users/mambocab/gists{/gist_id}","starred_url":"https://api.github.com/users/mambocab/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mambocab/subscriptions","organizations_url":"https://api.github.com/users/mambocab/orgs","repos_url":"https://api.github.com/users/mambocab/repos","events_url":"https://api.github.com/users/mambocab/events{/privacy}","received_events_url":"https://api.github.com/users/mambocab/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/mambocab/cassandra-dtest","description":"Cassandra Distributed Tests","fork":true,"url":"https://api.github.com/repos/mambocab/cassandra-dtest","forks_url":"https://api.github.com/repos/mambocab/cassandra-dtest/forks","keys_url":"https://api.github.com/repos/mambocab/cassandra-dtest/keys{/key_id}","collaborators_url":"https://api.github.com/repos/mambocab/cassandra-dtest/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/mambocab/cassandra-dtest/teams","hooks_url":"https://api.github.com/repos/mambocab/cassandra-dtest/hooks","issue_events_url":"https://api.github.com/repos/mambocab/cassandra-dtest/issues/events{/number}","events_url":"https://api.github.com/repos/mambocab/cassandra-dtest/events","assignees_url":"https://api.github.com/repos/mambocab/cassandra-dtest/assignees{/user}","branches_url":"https://api.github.com/repos/mambocab/cassandra-dtest/branches{/branch}","tags_url":"https://api.github.com/repos/mambocab/cassandra-dtest/tags","blobs_url":"https://api.github.com/repos/mambocab/cassandra-dtest/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/mambocab/cassandra-dtest/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/mambocab/cassandra-dtest/git/refs{/sha}","trees_url":"https://api.github.com/repos/mambocab/cassandra-dtest/git/trees{/sha}","statuses_url":"https://api.github.com/repos/mambocab/cassandra-dtest/statuses/{sha}","languages_url":"https://api.github.com/repos/mambocab/cassandra-dtest/languages","stargazers_url":"https://api.github.com/repos/mambocab/cassandra-dtest/stargazers","contributors_url":"https://api.github.com/repos/mambocab/cassandra-dtest/contributors","subscribers_url":"https://api.github.com/repos/mambocab/cassandra-dtest/subscribers","subscription_url":"https://api.github.com/repos/mambocab/cassandra-dtest/subscription","commits_url":"https://api.github.com/repos/mambocab/cassandra-dtest/commits{/sha}","git_commits_url":"https://api.github.com/repos/mambocab/cassandra-dtest/git/commits{/sha}","comments_url":"https://api.github.com/repos/mambocab/cassandra-dtest/comments{/number}","issue_comment_url":"https://api.github.com/repos/mambocab/cassandra-dtest/issues/comments{/number}","contents_url":"https://api.github.com/repos/mambocab/cassandra-dtest/contents/{+path}","compare_url":"https://api.github.com/repos/mambocab/cassandra-dtest/compare/{base}...{head}","merges_url":"https://api.github.com/repos/mambocab/cassandra-dtest/merges","archive_url":"https://api.github.com/repos/mambocab/cassandra-dtest/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/mambocab/cassandra-dtest/downloads","issues_url":"https://api.github.com/repos/mambocab/cassandra-dtest/issues{/number}","pulls_url":"https://api.github.com/repos/mambocab/cassandra-dtest/pulls{/number}","milestones_url":"https://api.github.com/repos/mambocab/cassandra-dtest/milestones{/number}","notifications_url":"https://api.github.com/repos/mambocab/cassandra-dtest/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/mambocab/cassandra-dtest/labels{/name}","releases_url":"https://api.github.com/repos/mambocab/cassandra-dtest/releases{/id}","created_at":"2015-02-23T23:58:43Z","updated_at":"2015-03-20T18:05:58Z","pushed_at":"2015-12-21T23:03:40Z","git_url":"git://github.com/mambocab/cassandra-dtest.git","ssh_url":"git@github.com:mambocab/cassandra-dtest.git","clone_url":"https://github.com/mambocab/cassandra-dtest.git","svn_url":"https://github.com/mambocab/cassandra-dtest","homepage":"","size":13295,"stargazers_count":0,"watchers_count":0,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":1,"forks":0,"open_issues":1,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/mambocab/cassandra-dtest/pulls/3"},"html":{"href":"https://github.com/mambocab/cassandra-dtest/pull/3"},"issue":{"href":"https://api.github.com/repos/mambocab/cassandra-dtest/issues/3"},"comments":{"href":"https://api.github.com/repos/mambocab/cassandra-dtest/issues/3/comments"},"review_comments":{"href":"https://api.github.com/repos/mambocab/cassandra-dtest/pulls/3/comments"},"review_comment":{"href":"https://api.github.com/repos/mambocab/cassandra-dtest/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/mambocab/cassandra-dtest/pulls/3/commits"},"statuses":{"href":"https://api.github.com/repos/mambocab/cassandra-dtest/statuses/2540441659569fc30916d21d3e8dd4779eef498f"}}}}