Skip to content

Commit d293346

Browse files
committed
Proper skipping technique for yaml test suite
1 parent 8e43be9 commit d293346

File tree

1 file changed

+20
-1
lines changed

1 file changed

+20
-1
lines changed

test_elasticsearch/test_server/test_common.py

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,8 +125,27 @@ def run_do(self, action):
125125
if catch:
126126
raise AssertionError('Failed to catch %r in %r.' % (catch, self.last_response))
127127

128+
def _get_nodes(self):
129+
if not hasattr(self, '_node_info'):
130+
self._node_info = list(self.client.nodes.info(node_id='_all', metric='clear')['nodes'].values())
131+
return self._node_info
132+
133+
def _get_data_nodes(self):
134+
return len([info for info in self._get_nodes() if info.get('attributes', {}).get('data', 'true') == 'true'])
135+
136+
def _get_benchmark_nodes(self):
137+
return len([info for info in self._get_nodes() if info.get('attributes', {}).get('bench', 'false') == 'true'])
138+
128139
def run_skip(self, skip):
129-
if 'features' in skip and skip['features'] not in IMPLEMENTED_FEATURES:
140+
if 'features' in skip:
141+
if skip['features'] in IMPLEMENTED_FEATURES:
142+
return
143+
elif skip['features'] == 'requires_replica':
144+
if self._get_data_nodes() > 1:
145+
return
146+
elif skip['features'] == 'benchmark':
147+
if self._get_benchmark_nodes():
148+
return
130149
raise SkipTest(skip.get('reason', 'Feature %s is not supported' % skip['features']))
131150

132151
if 'version' in skip:

0 commit comments

Comments
 (0)