|
56 | 56 | version = raft_sdk.raft_common.get_version() |
57 | 57 |
|
58 | 58 |
|
| 59 | +def compatability_test(service_cli): |
| 60 | + # Verify that the major version numbers of the CLI |
| 61 | + # and the service are the same. |
| 62 | + # https://github.com/microsoft/rest-api-fuzz-testing/docs/raft-updates.md |
| 63 | + # for a discussion on versions. |
| 64 | + # Major version numbers are incremented on breaking changes |
| 65 | + # Minor version numbers are incremented with CLI changes. |
| 66 | + # So for this check we only need to verify major version numbers. |
| 67 | + |
| 68 | + cli_version = raft_sdk.raft_common.get_version() |
| 69 | + cli_version_parts = cli_version.split('.') |
| 70 | + cli_major = cli_version_parts[0] |
| 71 | + |
| 72 | + info = service_cli.service_info() |
| 73 | + service_version_parts = info['version'].split('.') |
| 74 | + service_major = service_version_parts[0] |
| 75 | + |
| 76 | + if (cli_major != service_major): |
| 77 | + error_message = 'The CLI and service MUST be on ' |
| 78 | + error_message + 'the same major version. ' |
| 79 | + error_message += f'CLI version = {cli_version} ' |
| 80 | + error_message += f'Service version = {info["version"]}' |
| 81 | + raise Exception(error_message) |
| 82 | + |
| 83 | + |
59 | 84 | def run(args): |
60 | 85 | def validate(defaults): |
61 | 86 | s = defaults.get('subscription') |
@@ -106,11 +131,13 @@ def validate(defaults): |
106 | 131 | job_action = args.get('job-action') |
107 | 132 | webhook_action = args.get('webhook-action') |
108 | 133 |
|
| 134 | + service_cli = RaftServiceCLI( |
| 135 | + defaults, |
| 136 | + defaults_path, |
| 137 | + args.get('secret')) |
| 138 | + compatability_test(service_cli) |
| 139 | + |
109 | 140 | if service_action: |
110 | | - service_cli = RaftServiceCLI( |
111 | | - defaults, |
112 | | - defaults_path, |
113 | | - args.get('secret')) |
114 | 141 | if service_action == 'restart': |
115 | 142 | service_cli.restart() |
116 | 143 | elif service_action == 'info': |
|
0 commit comments