mesa_test 1.0.4 → 1.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/bin/mesa_test +10 -3
- data/lib/mesa_test.rb +185 -11
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: de6aece52d2c391d00f2fc190fc466bbcd65f892e0779857d191b60705aa16aa
|
4
|
+
data.tar.gz: 5783cb8940b3ad6d7e8373fec41325c5ffc60f7ba63c912c04c9da78fbf3173e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2fc8fe1a184c7ac9b9df350236288445f01e5cccbb8ab4c2d684911e268730f65df24479e1afa62bf03bdabefa9a0e7d82cdbfbda44528e8fb38764071f0bc67
|
7
|
+
data.tar.gz: 4001cf3f05fd3076f27fae7082aff30f55b1257ee466c38e1a8dee0cc9529f7748357eea6106f6c8adcadaf6f839923f006a73365a198b45d939a425a30531a7
|
data/bin/mesa_test
CHANGED
@@ -138,7 +138,8 @@ class MesaTest < Thor
|
|
138
138
|
m.check_installation
|
139
139
|
rescue MesaDirError
|
140
140
|
shell.say %q{This MESA installation doesn't seem to be compiled } \
|
141
|
-
'properly.
|
141
|
+
'properly. Attempting to submit a compilation failure to '\
|
142
|
+
'MESATestHub.', :red
|
142
143
|
empty = true
|
143
144
|
ensure
|
144
145
|
# submit all tests
|
@@ -209,8 +210,14 @@ class MesaTest < Thor
|
|
209
210
|
github_protocol: s.github_protocol
|
210
211
|
)
|
211
212
|
end
|
212
|
-
|
213
|
-
|
213
|
+
begin
|
214
|
+
m.clean
|
215
|
+
m.install
|
216
|
+
rescue MesaDirError
|
217
|
+
shell.say "\nFailed in compiling MESA.", :red
|
218
|
+
else
|
219
|
+
shell.say "\nSuccessfully compiled MESA commit #{m.sha}.", :green
|
220
|
+
end
|
214
221
|
end
|
215
222
|
|
216
223
|
desc 'install_and_test [SHA]', 'Install, test, and submit an entire commit.'
|
data/lib/mesa_test.rb
CHANGED
@@ -7,6 +7,7 @@ require 'net/http'
|
|
7
7
|
require 'net/https'
|
8
8
|
require 'thor'
|
9
9
|
require 'json'
|
10
|
+
require 'base64'
|
10
11
|
|
11
12
|
MesaDirError = Class.new(StandardError)
|
12
13
|
TestCaseDirError = Class.new(StandardError)
|
@@ -48,9 +49,15 @@ e-mail and password will be stored in plain text.'
|
|
48
49
|
"#{s.email} (required)? (#{s.password})", :blue
|
49
50
|
s.password = response unless response.empty?
|
50
51
|
|
52
|
+
# Get API key for submitting failure logs
|
53
|
+
response = shell.ask 'What is the logs submission API token associated '\
|
54
|
+
"with the email #{s.email} (required; contact Josiah Schwab if you "\
|
55
|
+
"need a key)? (#{s.logs_token})", :blue
|
56
|
+
s.logs_token = response unless response.empty?
|
57
|
+
|
51
58
|
# Determine if we'll use ssh or https to access github
|
52
59
|
response = shell.ask 'When accessing GitHub, which protocol do you '\
|
53
|
-
'want to use?
|
60
|
+
'want to use?', :blue, limited_to: %w[ssh https]
|
54
61
|
s.github_protocol = response.strip.downcase.to_sym
|
55
62
|
|
56
63
|
# Get location of source MESA repo (the mirror)
|
@@ -110,7 +117,7 @@ e-mail and password will be stored in plain text.'
|
|
110
117
|
|
111
118
|
attr_accessor :computer_name, :user_name, :email, :password, :platform,
|
112
119
|
:mesa_mirror, :mesa_work, :platform_version, :processor,
|
113
|
-
:config_file, :base_uri, :
|
120
|
+
:config_file, :base_uri, :github_protocol, :logs_token
|
114
121
|
|
115
122
|
attr_reader :shell
|
116
123
|
|
@@ -118,7 +125,7 @@ e-mail and password will be stored in plain text.'
|
|
118
125
|
def initialize(
|
119
126
|
computer_name: nil, user_name: nil, email: nil, github_protocol: nil,
|
120
127
|
mesa_mirror: nil, platform: nil, platform_version: nil, processor: nil,
|
121
|
-
config_file: nil, base_uri: nil,
|
128
|
+
config_file: nil, base_uri: nil, logs_token: nil
|
122
129
|
)
|
123
130
|
@computer_name = computer_name || Socket.gethostname.scan(/^[^\.]+\.?/)[0]
|
124
131
|
@computer_name.chomp!('.') if @computer_name
|
@@ -146,6 +153,7 @@ e-mail and password will be stored in plain text.'
|
|
146
153
|
@config_file = config_file || File.join(ENV['HOME'], '.mesa_test',
|
147
154
|
'config.yml')
|
148
155
|
@base_uri = base_uri
|
156
|
+
@logs_token = logs_token || ENV['MESA_LOGS_TOKEN']
|
149
157
|
|
150
158
|
# set up thor-proof way to get responses from user. Thor hijacks the
|
151
159
|
# gets command, so we have to use its built-in "ask" method, which is
|
@@ -166,6 +174,7 @@ e-mail and password will be stored in plain text.'
|
|
166
174
|
puts "Computer Name #{computer_name}"
|
167
175
|
puts "User email #{email}"
|
168
176
|
puts 'Password ***********'
|
177
|
+
puts "logs API token #{logs_token}"
|
169
178
|
puts "GitHub Protocol #{github_protocol}"
|
170
179
|
puts "MESA Mirror Location #{mesa_mirror}"
|
171
180
|
puts "MESA Work Location #{mesa_work}"
|
@@ -188,6 +197,7 @@ e-mail and password will be stored in plain text.'
|
|
188
197
|
'computer_name' => computer_name,
|
189
198
|
'email' => email,
|
190
199
|
'password' => password,
|
200
|
+
'logs_token' => logs_token,
|
191
201
|
'github_protocol' => github_protocol,
|
192
202
|
'mesa_mirror' => mesa_mirror,
|
193
203
|
'mesa_work' => mesa_work,
|
@@ -206,6 +216,7 @@ e-mail and password will be stored in plain text.'
|
|
206
216
|
@computer_name = data_hash['computer_name']
|
207
217
|
@email = data_hash['email']
|
208
218
|
@password = data_hash['password']
|
219
|
+
@logs_token = data_hash['logs_token']
|
209
220
|
@github_protocol = data_hash['github_protocol'].to_sym
|
210
221
|
@mesa_mirror = data_hash['mesa_mirror']
|
211
222
|
@mesa_work = data_hash['mesa_work']
|
@@ -273,6 +284,28 @@ e-mail and password will be stored in plain text.'
|
|
273
284
|
res
|
274
285
|
end
|
275
286
|
|
287
|
+
# Parameters for reporting a failed compilation to the logs server
|
288
|
+
def build_log_params(mesa)
|
289
|
+
{
|
290
|
+
'computer_name' => computer_name,
|
291
|
+
'commit' => mesa.sha,
|
292
|
+
'build.log' => mesa.build_log_64
|
293
|
+
}
|
294
|
+
end
|
295
|
+
|
296
|
+
# Parameters for reporting a failed test to the logs server
|
297
|
+
def test_log_params(test_case)
|
298
|
+
res = {
|
299
|
+
'computer_name' => computer_name,
|
300
|
+
'commit' => test_case.mesa.sha,
|
301
|
+
'test_case' => test_case.test_name
|
302
|
+
}
|
303
|
+
res['mk.txt'] = test_case.mk_64 unless test_case.mk_64.empty?
|
304
|
+
res['out.txt'] = test_case.out_64 unless test_case.out_64.empty?
|
305
|
+
res['err.txt'] = test_case.err_64 unless test_case.err_64.empty?
|
306
|
+
res
|
307
|
+
end
|
308
|
+
|
276
309
|
# Parameters for a single test case. +mesa+ is an instance of +Mesa+, and
|
277
310
|
# +test_case+ is an instance of MesaTestCase representing the test case to
|
278
311
|
# be submitted
|
@@ -319,7 +352,9 @@ e-mail and password will be stored in plain text.'
|
|
319
352
|
#
|
320
353
|
# if we have an empty submission, then it is necessarily not entire.
|
321
354
|
# Similarly, a non-empty submission is necessarily entire (otherwise one
|
322
|
-
# would use +submit_instance+)
|
355
|
+
# would use +submit_instance+). Also, make a "nonempty" submission be
|
356
|
+
# empty if there was an overall build error
|
357
|
+
empty ||= !mesa.installed?
|
323
358
|
request_data = {submitter: submitter_params,
|
324
359
|
commit: commit_params(mesa, empty: empty, entire: !empty)}
|
325
360
|
# don't need test instances if it's an empty submission or if compilation
|
@@ -338,7 +373,29 @@ e-mail and password will be stored in plain text.'
|
|
338
373
|
false
|
339
374
|
else
|
340
375
|
shell.say "\nSuccessfully submitted commit #{mesa.sha}.", :green
|
341
|
-
|
376
|
+
# commit submitted to testhub, now submit build log if compilation failed
|
377
|
+
# and exit
|
378
|
+
unless mesa.installed?
|
379
|
+
return submit_build_log(mesa)
|
380
|
+
end
|
381
|
+
|
382
|
+
# compilation succeded, so submit any logs for failing tests
|
383
|
+
res = true
|
384
|
+
unless empty
|
385
|
+
mesa.test_cases.each do |mod, test_case_hash|
|
386
|
+
test_case_hash.each do |tc_name, test_case|
|
387
|
+
# get at each individual test case, see if it failed, and if it
|
388
|
+
# did, submit its log files
|
389
|
+
unless test_case.passed?
|
390
|
+
res &&= submit_test_log(test_case)
|
391
|
+
end
|
392
|
+
end
|
393
|
+
end
|
394
|
+
end
|
395
|
+
|
396
|
+
# a true return value means that any and all log submission were
|
397
|
+
# successful
|
398
|
+
res
|
342
399
|
end
|
343
400
|
end
|
344
401
|
|
@@ -378,9 +435,79 @@ e-mail and password will be stored in plain text.'
|
|
378
435
|
else
|
379
436
|
shell.say "\nSuccessfully submitted instance of #{test_case.test_name} "\
|
380
437
|
"for commit #{mesa.sha}.", :green
|
438
|
+
# submit logs if test failed
|
439
|
+
return submit_test_log(test_case) unless test_case.passed?
|
381
440
|
true
|
382
441
|
end
|
383
442
|
end
|
443
|
+
|
444
|
+
# make generic request to LOGS server
|
445
|
+
# +params+ is a hash of data to be encoded as JSON and sent off
|
446
|
+
def submit_logs(params)
|
447
|
+
uri = URI('https://logs.mesastar.org/uploads')
|
448
|
+
https = Net::HTTP.new(uri.host, uri.port)
|
449
|
+
https.use_ssl = true
|
450
|
+
req = Net::HTTP::Post.new(uri.path, 'Content-Type' => 'application/json',
|
451
|
+
'X-Api-Key' => logs_token)
|
452
|
+
req.body = params.to_json
|
453
|
+
https.request(req)
|
454
|
+
end
|
455
|
+
|
456
|
+
# send build log to the logs server
|
457
|
+
def submit_build_log(mesa)
|
458
|
+
# intercept and don't send if mesa was properly installed
|
459
|
+
return true if mesa.installed?
|
460
|
+
|
461
|
+
# don't even try unless we have a logs token set
|
462
|
+
unless logs_token
|
463
|
+
shell.say 'Cannot submit to logs server; need to set mesa_logs_token '\
|
464
|
+
'in the mesa_test config file.'
|
465
|
+
return false
|
466
|
+
end
|
467
|
+
|
468
|
+
# do submission
|
469
|
+
res = submit_logs(build_log_params(mesa))
|
470
|
+
|
471
|
+
# report out results
|
472
|
+
if !res.is_a? Net::HTTPOK
|
473
|
+
shell.say "\nFailed to submit build.log to the LOGS server for commit "\
|
474
|
+
"#{mesa.sha}.", :red
|
475
|
+
false
|
476
|
+
else
|
477
|
+
shell.say "\nSuccessfully submitted build.log to the LOGS server for "\
|
478
|
+
"#{mesa.sha}.", :green
|
479
|
+
true
|
480
|
+
end
|
481
|
+
end
|
482
|
+
|
483
|
+
# send build log to the logs server
|
484
|
+
def submit_test_log(test_case)
|
485
|
+
# skip submission if mesa was never installed or if the test passed
|
486
|
+
return true if !test_case.mesa.installed? || test_case.passed?
|
487
|
+
|
488
|
+
# don't even try unless we have a logs token set
|
489
|
+
unless logs_token
|
490
|
+
shell.say 'Cannot submit to logs server; need to set mesa_logs_token '\
|
491
|
+
'in the mesa_test config file..'
|
492
|
+
return false
|
493
|
+
end
|
494
|
+
|
495
|
+
# do submission
|
496
|
+
res = submit_logs(test_log_params(test_case))
|
497
|
+
|
498
|
+
# report out results
|
499
|
+
if !res.is_a? Net::HTTPOK
|
500
|
+
shell.say "Failed to submit logs for test case #{test_case.test_name} "\
|
501
|
+
"in commit #{test_case.mesa.sha}.", :red
|
502
|
+
false
|
503
|
+
else
|
504
|
+
shell.say "Successfully submitted logs for test case "\
|
505
|
+
"#{test_case.test_name} in commit #{test_case.mesa.sha}.",
|
506
|
+
:green
|
507
|
+
true
|
508
|
+
end
|
509
|
+
end
|
510
|
+
|
384
511
|
end
|
385
512
|
|
386
513
|
class Mesa
|
@@ -562,6 +689,14 @@ class Mesa
|
|
562
689
|
'show a successful installation).'
|
563
690
|
end
|
564
691
|
|
692
|
+
# base 64-encoded contents of build.log
|
693
|
+
def build_log_64
|
694
|
+
build_log = File.join(mesa_dir, 'build.log')
|
695
|
+
return '' unless File.exist?(build_log)
|
696
|
+
|
697
|
+
b64_file(build_log)
|
698
|
+
end
|
699
|
+
|
565
700
|
# sourced from $MESA_DIR/testhub.yml, which should be created after
|
566
701
|
# installation
|
567
702
|
def compiler_hash
|
@@ -614,12 +749,16 @@ class Mesa
|
|
614
749
|
num, tc_name = line.strip.split
|
615
750
|
@names_to_numbers[mod][tc_name.strip] = num.to_i
|
616
751
|
@test_case_names[mod] << tc_name.strip
|
617
|
-
|
618
|
-
|
619
|
-
|
620
|
-
|
621
|
-
|
622
|
-
|
752
|
+
begin
|
753
|
+
@test_cases[mod][tc_name.strip] = MesaTestCase.new(
|
754
|
+
test: tc_name.strip,
|
755
|
+
mod: mod,
|
756
|
+
position: num.to_i,
|
757
|
+
mesa: self
|
758
|
+
)
|
759
|
+
rescue TestCaseDirError
|
760
|
+
shell.say "No such test case #{tc_name.strip}. Skipping loading it.", :red
|
761
|
+
end
|
623
762
|
end
|
624
763
|
end
|
625
764
|
end
|
@@ -853,6 +992,36 @@ class MesaTestCase
|
|
853
992
|
YAML.safe_load(File.read(testhub_file), [Symbol])
|
854
993
|
end
|
855
994
|
|
995
|
+
# whether or not a test case has passed; only has meaning
|
996
|
+
# if we can load the results hash, though
|
997
|
+
def passed?
|
998
|
+
results_hash['outcome'] == :pass
|
999
|
+
end
|
1000
|
+
|
1001
|
+
# Base-64 encoded contents of mk.txt file
|
1002
|
+
def mk_64
|
1003
|
+
mk_file = File.join(test_case_dir, 'mk.txt')
|
1004
|
+
return '' unless File.exist?(mk_file)
|
1005
|
+
|
1006
|
+
b64_file(mk_file)
|
1007
|
+
end
|
1008
|
+
|
1009
|
+
# Base-64 encoded contents of err.txt file
|
1010
|
+
def err_64
|
1011
|
+
err_file = File.join(test_case_dir, 'err.txt')
|
1012
|
+
return '' unless File.exist?(err_file)
|
1013
|
+
|
1014
|
+
b64_file(err_file)
|
1015
|
+
end
|
1016
|
+
|
1017
|
+
# Base-64 encoded contents of out.txt file
|
1018
|
+
def out_64
|
1019
|
+
out_file = File.join(test_case_dir, 'out.txt')
|
1020
|
+
return '' unless File.exist?(out_file)
|
1021
|
+
|
1022
|
+
b64_file(out_file)
|
1023
|
+
end
|
1024
|
+
|
856
1025
|
private
|
857
1026
|
|
858
1027
|
# cd into the test case directory, do something in a block, then cd back
|
@@ -951,3 +1120,8 @@ end
|
|
951
1120
|
def bashticks(command)
|
952
1121
|
`bash -c "#{command}"`.chomp
|
953
1122
|
end
|
1123
|
+
|
1124
|
+
# encode the contents of a file as base-64
|
1125
|
+
def b64_file(filename)
|
1126
|
+
Base64.encode64(File.open(filename).read)
|
1127
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mesa_test
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.1.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- William Wolf
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-05-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: json
|
@@ -81,7 +81,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
81
81
|
- !ruby/object:Gem::Version
|
82
82
|
version: '0'
|
83
83
|
requirements: []
|
84
|
-
rubygems_version: 3.
|
84
|
+
rubygems_version: 3.2.3
|
85
85
|
signing_key:
|
86
86
|
specification_version: 4
|
87
87
|
summary: Command line tool for running and reporting the MESA test suites.
|