Skip to content
This repository was archived by the owner on Feb 2, 2022. It is now read-only.

Commit f2b624a

Browse files
authored
Verify the CLI and Azure service are running the same major version. #229 (#231)
1 parent a5b1aac commit f2b624a

File tree

1 file changed

+31
-4
lines changed

1 file changed

+31
-4
lines changed

cli/raft.py

Lines changed: 31 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,31 @@
5656
version = raft_sdk.raft_common.get_version()
5757

5858

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+
5984
def run(args):
6085
def validate(defaults):
6186
s = defaults.get('subscription')
@@ -106,11 +131,13 @@ def validate(defaults):
106131
job_action = args.get('job-action')
107132
webhook_action = args.get('webhook-action')
108133

134+
service_cli = RaftServiceCLI(
135+
defaults,
136+
defaults_path,
137+
args.get('secret'))
138+
compatability_test(service_cli)
139+
109140
if service_action:
110-
service_cli = RaftServiceCLI(
111-
defaults,
112-
defaults_path,
113-
args.get('secret'))
114141
if service_action == 'restart':
115142
service_cli.restart()
116143
elif service_action == 'info':

0 commit comments

Comments
 (0)