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