mesa_test 1.2.0 → 1.2.1

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.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/mesa_test.rb +67 -13
  3. metadata +3 -6
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 77716549c3af3f8960f9d630145619aed3fcc1a35b66f8303d0f5561fe70306a
4
- data.tar.gz: 3a52ee9cbc1f853469979ffaff62ff2e72ef9422a9edc643a13f387747d414da
3
+ metadata.gz: 3c01327f74ca824acf8b7cb473561037281255de396cc623c6c636b9c21bb2ed
4
+ data.tar.gz: 52f1c9d09ece9a85bdfc3827249357ec1ada18da6b14d70793df9b082331bbe9
5
5
  SHA512:
6
- metadata.gz: a1db1bf6457b33ea8e0ce55f4cd6c6fafe3ece040925176748bd49541cdb6ba0540c3c7a6354743685df210a82be0f9acbcd1a9ad692d0be88a012746971eb8c
7
- data.tar.gz: 264f3d0dd767b4bc610cbbd2d736bd387840e675de87a52ef5748453a5c0ffef8a7f90f6a2f0f14019fdb974cee54e9c1ad4c86227c04de5d9e0553f29f5d2a2
6
+ metadata.gz: 91a42fce1cf44a643b465edf60351448ea863ebd8ac4e5f962733928b9c620c1dafb251c38cbc4bd9267309ee6298d96fb05a12b35847a974025aa8a183f9037
7
+ data.tar.gz: 19aca1c41bc5519d8082f7ee5e85398a3652d9b7455f21b4ecf2b2b767084e3abfe5fd52a2630f4a17a8248879e84375549b954453f3c2c79a1acdf6590cd6cf
data/lib/mesa_test.rb CHANGED
@@ -330,7 +330,12 @@ e-mail and password will be stored in plain text.'
330
330
  password: password,
331
331
  computer_name: computer_name
332
332
  }.to_json
333
- JSON.parse(https.request(request).body).to_hash
333
+ response = testhub_request(https, request)
334
+ # if the hub was unreachable, behave as an unverified computer; the
335
+ # network error has already been reported by testhub_request
336
+ return {} if response.nil?
337
+
338
+ JSON.parse(response.body).to_hash
334
339
  end
335
340
 
336
341
  # submit entire commit's worth of test cases, OR submit compilation status
@@ -366,11 +371,15 @@ e-mail and password will be stored in plain text.'
366
371
  request.body = request_data.to_json
367
372
 
368
373
  # actually do the submission
369
- response = https.request request
374
+ response = testhub_request(https, request)
370
375
 
371
- if !response.is_a? Net::HTTPCreated
376
+ if response.nil?
377
+ # network failure; testhub_request already explained why
378
+ false
379
+ elsif !response.is_a? Net::HTTPCreated
372
380
  shell.say "\nFailed to submit some or all test case instances and/or "\
373
- 'commit data.', :red
381
+ "commit data (server responded #{response.code} "\
382
+ "#{response.message}).", :red
374
383
  false
375
384
  else
376
385
  shell.say "\nSuccessfully submitted commit #{mesa.sha}.", :green
@@ -427,12 +436,16 @@ e-mail and password will be stored in plain text.'
427
436
  request.body = request_data.to_json
428
437
 
429
438
  # actually do the submission
430
- response = https.request request
439
+ response = testhub_request(https, request)
431
440
 
432
- if !response.is_a? Net::HTTPCreated
441
+ if response.nil?
442
+ # network failure; testhub_request already explained why
443
+ return false
444
+ elsif !response.is_a? Net::HTTPCreated
433
445
  shell.say "\nFailed to submit #{test_case.test_name} for commit "\
434
- "#{mesa.sha}", :red
435
- false
446
+ "#{mesa.sha} (server responded #{response.code} "\
447
+ "#{response.message}).", :red
448
+ return false
436
449
  else
437
450
  shell.say "\nSuccessfully submitted instance of #{test_case.test_name} "\
438
451
  "for commit #{mesa.sha}.", :green
@@ -444,17 +457,50 @@ e-mail and password will be stored in plain text.'
444
457
  end
445
458
  end
446
459
 
460
+ # Perform an HTTP request against the test hub with bounded connect/read
461
+ # timeouts, so a slow or unreachable server (e.g. while it is under heavy
462
+ # load) fails fast with a clear message instead of hanging on the default
463
+ # 60-second connect timeout and then dumping a raw Ruby backtrace. Returns
464
+ # the Net::HTTPResponse, or +nil+ if the request could not be completed
465
+ # because of a network problem.
466
+ def testhub_request(https, request)
467
+ https.open_timeout = 10
468
+ https.read_timeout = 60
469
+ https.request(request)
470
+ rescue StandardError => e
471
+ shell.say "\nCould not reach the test hub at #{https.address} "\
472
+ "(#{e.class}: #{e.message}).", :red
473
+ nil
474
+ end
475
+
447
476
  # make generic request to LOGS server
