mesa_test 1.1.12 → 1.2.0
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 +60 -0
- data/lib/mesa_test.rb +37 -3
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 77716549c3af3f8960f9d630145619aed3fcc1a35b66f8303d0f5561fe70306a
|
|
4
|
+
data.tar.gz: 3a52ee9cbc1f853469979ffaff62ff2e72ef9422a9edc643a13f387747d414da
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: a1db1bf6457b33ea8e0ce55f4cd6c6fafe3ece040925176748bd49541cdb6ba0540c3c7a6354743685df210a82be0f9acbcd1a9ad692d0be88a012746971eb8c
|
|
7
|
+
data.tar.gz: 264f3d0dd767b4bc610cbbd2d736bd387840e675de87a52ef5748453a5c0ffef8a7f90f6a2f0f14019fdb974cee54e9c1ad4c86227c04de5d9e0553f29f5d2a2
|
data/bin/mesa_test
CHANGED
|
@@ -328,8 +328,68 @@ class MesaTest < Thor
|
|
|
328
328
|
force_setup: true)
|
|
329
329
|
end
|
|
330
330
|
|
|
331
|
+
desc 'search "QUERY"', 'retrieve JSON test instances matching QUERY'
|
|
332
|
+
long_desc <<-LONGDESC
|
|
333
|
+
Sends a GET request to the MesaTestHub search API. QUERY should be
|
|
334
|
+
quoted. Credentials are read from your mesa_test config file and sent as
|
|
335
|
+
URL query parameters (HTTPS is mandatory).
|
|
336
|
+
|
|
337
|
+
Query syntax is the same key-value form used by the in-browser search box
|
|
338
|
+
at testhub.mesastar.org/test_instances/search (see the "Query syntax"
|
|
339
|
+
panel on that page). Example:
|
|
340
|
+
|
|
341
|
+
mesa_test search "computer: Hercules; passed: false"
|
|
342
|
+
|
|
343
|
+
The raw JSON response body is written to STDOUT, suitable for piping to
|
|
344
|
+
jq or redirecting to a file. If the server reports any rejected query
|
|
345
|
+
clauses in a `failures` array, those are also echoed to STDERR so they
|
|
346
|
+
aren't silently dropped from downstream pipelines. On a non-success HTTP
|
|
347
|
+
status, an error is written to STDERR and the command exits non-zero.
|
|
348
|
+
LONGDESC
|
|
349
|
+
|
|
350
|
+
def search(query)
|
|
351
|
+
s = create_submitter(force: true)
|
|
352
|
+
emit_search_response(s.search(query))
|
|
353
|
+
end
|
|
354
|
+
|
|
355
|
+
desc 'count "QUERY"', 'count test instances matching QUERY'
|
|
356
|
+
long_desc <<-LONGDESC
|
|
357
|
+
Like `search`, but hits the count endpoint. The response is a small JSON
|
|
358
|
+
object containing the result-set size (and any `failures`). Use this
|
|
359
|
+
before `search` when you don't know how large a result set will be.
|
|
360
|
+
LONGDESC
|
|
361
|
+
|
|
362
|
+
def count(query)
|
|
363
|
+
s = create_submitter(force: true)
|
|
364
|
+
emit_search_response(s.search_count(query))
|
|
365
|
+
end
|
|
366
|
+
|
|
331
367
|
private
|
|
332
368
|
|
|
369
|
+
def emit_search_response(response)
|
|
370
|
+
if response.is_a?(Net::HTTPSuccess)
|
|
371
|
+
puts response.body
|
|
372
|
+
warn_search_failures(response.body)
|
|
373
|
+
else
|
|
374
|
+
$stderr.puts "Search request failed: HTTP #{response.code} "\
|
|
375
|
+
"#{response.message}"
|
|
376
|
+
$stderr.puts response.body unless response.body.nil? || response.body.empty?
|
|
377
|
+
exit 1
|
|
378
|
+
end
|
|
379
|
+
end
|
|
380
|
+
|
|
381
|
+
def warn_search_failures(body)
|
|
382
|
+
parsed = JSON.parse(body)
|
|
383
|
+
failures = parsed['failures']
|
|
384
|
+
return unless failures.is_a?(Array) && !failures.empty?
|
|
385
|
+
|
|
386
|
+
$stderr.puts 'Warning: the following query clauses were rejected by '\
|
|
387
|
+
'the server and ignored:'
|
|
388
|
+
failures.each { |f| $stderr.puts " - #{f}" }
|
|
389
|
+
rescue JSON::ParserError
|
|
390
|
+
# Body wasn't JSON; nothing to surface.
|
|
391
|
+
end
|
|
392
|
+
|
|
333
393
|
def work_dir(given, default)
|
|
334
394
|
if given
|
|
335
395
|
File.expand_path('', given)
|
data/lib/mesa_test.rb
CHANGED
|
@@ -18,7 +18,6 @@ GITHUB_HTTPS = 'https://github.com/MESAHub/mesa.git'.freeze
|
|
|
18
18
|
GITHUB_SSH = 'git@github.com:MESAHub/mesa.git'.freeze
|
|
19
19
|
|
|
20
20
|
class MesaTestSubmitter
|
|
21
|
-
# DEFAULT_URI = 'https://mesa-test-hub.herokuapp.com'.freeze
|
|
22
21
|
DEFAULT_URI = 'https://testhub.mesastar.org'.freeze
|
|
23
22
|
|
|
24
23
|
# set up config file for computer
|
|
@@ -52,8 +51,9 @@ e-mail and password will be stored in plain text.'
|
|
|
52
51
|
|
|
53
52
|
# Get API key for submitting failure logs
|
|
54
53
|
response = shell.ask 'What is the logs submission API token associated '\
|
|
55
|
-
"with the email #{s.email} (required;
|
|
56
|
-
"
|
|
54
|
+
"with the email #{s.email} (required; if you don't have one, ask a "\
|
|
55
|
+
"MESA testing maintainer or a representative from Flatiron for a "\
|
|
56
|
+
"key)? (#{s.logs_token})", :blue
|
|
57
57
|
s.logs_token = response unless response.empty?
|
|
58
58
|
|
|
59
59
|
# Determine if we'll use ssh or https to access github
|
|
@@ -515,6 +515,40 @@ e-mail and password will be stored in plain text.'
|
|
|
515
515
|
end
|
|
516
516
|
end
|
|
517
517
|
|
|
518
|
+
# GET a search query from the testhub. Credentials and the query string
|
|
519
|
+
# ride in the URL's query parameters (per the testhub search API contract;
|
|
520
|
+
# the controller also accepts session auth, but a CLI sends them in-band).
|
|
521
|
+
# Returns the raw Net::HTTP response.
|
|
522
|
+
def search(query_text)
|
|
523
|
+
get_search('/test_instances/search.json', query_text)
|
|
524
|
+
end
|
|
525
|
+
|
|
526
|
+
# Like #search, but hits the count endpoint. Useful for sizing a result set
|
|
527
|
+
# before pulling the full payload.
|
|
528
|
+
def search_count(query_text)
|
|
529
|
+
get_search('/test_instances/search_count.json', query_text)
|
|
530
|
+
end
|
|
531
|
+
|
|
532
|
+
private
|
|
533
|
+
|
|
534
|
+
def get_search(path, query_text)
|
|
535
|
+
uri = URI.parse(base_uri + path)
|
|
536
|
+
uri.query = URI.encode_www_form(
|
|
537
|
+
email: email,
|
|
538
|
+
password: password,
|
|
539
|
+
query_text: query_text
|
|
540
|
+
)
|
|
541
|
+
|
|
542
|
+
https = Net::HTTP.new(uri.hostname, uri.port)
|
|
543
|
+
https.use_ssl = base_uri.include? 'https'
|
|
544
|
+
|
|
545
|
+
request = Net::HTTP::Get.new(
|
|
546
|
+
uri,
|
|
547
|
+
initheader = { 'Accept' => 'application/json' }
|
|
548
|
+
)
|
|
549
|
+
|
|
550
|
+
https.request(request)
|
|
551
|
+
end
|
|
518
552
|
end
|
|
519
553
|
|
|
520
554
|
class Mesa
|
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.2.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- William Wolf
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2026-05-
|
|
11
|
+
date: 2026-05-26 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: json
|