tiny-presto 0.0.1 → 0.0.2
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/.github/workflows/ruby.yml +20 -0
- data/Gemfile +1 -0
- data/Gemfile.lock +2 -0
- data/README.md +8 -2
- data/lib/tiny-presto.rb +6 -2
- data/lib/tiny-presto/cluster.rb +4 -0
- data/lib/tiny-presto/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5e2bdd215986246b63650c85c8d78eabd47e481fa51a665e0a22264f079e24af
|
4
|
+
data.tar.gz: 3e9d922298a4ff0e9ac6e1d9aaf4993cdad8cc680b5fa1985914d176d2985cdf
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c99b29e972147490ac5fbe3d50b3ce870aff7dd368d77ccbdd73739c36ca7f593718e89b2fc9b56c583d6e8a5b51d90a4a9ae3630f7cf22417cb7c3dfc974390
|
7
|
+
data.tar.gz: 4946f97714fab4f02b9235f5f87c2c615d097d4770fa3762115a7a3c8ce023704c182002773d6253e1b384daf81d48813720ccd0711b90a3df3f4d37f47deb3b
|
@@ -0,0 +1,20 @@
|
|
1
|
+
name: test
|
2
|
+
|
3
|
+
on: [push]
|
4
|
+
|
5
|
+
jobs:
|
6
|
+
build:
|
7
|
+
|
8
|
+
runs-on: ubuntu-latest
|
9
|
+
|
10
|
+
steps:
|
11
|
+
- uses: actions/checkout@v1
|
12
|
+
- name: Set up Ruby 2.6
|
13
|
+
uses: actions/setup-ruby@v1
|
14
|
+
with:
|
15
|
+
ruby-version: 2.6.x
|
16
|
+
- name: Build and test with Rake
|
17
|
+
run: |
|
18
|
+
gem install bundler
|
19
|
+
bundle install --jobs 4 --retry 3
|
20
|
+
bundle exec rake spec
|
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
@@ -21,6 +21,7 @@ GEM
|
|
21
21
|
msgpack (>= 0.7.0)
|
22
22
|
rainbow (3.0.0)
|
23
23
|
rake (13.0.1)
|
24
|
+
rdoc (6.2.1)
|
24
25
|
rspec (3.8.0)
|
25
26
|
rspec-core (~> 3.8.0)
|
26
27
|
rspec-expectations (~> 3.8.0)
|
@@ -51,6 +52,7 @@ DEPENDENCIES
|
|
51
52
|
docker-api
|
52
53
|
presto-client
|
53
54
|
rake
|
55
|
+
rdoc
|
54
56
|
rspec
|
55
57
|
rubocop
|
56
58
|
|
data/README.md
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
# tiny-presto
|
1
|
+
# tiny-presto [](https://github.com/Lewuathe/tiny-presto/actions)  
|
2
2
|
|
3
3
|
Tiny [Presto](https://prestosql.io/) cluster to check the compatibility of query result by using the specific Presto version.
|
4
4
|
|
@@ -36,4 +36,10 @@ To check the result consistency, `verify` method is available.
|
|
36
36
|
```ruby
|
37
37
|
result = TinyPresto.verify('show schemas', [["default"], ["information_schema"]])
|
38
38
|
# result is true if the returned value by the query matched with the given expected result.
|
39
|
-
```
|
39
|
+
```
|
40
|
+
|
41
|
+
To ensure to delete the tiny-presto cluster, make sure to call `ensure_stop` before exiting.
|
42
|
+
|
43
|
+
```ruby
|
44
|
+
TinyPresto.ensure_stop
|
45
|
+
```
|
data/lib/tiny-presto.rb
CHANGED
@@ -5,6 +5,7 @@ require 'singleton'
|
|
5
5
|
require 'presto-client'
|
6
6
|
|
7
7
|
module TinyPresto
|
8
|
+
# Singleton object representing a Presto cluster running in the local machine.
|
8
9
|
class TinyPresto
|
9
10
|
include Singleton
|
10
11
|
|
@@ -19,7 +20,7 @@ module TinyPresto
|
|
19
20
|
begin
|
20
21
|
@client.run('show schemas')
|
21
22
|
break
|
22
|
-
rescue StandardError =>
|
23
|
+
rescue StandardError => _
|
23
24
|
# Waiting for the cluster is launched
|
24
25
|
sleep(1)
|
25
26
|
end
|
@@ -31,20 +32,23 @@ module TinyPresto
|
|
31
32
|
end
|
32
33
|
end
|
33
34
|
|
35
|
+
# Run the given SQL.
|
34
36
|
def self.run(sql)
|
35
37
|
presto = TinyPresto.instance
|
36
38
|
_, rows = presto.client.run(sql)
|
37
39
|
rows
|
38
40
|
end
|
39
41
|
|
42
|
+
# Run the given SQL and verify the result.
|
40
43
|
def self.verify(sql, expected_result)
|
41
44
|
presto = TinyPresto.instance
|
42
45
|
_, rows = presto.client.run(sql)
|
43
46
|
rows == expected_result
|
44
47
|
end
|
45
48
|
|
49
|
+
# Make sure to stop the cluster.
|
46
50
|
def self.ensure_stop
|
47
51
|
presto = TinyPresto.instance
|
48
52
|
presto.stop
|
49
53
|
end
|
50
|
-
end
|
54
|
+
end
|
data/lib/tiny-presto/cluster.rb
CHANGED
@@ -1,6 +1,8 @@
|
|
1
1
|
require 'docker-api'
|
2
2
|
|
3
3
|
module TinyPresto
|
4
|
+
# Represents a Presto cluster
|
5
|
+
#
|
4
6
|
class Cluster
|
5
7
|
def initialize(url, tag = 'latest')
|
6
8
|
@url = url
|
@@ -8,6 +10,7 @@ module TinyPresto
|
|
8
10
|
@image_name = "prestosql/presto:#{@tag}"
|
9
11
|
end
|
10
12
|
|
13
|
+
# Launch Presto cluster running on Docker container
|
11
14
|
def run
|
12
15
|
# Ensure to pull the specified image
|
13
16
|
Docker::Image.create('fromImage' => @image_name)
|
@@ -27,6 +30,7 @@ module TinyPresto
|
|
27
30
|
@container
|
28
31
|
end
|
29
32
|
|
33
|
+
# Kill Presto cluster process
|
30
34
|
def stop
|
31
35
|
@container.stop
|
32
36
|
end
|
data/lib/tiny-presto/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: tiny-presto
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Kai Sasaki
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-01-
|
11
|
+
date: 2020-01-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: docker-api
|
@@ -73,6 +73,7 @@ executables: []
|
|
73
73
|
extensions: []
|
74
74
|
extra_rdoc_files: []
|
75
75
|
files:
|
76
|
+
- ".github/workflows/ruby.yml"
|
76
77
|
- ".gitignore"
|
77
78
|
- ".pre-commit-config.yaml"
|
78
79
|
- ".rubocop.yml"
|