nats-async 0.1.2 → 0.1.4
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/lib/version.rb +1 -1
- data/spec/examples_spec.rb +46 -46
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 6553bb8adf02cd233df4cc933e2105b5ef5c2be79b55872b66143f01d8162890
|
|
4
|
+
data.tar.gz: a0fee08a18816390e046ca7dca4d1763e884584146b5939abc1af2b37aaacdf4
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: e8034ee55ee0f575a42890e0f882286bed6c8db5598511c566d754afb6e87ffd624008c99c073074f28f079f100f0e3c35daface6f07d4c83b115119b3a9ad5e
|
|
7
|
+
data.tar.gz: e3f757abed15e89ccc47ce6d59ad147dc99779522ce56673958270beba773a17394feff856839d958f0cb246f8bc4776e9c8a0ed5c6c435c8a331f6cacd3d5ea
|
data/lib/version.rb
CHANGED
data/spec/examples_spec.rb
CHANGED
|
@@ -11,23 +11,8 @@ require "tempfile"
|
|
|
11
11
|
require "tmpdir"
|
|
12
12
|
|
|
13
13
|
RSpec.describe "example scripts" do
|
|
14
|
-
def report_server_start_failure(reason, log_path)
|
|
15
|
-
log = File.exist?(log_path) ? File.read(log_path) : "(log file missing)"
|
|
16
|
-
message = <<~MSG
|
|
17
|
-
nats-server example integration skipped: #{reason}
|
|
18
|
-
--- nats-server log ---
|
|
19
|
-
#{log}
|
|
20
|
-
--- end nats-server log ---
|
|
21
|
-
MSG
|
|
22
|
-
|
|
23
|
-
warn(message)
|
|
24
|
-
warn("::warning::#{message.gsub("\n", "%0A")}") if ENV["GITHUB_ACTIONS"] == "true"
|
|
25
|
-
skip(message)
|
|
26
|
-
end
|
|
27
|
-
|
|
28
14
|
def project_path = File.expand_path("..", __dir__)
|
|
29
15
|
def server_path = File.join(project_path, "bin", "nats-server")
|
|
30
|
-
def config_path = File.join(project_path, "config", "nats.conf")
|
|
31
16
|
|
|
32
17
|
def free_port
|
|
33
18
|
server = TCPServer.new("127.0.0.1", 0)
|
|
@@ -45,11 +30,21 @@ RSpec.describe "example scripts" do
|
|
|
45
30
|
return
|
|
46
31
|
rescue Errno::ECONNREFUSED, Errno::EHOSTUNREACH
|
|
47
32
|
if Process.waitpid(server_pid, Process::WNOHANG)
|
|
48
|
-
|
|
33
|
+
raise <<~MSG
|
|
34
|
+
bundled nats-server exited before becoming ready
|
|
35
|
+
--- nats-server log ---
|
|
36
|
+
#{File.exist?(log_path) ? File.read(log_path) : "(log file missing)"}
|
|
37
|
+
--- end nats-server log ---
|
|
38
|
+
MSG
|
|
49
39
|
end
|
|
50
40
|
|
|
51
41
|
if Process.clock_gettime(Process::CLOCK_MONOTONIC) >= deadline
|
|
52
|
-
|
|
42
|
+
raise <<~MSG
|
|
43
|
+
bundled nats-server did not start on port #{port}
|
|
44
|
+
--- nats-server log ---
|
|
45
|
+
#{File.exist?(log_path) ? File.read(log_path) : "(log file missing)"}
|
|
46
|
+
--- end nats-server log ---
|
|
47
|
+
MSG
|
|
53
48
|
end
|
|
54
49
|
|
|
55
50
|
sleep 0.1
|
|
@@ -75,37 +70,42 @@ RSpec.describe "example scripts" do
|
|
|
75
70
|
url = "nats://127.0.0.1:#{port}"
|
|
76
71
|
Tempfile.create(["nats-async-example", ".log"]) do |log|
|
|
77
72
|
log_path = log.path
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
run_example("examples/basic_pub_sub.rb", {"NATS_URL" => url})
|
|
93
|
-
run_example(
|
|
94
|
-
"examples/jetstream_roundtrip.rb",
|
|
95
|
-
{
|
|
96
|
-
"NATS_URL" => url,
|
|
97
|
-
"JS_STREAM" => "spec_stream",
|
|
98
|
-
"JS_SUBJECT" => "spec.subject",
|
|
99
|
-
"JS_CONSUMER" => "spec_consumer",
|
|
100
|
-
"JS_PAYLOAD" => "spec payload"
|
|
101
|
-
}
|
|
73
|
+
Tempfile.create(["nats-async", ".conf"]) do |config|
|
|
74
|
+
config.write("debug: true\ntrace: true\n")
|
|
75
|
+
config.flush
|
|
76
|
+
|
|
77
|
+
Dir.mktmpdir("nats-async-js") do |store_dir|
|
|
78
|
+
server = Process.spawn(
|
|
79
|
+
server_path,
|
|
80
|
+
"-c", config.path,
|
|
81
|
+
"-js",
|
|
82
|
+
"-sd", store_dir,
|
|
83
|
+
"-p", port.to_s,
|
|
84
|
+
out: log,
|
|
85
|
+
err: log,
|
|
86
|
+
chdir: project_path
|
|
102
87
|
)
|
|
103
|
-
|
|
88
|
+
|
|
104
89
|
begin
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
90
|
+
wait_for_server(port, server, log_path)
|
|
91
|
+
run_example("examples/basic_pub_sub.rb", {"NATS_URL" => url})
|
|
92
|
+
run_example(
|
|
93
|
+
"examples/jetstream_roundtrip.rb",
|
|
94
|
+
{
|
|
95
|
+
"NATS_URL" => url,
|
|
96
|
+
"JS_STREAM" => "spec_stream",
|
|
97
|
+
"JS_SUBJECT" => "spec.subject",
|
|
98
|
+
"JS_CONSUMER" => "spec_consumer",
|
|
99
|
+
"JS_PAYLOAD" => "spec payload"
|
|
100
|
+
}
|
|
101
|
+
)
|
|
102
|
+
ensure
|
|
103
|
+
begin
|
|
104
|
+
Process.kill("TERM", server)
|
|
105
|
+
Process.wait(server)
|
|
106
|
+
rescue Errno::ESRCH, Process::Waiter::Error
|
|
107
|
+
nil
|
|
108
|
+
end
|
|
109
109
|
end
|
|
110
110
|
end
|
|
111
111
|
end
|