File tree Expand file tree Collapse file tree 3 files changed +40
-8
lines changed Expand file tree Collapse file tree 3 files changed +40
-8
lines changed Original file line number Diff line number Diff line change 48
48
MAX_WRITE_BATCH_SIZE = 1000
49
49
50
50
# What this version of PyMongo supports.
51
+ MIN_SUPPORTED_SERVER_VERSION = "2.6"
51
52
MIN_SUPPORTED_WIRE_VERSION = 2
52
53
MAX_SUPPORTED_WIRE_VERSION = 5
53
54
Original file line number Diff line number Diff line change @@ -76,15 +76,21 @@ def __init__(self,
76
76
s .max_wire_version is not None
77
77
and s .max_wire_version < common .MIN_SUPPORTED_WIRE_VERSION )
78
78
79
- if server_too_new or server_too_old :
79
+ if server_too_new :
80
80
self ._incompatible_err = (
81
- "Server at %s:%d "
82
- "uses wire protocol versions %d through %d, "
83
- "but PyMongo only supports %d through %d"
81
+ "Server at %s:%d requires wire version %d, but this "
82
+ "version of PyMongo only supports up to %d."
84
83
% (s .address [0 ], s .address [1 ],
85
- s .min_wire_version , s .max_wire_version ,
84
+ s .min_wire_version , common .MAX_SUPPORTED_WIRE_VERSION ))
85
+
86
+ elif server_too_old :
87
+ self ._incompatible_err = (
88
+ "Server at %s:%d reports wire version %d, but this "
89
+ "version of PyMongo requires at least %d (MongoDB %s)."
90
+ % (s .address [0 ], s .address [1 ],
91
+ s .max_wire_version ,
86
92
common .MIN_SUPPORTED_WIRE_VERSION ,
87
- common .MAX_SUPPORTED_WIRE_VERSION ))
93
+ common .MIN_SUPPORTED_SERVER_VERSION ))
88
94
89
95
break
90
96
Original file line number Diff line number Diff line change @@ -567,8 +567,33 @@ def test_wire_version(self):
567
567
t .select_servers (any_server_selector )
568
568
except ConfigurationError as e :
569
569
# Error message should say which server failed and why.
570
- self .assertTrue ('a:27017' in str (e ))
571
- self .assertTrue ('wire protocol versions 11 through 12' in str (e ))
570
+ self .assertEqual (
571
+ str (e ),
572
+ "Server at a:27017 requires wire version 11, but this version "
573
+ "of PyMongo only supports up to %d."
574
+ % (common .MAX_SUPPORTED_WIRE_VERSION ,))
575
+ else :
576
+ self .fail ('No error with incompatible wire version' )
577
+
578
+ # Incompatible.
579
+ got_ismaster (t , address , {
580
+ 'ok' : 1 ,
581
+ 'ismaster' : True ,
582
+ 'setName' : 'rs' ,
583
+ 'hosts' : ['a' ],
584
+ 'minWireVersion' : 0 ,
585
+ 'maxWireVersion' : 0 })
586
+
587
+ try :
588
+ t .select_servers (any_server_selector )
589
+ except ConfigurationError as e :
590
+ # Error message should say which server failed and why.
591
+ self .assertEqual (
592
+ str (e ),
593
+ "Server at a:27017 reports wire version 0, but this version "
594
+ "of PyMongo requires at least %d (MongoDB %s)."
595
+ % (common .MIN_SUPPORTED_WIRE_VERSION ,
596
+ common .MIN_SUPPORTED_SERVER_VERSION ))
572
597
else :
573
598
self .fail ('No error with incompatible wire version' )
574
599
You can’t perform that action at this time.
0 commit comments