448
477
  # +params+ is a hash of data to be encoded as JSON and sent off
478
+ #
479
+ # Returns the Net::HTTPResponse on success, or +nil+ if the request could
480
+ # not be completed because of a network problem (the LOGS server being
481
+ # unreachable, slow, or refusing connections). The LOGS server only receives
482
+ # diagnostic build/test output, so a failure here must never crash the run or
483
+ # fail a CI build whose actual test results already reached the test hub. We
484
+ # cap the connect/read time so we fail fast instead of hanging on the default
485
+ # 60-second open timeout for every test case.
449
486
  def submit_logs(params)
450
487
  #uri = URI('https://logs.mesastar.org/uploads')
451
488
  uri = URI('https://mesa-logs.flatironinstitute.org/uploads')
452
489
  https = Net::HTTP.new(uri.host, uri.port)
453
490
  https.use_ssl = true
491
+ https.open_timeout = 10
492
+ https.read_timeout = 30
454
493
  req = Net::HTTP::Post.new(uri.path, 'Content-Type' => 'application/json',
455
494
  'X-Api-Key' => logs_token)
456
495
  req.body = params.to_json
457
- https.request(req)
496
+ begin
497
+ https.request(req)
498
+ rescue StandardError => e
499
+ shell.say "\nCould not reach the LOGS server at #{uri.host} "\
500
+ "(#{e.class}: #{e.message}). Skipping log upload; this does "\
501
+ 'not affect test results already sent to the test hub.', :yellow
502
+ nil
503
+ end
458
504
  end
459
505
 
460
506
  # send build log to the logs server
@@ -473,9 +519,13 @@ e-mail and password will be stored in plain text.'
473
519
  res = submit_logs(build_log_params(mesa))
474
520
 
475
521
  # report out results
476
- if !res.is_a? Net::HTTPOK
522
+ if res.nil?
523
+ # network failure; submit_logs already explained why. Don't fail the run.
524
+ false
525
+ elsif !res.is_a? Net::HTTPOK
477
526
  shell.say "\nFailed to submit build.log to the LOGS server for commit "\
478
- "#{mesa.sha}.", :red
527
+ "#{mesa.sha} (server responded #{res.code} #{res.message}).",
528
+ :red
479
529
  false
480
530
  else
481
531
  shell.say "\nSuccessfully submitted build.log to the LOGS server for "\
@@ -503,9 +553,13 @@ e-mail and password will be stored in plain text.'
503
553
  res = submit_logs(test_log_params(test_case))
504
554
 
505
555
  # report out results
506
- if !res.is_a? Net::HTTPOK
556
+ if res.nil?
557
+ # network failure; submit_logs already explained why. Don't fail the run.
558
+ false
559
+ elsif !res.is_a? Net::HTTPOK
507
560
  shell.say "Failed to submit logs for test case #{test_case.test_name} "\
508
- "in commit #{test_case.mesa.sha}.", :red
561
+ "in commit #{test_case.mesa.sha} (server responded "\
562
+ "#{res.code} #{res.message}).", :red
509
563
  false
510
564
  else
511
565
  shell.say "Successfully submitted logs for test case "\
metadata CHANGED
@@ -1,14 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mesa_test
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.0
4
+ version: 1.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - William Wolf
8
- autorequire:
9
8
  bindir: bin
10
9
  cert_chain: []
11
- date: 2026-05-26 00:00:00.000000000 Z
10
+ date: 2026-05-29 00:00:00.000000000 Z
12
11
  dependencies:
13
12
  - !ruby/object:Gem::Dependency
14
13
  name: json
@@ -66,7 +65,6 @@ homepage: https://github.com/MESAHub/mesa_test
66
65
  licenses:
67
66
  - MIT
68
67
  metadata: {}
69
- post_install_message:
70
68
  rdoc_options: []
71
69
  require_paths:
72
70
  - lib
@@ -81,8 +79,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
81
79
  - !ruby/object:Gem::Version
82
80
  version: '0'
83
81
  requirements: []
84
- rubygems_version: 3.4.17
85
- signing_key:
82
+ rubygems_version: 3.7.1
86
83
  specification_version: 4
87
84
  summary: Command line tool for running and reporting the MESA test suites.
88
85
  test_files: []