57
57
"""
58
58
env = os .environ
59
59
60
+ PLUGINS = [('bigdesk' , 'lukas-vlcek/bigdesk' ),
61
+ ('paramedic' , 'karmi/elasticsearch-paramedic' ),
62
+ ('segmentspy' , 'polyfractal/elasticsearch-segmentspy' ),
63
+ ('inquisitor' , 'polyfractal/elasticsearch-inquisitor' ),
64
+ ('head' , 'mobz/elasticsearch-head' )]
65
+
60
66
LOG = env .get ('ES_RELEASE_LOG' , '/tmp/elasticsearch_release.log' )
61
67
62
68
def log (msg ):
@@ -116,10 +122,11 @@ def verify_mvn_java_version(version, mvn):
116
122
117
123
# Returns the hash of the current git HEAD revision
118
124
def get_head_hash ():
119
- return get_hash ( ' HEAD' )
125
+ return os . popen ( ' git rev-parse --verify HEAD 2>&1' ). read (). strip ( )
120
126
121
- def get_hash (version ):
122
- return os .popen ('git rev-parse --verify %s 2>&1' % (version )).read ().strip ()
127
+ # Returns the hash of the given tag revision
128
+ def get_tag_hash (tag ):
129
+ return os .popen ('git show-ref --tags %s --hash 2>&1' % (tag )).read ().strip ()
123
130
124
131
# Returns the name of the current branch
125
132
def get_current_branch ():
@@ -132,6 +139,10 @@ def get_current_branch():
132
139
def release_branch (version ):
133
140
return 'release_branch_%s' % version
134
141
142
+ # runs get fetch on the given remote
143
+ def fetch (remote ):
144
+ run ('git fetch %s' % remote )
145
+
135
146
# Creates a new release branch from the given source branch
136
147
# and rebases the source branch from the remote before creating
137
148
# the release branch. Note: This fails if the source branch
@@ -308,7 +319,7 @@ def generate_checksums(files):
308
319
res = res + [os .path .join (directory , checksum_file ), release_file ]
309
320
return res
310
321
311
- def download_and_verify (release , files , base_url = 'https://download.elasticsearch.org/elasticsearch/elasticsearch' ):
322
+ def download_and_verify (release , files , plugins = None , base_url = 'https://download.elasticsearch.org/elasticsearch/elasticsearch' ):
312
323
print ('Downloading and verifying release %s from %s' % (release , base_url ))
313
324
tmp_dir = tempfile .mkdtemp ()
314
325
try :
@@ -325,11 +336,11 @@ def download_and_verify(release, files, base_url='https://download.elasticsearch
325
336
urllib .request .urlretrieve (url , checksum_file )
326
337
print (' Verifying checksum %s' % (checksum_file ))
327
338
run ('cd %s && sha1sum -c %s' % (tmp_dir , os .path .basename (checksum_file )))
328
- smoke_test_release (release , downloaded_files , get_hash ('v%s' % release ))
339
+ smoke_test_release (release , downloaded_files , get_tag_hash ('v%s' % release ), plugins )
329
340
finally :
330
341
shutil .rmtree (tmp_dir )
331
342
332
- def smoke_test_release (release , files , expected_hash ):
343
+ def smoke_test_release (release , files , expected_hash , plugins ):
333
344
for release_file in files :
334
345
if not os .path .isfile (release_file ):
335
346
raise RuntimeError ('Smoketest failed missing file %s' % (release_file ))
@@ -343,9 +354,20 @@ def smoke_test_release(release, files, expected_hash):
343
354
continue # nothing to do here
344
355
es_run_path = os .path .join (tmp_dir , 'elasticsearch-%s' % (release ), 'bin/elasticsearch' )
345
356
print (' Smoke testing package [%s]' % release_file )
357
+ es_plugin_path = os .path .join (tmp_dir , 'elasticsearch-%s' % (release ),'bin/plugin' )
358
+ plugin_names = {}
359
+ for name , plugin in plugins :
360
+ print (' Install plugin [%s] from [%s]' % (name , plugin ))
361
+ run ('%s %s %s' % (es_plugin_path , '-install' , plugin ))
362
+ plugin_names [name ] = True
363
+
364
+ if release .startswith ("0.90." ):
365
+ background = '' # 0.90.x starts in background automatically
366
+ else :
367
+ background = '-d'
346
368
print (' Starting elasticsearch deamon from [%s]' % os .path .join (tmp_dir , 'elasticsearch-%s' % release ))
347
- run ('%s; %s -Des.node.name=smoke_tester -Des.cluster.name=prepare_release -Des.discovery.zen.ping.multicast.enabled=false'
348
- % (java_exe (), es_run_path ))
369
+ run ('%s; %s -Des.node.name=smoke_tester -Des.cluster.name=prepare_release -Des.discovery.zen.ping.multicast.enabled=false %s '
370
+ % (java_exe (), es_run_path , background ))
349
371
conn = HTTPConnection ('127.0.0.1' , 9200 , 20 );
350
372
wait_for_node_startup ()
351
373
try :
@@ -359,9 +381,25 @@ def smoke_test_release(release, files, expected_hash):
359
381
if version ['build_snapshot' ]:
360
382
raise RuntimeError ('Expected non snapshot version' )
361
383
if version ['build_hash' ].strip () != expected_hash :
362
- raise RuntimeError ('HEAD hash does not match expected [%s] but got [%s]' % (get_head_hash () , version ['build_hash' ]))
384
+ raise RuntimeError ('HEAD hash does not match expected [%s] but got [%s]' % (expected_hash , version ['build_hash' ]))
363
385
print (' Running REST Spec tests against package [%s]' % release_file )
364
386
run_mvn ('test -Dtests.rest=%s -Dtests.class=*.*RestTests' % ("127.0.0.1:9200" ))
387
+ print (' Verify if plugins are listed in _nodes' )
388
+ conn .request ('GET' , '/_nodes?plugin=true&pretty=true' )
389
+ res = conn .getresponse ()
390
+ if res .status == 200 :
391
+ nodes = json .loads (res .read ().decode ("utf-8" ))['nodes' ]
392
+ for _ , node in nodes .items ():
393
+ node_plugins = node ['plugins' ]
394
+ for node_plugin in node_plugins :
395
+ if not plugin_names .get (node_plugin ['name' ], False ):
396
+ raise RuntimeError ('Unexpeced plugin %s' % node_plugin ['name' ])
397
+ del plugin_names [node_plugin ['name' ]]
398
+ if plugin_names :
399
+ raise RuntimeError ('Plugins not loaded %s' % list (plugin_names .keys ()))
400
+
401
+ else :
402
+ raise RuntimeError ('Expected HTTP 200 but got %s' % res .status )
365
403
else :
366
404
raise RuntimeError ('Expected HTTP 200 but got %s' % res .status )
367
405
finally :
@@ -470,14 +508,11 @@ def check_s3_credentials():
470
508
print ('Preparing Release from branch [%s] running tests: [%s] dryrun: [%s]' % (src_branch , run_tests , dry_run ))
471
509
print (' JAVA_HOME is [%s]' % JAVA_HOME )
472
510
print (' Running with maven command: [%s] ' % (MVN ))
473
- release_version = find_release_version (src_branch )
474
-
475
- if not smoke_test_version and not dry_run :
476
- smoke_test_version = release_version
477
- elif smoke_test_version :
478
- print ("Skipping build - smoketest only against version %s" % smoke_test_version )
479
511
480
512
if build :
513
+ release_version = find_release_version (src_branch )
514
+ if not dry_run :
515
+ smoke_test_version = release_version
481
516
head_hash = get_head_hash ()
482
517
run_mvn ('clean' ) # clean the env!
483
518
print (' Release version: [%s]' % release_version )
@@ -496,11 +531,14 @@ def check_s3_credentials():
496
531
print ('' .join (['-' for _ in range (80 )]))
497
532
print ('Building Release candidate' )
498
533
input ('Press Enter to continue...' )
499
- print (' Running maven builds now and publish to sonartype- run-tests [%s]' % run_tests )
534
+ if not dry_run :
535
+ print (' Running maven builds now and publish to sonartype - run-tests [%s]' % run_tests )
536
+ else :
537
+ print (' Running maven builds now run-tests [%s]' % run_tests )
500
538
build_release (run_tests = run_tests , dry_run = dry_run , cpus = cpus )
501
539
artifacts = get_artifacts (release_version )
502
540
artifacts_and_checksum = generate_checksums (artifacts )
503
- smoke_test_release (release_version , artifacts , get_head_hash ())
541
+ smoke_test_release (release_version , artifacts , get_head_hash (), PLUGINS )
504
542
print ('' .join (['-' for _ in range (80 )]))
505
543
print ('Finish Release -- dry_run: %s' % dry_run )
506
544
input ('Press Enter to continue...' )
@@ -529,5 +567,9 @@ def check_s3_credentials():
529
567
run ('git tag -d v%s' % release_version )
530
568
# we delete this one anyways
531
569
run ('git branch -D %s' % (release_branch (release_version )))
570
+ else :
571
+ print ("Skipping build - smoketest only against version %s" % smoke_test_version )
572
+
532
573
if smoke_test_version :
533
- download_and_verify (smoke_test_version , artifact_names (smoke_test_version ))
574
+ fetch (remote )
575
+ download_and_verify (smoke_test_version , artifact_names (smoke_test_version ), plugins = PLUGINS )
0 commit comments