cequel 3.0.1 → 3.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +4 -0
- data/CONTRIBUTING.md +23 -25
- data/Gemfile.lock +12 -17
- data/Rakefile +0 -14
- data/lib/cequel/metal/new_relic_instrumentation.rb +2 -1
- data/lib/cequel/type.rb +21 -1
- data/lib/cequel/uuids.rb +8 -0
- data/lib/cequel/version.rb +1 -1
- data/spec/examples/record/record_set_spec.rb +12 -0
- data/spec/examples/type_spec.rb +14 -0
- metadata +24 -25
- data/Vagrantfile +0 -150
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c1697dbd75c69854dffccbe95b14689a6f5d4453
|
4
|
+
data.tar.gz: 62a729f6421425b0fdf188fca359498520f09ac1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 13716de6aa85d3007df82a7330f1cca8e0cc46f08b4ac477a0381222bd01301b58a439e58c15a19561361cb26221fff6be7cc5c02ebba495b4ded5724efbf8e0
|
7
|
+
data.tar.gz: 8ed5d80b009c48845ff74e3d2ccca6001408525131591caf6eb1aee4df9e77dc18112bb88f8ff4c1495c31917485a4a7415bf0ac9d6721a741e63946e6ebcf6b
|
data/CHANGELOG.md
CHANGED
data/CONTRIBUTING.md
CHANGED
@@ -6,7 +6,7 @@ Contributions to Cequel are highly welcome! Here's a quick guide.
|
|
6
6
|
|
7
7
|
1. Fork the repo and create a topic branch
|
8
8
|
2. Set up your environment and run the tests. The easiest way to do this is to
|
9
|
-
use
|
9
|
+
use Docker; [see below](#running-the-tests). For those who already have a suitable Cassandra
|
10
10
|
instance running locally: `rake test`
|
11
11
|
3. Add tests for your change.
|
12
12
|
4. Make the tests pass.
|
@@ -30,35 +30,33 @@ Contributions to Cequel are highly welcome! Here's a quick guide.
|
|
30
30
|
|
31
31
|
### For the impatient ###
|
32
32
|
|
33
|
+
[Install Docker](https://docs.docker.com/engine/installation/) first, then run tests:
|
33
34
|
```bash
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
$ brew cask install virtualbox vagrant
|
40
|
-
$ vagrant up 2.2.5
|
41
|
-
$ rake test
|
35
|
+
git clone git@github.com:yourname/cequel.git
|
36
|
+
cd cequel
|
37
|
+
git remote add upstream git@github.com:cequel/cequel.git
|
38
|
+
bundle install
|
39
|
+
bundle exec rake test
|
42
40
|
```
|
43
41
|
|
44
|
-
### Using
|
42
|
+
### Using Docker
|
45
43
|
|
46
44
|
Cequel's test suite runs against a live Cassandra instance. The easiest way to
|
47
|
-
get one is to use
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
Cequel is tested against a large range of Ruby, Rails, and Cassandra
|
58
|
-
for most patches, you can just run the tests using the
|
59
|
-
them. If you're messing with the
|
60
|
-
you'll want to test at
|
61
|
-
|
45
|
+
get one is to use Docker, `docker run --rm -p 9042:9042 cassandra`.
|
46
|
+
|
47
|
+
### Using different ports
|
48
|
+
|
49
|
+
You can configure the cequel test suite to use a different port by setting the `CEQUEL_TEST_PORT` environment variable. Example:
|
50
|
+
1. `docker run --rm -p 33333:9042 cassandra` in one terminal
|
51
|
+
1. `rake test CEQUEL_TEST_PORT=33333` in another termainal
|
52
|
+
|
53
|
+
### Cassandra versions
|
54
|
+
|
55
|
+
Cequel is tested against a large range of Ruby, Rails, and Cassandra
|
56
|
+
versions; for most patches, you can just run the tests using the
|
57
|
+
latest version of all of them. If you're messing with the
|
58
|
+
`Cequel::Schema` or `Cequel::Type` modules, you'll want to test at
|
59
|
+
least against the first and latest releases of 2.1, 2.2 and 3 series.
|
62
60
|
|
63
61
|
## And finally
|
64
62
|
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
cequel (3.0.
|
4
|
+
cequel (3.0.2)
|
5
5
|
activemodel (>= 4.0)
|
6
6
|
cassandra-driver (~> 3.0)
|
7
7
|
|
@@ -20,19 +20,16 @@ GEM
|
|
20
20
|
bundler
|
21
21
|
rake
|
22
22
|
thor (>= 0.14.0)
|
23
|
-
ast (2.
|
23
|
+
ast (2.4.0)
|
24
24
|
backports (3.10.3)
|
25
25
|
byebug (2.7.0)
|
26
26
|
columnize (~> 0.3)
|
27
27
|
debugger-linecache (~> 1.2)
|
28
28
|
cassandra-driver (3.2.0)
|
29
29
|
ione (~> 1.2)
|
30
|
-
cassandra-driver (3.2.0-java)
|
31
|
-
ione (~> 1.2)
|
32
30
|
coderay (1.1.2)
|
33
31
|
columnize (0.9.0)
|
34
32
|
concurrent-ruby (1.0.5)
|
35
|
-
concurrent-ruby (1.0.5-java)
|
36
33
|
debugger-linecache (1.2.0)
|
37
34
|
diff-lcs (1.3)
|
38
35
|
ethon (0.11.0)
|
@@ -68,9 +65,9 @@ GEM
|
|
68
65
|
multipart-post (2.0.0)
|
69
66
|
net-http-persistent (2.9.4)
|
70
67
|
net-http-pipeline (1.0.1)
|
71
|
-
parallel (1.12.
|
72
|
-
parser (2.
|
73
|
-
ast (~> 2.
|
68
|
+
parallel (1.12.1)
|
69
|
+
parser (2.5.0.5)
|
70
|
+
ast (~> 2.4.0)
|
74
71
|
powerpack (0.1.1)
|
75
72
|
pry (0.11.2)
|
76
73
|
coderay (~> 1.1.0)
|
@@ -84,14 +81,13 @@ GEM
|
|
84
81
|
json
|
85
82
|
websocket (~> 1.0)
|
86
83
|
racc (1.4.14)
|
87
|
-
rainbow (
|
88
|
-
rake
|
84
|
+
rainbow (3.0.0)
|
89
85
|
rake (10.5.0)
|
90
86
|
rspec (3.7.0)
|
91
87
|
rspec-core (~> 3.7.0)
|
92
88
|
rspec-expectations (~> 3.7.0)
|
93
89
|
rspec-mocks (~> 3.7.0)
|
94
|
-
rspec-core (3.7.
|
90
|
+
rspec-core (3.7.1)
|
95
91
|
rspec-support (~> 3.7.0)
|
96
92
|
rspec-expectations (3.7.0)
|
97
93
|
diff-lcs (>= 1.2.0, < 2.0)
|
@@ -104,12 +100,12 @@ GEM
|
|
104
100
|
rspec-support (~> 3.7.0)
|
105
101
|
rspec-retry (0.5.6)
|
106
102
|
rspec-core (> 3.3, < 3.8)
|
107
|
-
rspec-support (3.7.
|
108
|
-
rubocop (0.
|
103
|
+
rspec-support (3.7.1)
|
104
|
+
rubocop (0.54.0)
|
109
105
|
parallel (~> 1.10)
|
110
|
-
parser (>= 2.
|
106
|
+
parser (>= 2.5)
|
111
107
|
powerpack (~> 0.1)
|
112
|
-
rainbow (>= 2.2.2, <
|
108
|
+
rainbow (>= 2.2.2, < 4.0)
|
113
109
|
ruby-progressbar (~> 1.7)
|
114
110
|
unicode-display_width (~> 1.0, >= 1.0.1)
|
115
111
|
ruby-progressbar (1.9.0)
|
@@ -319,7 +315,6 @@ GEM
|
|
319
315
|
ffi
|
320
316
|
thor (0.20.0)
|
321
317
|
thread_safe (0.3.6)
|
322
|
-
thread_safe (0.3.6-java)
|
323
318
|
timecop (0.9.1)
|
324
319
|
travis (1.8.8)
|
325
320
|
backports
|
@@ -337,7 +332,7 @@ GEM
|
|
337
332
|
unicode-display_width (1.3.0)
|
338
333
|
websocket (1.2.4)
|
339
334
|
wwtd (0.9.1)
|
340
|
-
yard (0.9.
|
335
|
+
yard (0.9.12)
|
341
336
|
|
342
337
|
PLATFORMS
|
343
338
|
java
|
data/Rakefile
CHANGED
@@ -119,17 +119,3 @@ task :verify_changelog do
|
|
119
119
|
end
|
120
120
|
end
|
121
121
|
|
122
|
-
namespace :cassandra do
|
123
|
-
namespace :versions do
|
124
|
-
desc 'Update list of available Cassandra versions'
|
125
|
-
task :update do
|
126
|
-
listing = Net::HTTP.get(URI.parse("http://archive.apache.org/dist/cassandra/"))
|
127
|
-
versions = listing.scan(%r(href="(\d+\.\d+\.\d+)/")).map(&:first)
|
128
|
-
File.open(File.expand_path('../.cassandra-versions', __FILE__), 'w') do |f|
|
129
|
-
f.puts "# This file is automatically generated by `rake cassandra:versions:update`"
|
130
|
-
f.puts "# do not edit by hand."
|
131
|
-
f.puts(versions.sort_by(&Gem::Version.method(:new)).join("\n"))
|
132
|
-
end
|
133
|
-
end
|
134
|
-
end
|
135
|
-
end
|
data/lib/cequel/type.rb
CHANGED
@@ -88,7 +88,7 @@ module Cequel
|
|
88
88
|
(value.to_r * 1000).round.to_s
|
89
89
|
when DateTime
|
90
90
|
quote(value.utc.to_time)
|
91
|
-
when Date
|
91
|
+
when ::Date
|
92
92
|
quote(Time.gm(value.year, value.month, value.day))
|
93
93
|
when Numeric, true, false, Cassandra::Uuid
|
94
94
|
value.to_s
|
@@ -401,6 +401,26 @@ module Cequel
|
|
401
401
|
end
|
402
402
|
register Timestamp.instance
|
403
403
|
|
404
|
+
#
|
405
|
+
# `date` columns store dates.
|
406
|
+
#
|
407
|
+
# @see http://cassandra.apache.org/doc/cql3/CQL-3.0.html#usingdates
|
408
|
+
# CQL3 documentation for date columns
|
409
|
+
#
|
410
|
+
class Date < Base
|
411
|
+
def internal_names
|
412
|
+
['org.apache.cassandra.db.marshal.DateType']
|
413
|
+
end
|
414
|
+
|
415
|
+
def cast(value)
|
416
|
+
if value.is_a?(::String) then ::Date.parse(value)
|
417
|
+
elsif value.respond_to?(:to_date) then value.to_date
|
418
|
+
else ::Date.parse(value.to_s)
|
419
|
+
end
|
420
|
+
end
|
421
|
+
end
|
422
|
+
register Date.instance
|
423
|
+
|
404
424
|
#
|
405
425
|
# `uuid` columns store type 1 and type 4 UUIDs. New UUID instances can be
|
406
426
|
# created using the {Cequel.uuid} method, and a value can be checked to see
|
data/lib/cequel/uuids.rb
CHANGED
@@ -34,11 +34,19 @@ module Cequel
|
|
34
34
|
# @return [Boolean] true if the object is recognized by Cequel as a UUID
|
35
35
|
#
|
36
36
|
def uuid?(object)
|
37
|
+
return true if uuid_in_string?(object)
|
38
|
+
|
37
39
|
object.is_a?(Cassandra::Uuid)
|
38
40
|
end
|
39
41
|
|
40
42
|
private
|
41
43
|
|
44
|
+
def uuid_in_string?(object)
|
45
|
+
object.is_a?(String) && Cassandra::Uuid.new(object)
|
46
|
+
rescue ArgumentError
|
47
|
+
false
|
48
|
+
end
|
49
|
+
|
42
50
|
def timeuuid_generator
|
43
51
|
@timeuuid_generator ||= Cassandra::TimeUuid::Generator.new
|
44
52
|
end
|
data/lib/cequel/version.rb
CHANGED
@@ -462,6 +462,7 @@ describe Cequel::Record::RecordSet do
|
|
462
462
|
|
463
463
|
describe '#after' do
|
464
464
|
let(:records) { [posts, published_posts] }
|
465
|
+
let(:published_at_uuid) { published_posts[2].published_at }
|
465
466
|
|
466
467
|
it 'should return collection after given key' do
|
467
468
|
expect(Post['cassandra'].after('cequel1').map(&:title)).
|
@@ -473,6 +474,11 @@ describe Cequel::Record::RecordSet do
|
|
473
474
|
map(&:title)).to eq((2...5).map { |i| "Cequel #{i}" })
|
474
475
|
end
|
475
476
|
|
477
|
+
it 'should query Time range for Timeuuid key with Timeuuid argument' do
|
478
|
+
expect(PublishedPost['cassandra'].after(published_at_uuid).map(&:permalink)).
|
479
|
+
to eq(%w(cequel4 cequel3))
|
480
|
+
end
|
481
|
+
|
476
482
|
it 'should query Time range for Timeuuid key' do
|
477
483
|
expect(PublishedPost['cassandra'].after(now - 3.minutes).map(&:permalink)).
|
478
484
|
to eq(%w(cequel4 cequel3 cequel2))
|
@@ -505,6 +511,7 @@ describe Cequel::Record::RecordSet do
|
|
505
511
|
|
506
512
|
describe '#before' do
|
507
513
|
let(:records) { [posts, published_posts] }
|
514
|
+
let(:published_at_uuid) { published_posts[3].published_at }
|
508
515
|
|
509
516
|
it 'should return collection before given key' do
|
510
517
|
expect(Post['cassandra'].before('cequel3').map(&:title)).
|
@@ -516,6 +523,11 @@ describe Cequel::Record::RecordSet do
|
|
516
523
|
to eq(%w(cequel2 cequel1 cequel0))
|
517
524
|
end
|
518
525
|
|
526
|
+
it 'should query Time range for Timeuuid key with Timeuuid argument' do
|
527
|
+
expect(PublishedPost['cassandra'].before(published_at_uuid).map(&:permalink)).
|
528
|
+
to eq(%w(cequel2 cequel1 cequel0))
|
529
|
+
end
|
530
|
+
|
519
531
|
it 'should cast argument' do
|
520
532
|
expect(Post['cassandra'].before('cequel3'.force_encoding('ASCII-8BIT')).
|
521
533
|
map(&:title)).to eq((0...3).map { |i| "Cequel #{i}" })
|
data/spec/examples/type_spec.rb
CHANGED
@@ -164,6 +164,20 @@ describe Cequel::Type do
|
|
164
164
|
end
|
165
165
|
end
|
166
166
|
|
167
|
+
describe 'date' do
|
168
|
+
subject { Cequel::Type[:date] }
|
169
|
+
its(:cql_name) { should == :date }
|
170
|
+
its(:internal_name) { should == 'org.apache.cassandra.db.marshal.DateType' }
|
171
|
+
|
172
|
+
describe '#cast' do
|
173
|
+
let(:today) { Date.today }
|
174
|
+
specify { expect(subject.cast(today)).to eq(today) }
|
175
|
+
specify { expect(subject.cast(today.to_s)).to eq(today) }
|
176
|
+
specify { expect(subject.cast(today.to_datetime)).to eq(today) }
|
177
|
+
specify { expect(subject.cast(today.to_time)).to eq(today) }
|
178
|
+
end
|
179
|
+
end
|
180
|
+
|
167
181
|
describe 'timeuuid' do
|
168
182
|
subject { Cequel::Type[:timeuuid] }
|
169
183
|
its(:cql_name) { should == :timeuuid }
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cequel
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.0.
|
4
|
+
version: 3.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Mat Brown
|
@@ -29,7 +29,7 @@ authors:
|
|
29
29
|
autorequire:
|
30
30
|
bindir: bin
|
31
31
|
cert_chain: []
|
32
|
-
date:
|
32
|
+
date: 2018-04-11 00:00:00.000000000 Z
|
33
33
|
dependencies:
|
34
34
|
- !ruby/object:Gem::Dependency
|
35
35
|
name: activemodel
|
@@ -218,7 +218,6 @@ files:
|
|
218
218
|
- LICENSE
|
219
219
|
- README.md
|
220
220
|
- Rakefile
|
221
|
-
- Vagrantfile
|
222
221
|
- lib/cequel.rb
|
223
222
|
- lib/cequel/errors.rb
|
224
223
|
- lib/cequel/instrumentation.rb
|
@@ -348,34 +347,34 @@ signing_key:
|
|
348
347
|
specification_version: 4
|
349
348
|
summary: Full-featured, ActiveModel-compliant ORM for Cassandra using CQL3
|
350
349
|
test_files:
|
351
|
-
- spec/examples/
|
352
|
-
- spec/examples/
|
353
|
-
- spec/examples/record/
|
354
|
-
- spec/examples/record/
|
350
|
+
- spec/examples/spec_helper.rb
|
351
|
+
- spec/examples/spec_support/preparation_spec.rb
|
352
|
+
- spec/examples/record/properties_spec.rb
|
353
|
+
- spec/examples/record/spec_helper.rb
|
354
|
+
- spec/examples/record/mass_assignment_spec.rb
|
355
|
+
- spec/examples/record/serialization_spec.rb
|
355
356
|
- spec/examples/record/dirty_spec.rb
|
356
|
-
- spec/examples/record/
|
357
|
-
- spec/examples/record/lazy_record_collection_spec.rb
|
357
|
+
- spec/examples/record/associations_spec.rb
|
358
358
|
- spec/examples/record/list_spec.rb
|
359
|
+
- spec/examples/record/set_spec.rb
|
360
|
+
- spec/examples/record/validations_spec.rb
|
361
|
+
- spec/examples/record/record_set_spec.rb
|
359
362
|
- spec/examples/record/map_spec.rb
|
360
|
-
- spec/examples/record/
|
361
|
-
- spec/examples/record/naming_spec.rb
|
363
|
+
- spec/examples/record/timestamps_spec.rb
|
362
364
|
- spec/examples/record/persistence_spec.rb
|
363
|
-
- spec/examples/record/
|
364
|
-
- spec/examples/record/
|
365
|
+
- spec/examples/record/naming_spec.rb
|
366
|
+
- spec/examples/record/callbacks_spec.rb
|
365
367
|
- spec/examples/record/schema_spec.rb
|
368
|
+
- spec/examples/record/lazy_record_collection_spec.rb
|
366
369
|
- spec/examples/record/scoped_spec.rb
|
367
|
-
- spec/examples/record/
|
368
|
-
- spec/examples/
|
369
|
-
- spec/examples/
|
370
|
-
- spec/examples/
|
371
|
-
- spec/examples/
|
372
|
-
- spec/examples/schema/
|
370
|
+
- spec/examples/record/finders_spec.rb
|
371
|
+
- spec/examples/metal/data_set_spec.rb
|
372
|
+
- spec/examples/metal/keyspace_spec.rb
|
373
|
+
- spec/examples/type_spec.rb
|
374
|
+
- spec/examples/schema/table_writer_spec.rb
|
375
|
+
- spec/examples/schema/table_updater_spec.rb
|
373
376
|
- spec/examples/schema/patch_spec.rb
|
374
|
-
- spec/examples/schema/table_differ_spec.rb
|
375
377
|
- spec/examples/schema/table_reader_spec.rb
|
376
|
-
- spec/examples/schema/
|
377
|
-
- spec/examples/schema/
|
378
|
-
- spec/examples/spec_helper.rb
|
379
|
-
- spec/examples/spec_support/preparation_spec.rb
|
380
|
-
- spec/examples/type_spec.rb
|
378
|
+
- spec/examples/schema/table_differ_spec.rb
|
379
|
+
- spec/examples/schema/keyspace_spec.rb
|
381
380
|
- spec/examples/uuids_spec.rb
|
data/Vagrantfile
DELETED
@@ -1,150 +0,0 @@
|
|
1
|
-
# -*- mode: ruby -*-
|
2
|
-
# vi: set ft=ruby :
|
3
|
-
require 'net/http'
|
4
|
-
|
5
|
-
# Vagrantfile API/syntax version. Don't touch unless you know what you're doing!
|
6
|
-
VAGRANTFILE_API_VERSION = "2"
|
7
|
-
|
8
|
-
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
|
9
|
-
# All Vagrant configuration is done here. The most common configuration
|
10
|
-
# options are documented and commented below. For a complete reference,
|
11
|
-
# please see the online documentation at vagrantup.com.
|
12
|
-
|
13
|
-
# Every Vagrant virtual environment requires a box to build off of.
|
14
|
-
config.vm.box = "ubuntu/trusty64"
|
15
|
-
|
16
|
-
# The url from where the 'config.vm.box' box will be fetched if it
|
17
|
-
# doesn't already exist on the user's system.
|
18
|
-
config.vm.box_url = "http://cloud-images.ubuntu.com/vagrant/precise/current/precise-server-cloudimg-amd64-vagrant-disk1.box"
|
19
|
-
|
20
|
-
# Create a forwarded port mapping which allows access to a specific port
|
21
|
-
# within the machine from a port on the host machine. In the example below,
|
22
|
-
# accessing "localhost:8080" will access port 80 on the guest machine.
|
23
|
-
# config.vm.network :forwarded_port, guest: 80, host: 8080
|
24
|
-
|
25
|
-
# Create a private network, which allows host-only access to the machine
|
26
|
-
# using a specific IP.
|
27
|
-
# config.vm.network :private_network, ip: "192.168.33.10"
|
28
|
-
|
29
|
-
# Create a public network, which generally matched to bridged network.
|
30
|
-
# Bridged networks make the machine appear as another physical device on
|
31
|
-
# your network.
|
32
|
-
# config.vm.network :public_network
|
33
|
-
|
34
|
-
# If true, then any SSH connections made will enable agent forwarding.
|
35
|
-
# Default value: false
|
36
|
-
# config.ssh.forward_agent = true
|
37
|
-
|
38
|
-
# Share an additional folder to the guest VM. The first argument is
|
39
|
-
# the path on the host to the actual folder. The second argument is
|
40
|
-
# the path on the guest to mount the folder. And the optional third
|
41
|
-
# argument is a set of non-required options.
|
42
|
-
config.vm.synced_folder ".", "/vagrant", disabled: true
|
43
|
-
|
44
|
-
# Provider-specific configuration so you can fine-tune various
|
45
|
-
# backing providers for Vagrant. These expose provider-specific options.
|
46
|
-
# Example for VirtualBox:
|
47
|
-
#
|
48
|
-
config.vm.provider :virtualbox do |vb|
|
49
|
-
vb.memory = 1024
|
50
|
-
end
|
51
|
-
#
|
52
|
-
# View the documentation for the provider you're using for more
|
53
|
-
# information on available options.
|
54
|
-
|
55
|
-
# Enable provisioning with Puppet stand alone. Puppet manifests
|
56
|
-
# are contained in a directory path relative to this Vagrantfile.
|
57
|
-
# You will need to create the manifests directory and a manifest in
|
58
|
-
# the file base.pp in the manifests_path directory.
|
59
|
-
#
|
60
|
-
# An example Puppet manifest to provision the message of the day:
|
61
|
-
#
|
62
|
-
# # group { "puppet":
|
63
|
-
# # ensure => "present",
|
64
|
-
# # }
|
65
|
-
# #
|
66
|
-
# # File { owner => 0, group => 0, mode => 0644 }
|
67
|
-
# #
|
68
|
-
# # file { '/etc/motd':
|
69
|
-
# # content => "Welcome to your Vagrant-built virtual machine!
|
70
|
-
# # Managed by Puppet.\n"
|
71
|
-
# # }
|
72
|
-
#
|
73
|
-
# config.vm.provision :puppet do |puppet|
|
74
|
-
# puppet.manifests_path = "manifests"
|
75
|
-
# puppet.manifest_file = "site.pp"
|
76
|
-
# end
|
77
|
-
|
78
|
-
# Enable provisioning with chef solo, specifying a cookbooks path, roles
|
79
|
-
# path, and data_bags path (all relative to this Vagrantfile), and adding
|
80
|
-
# some recipes and/or roles.
|
81
|
-
#
|
82
|
-
# config.vm.provision :chef_solo do |chef|
|
83
|
-
# chef.cookbooks_path = "../my-recipes/cookbooks"
|
84
|
-
# chef.roles_path = "../my-recipes/roles"
|
85
|
-
# chef.data_bags_path = "../my-recipes/data_bags"
|
86
|
-
# chef.add_recipe "mysql"
|
87
|
-
# chef.add_role "web"
|
88
|
-
#
|
89
|
-
# # You may also specify custom JSON attributes:
|
90
|
-
# chef.json = { :mysql_password => "foo" }
|
91
|
-
# end
|
92
|
-
|
93
|
-
# Enable provisioning with chef server, specifying the chef server URL,
|
94
|
-
# and the path to the validation key (relative to this Vagrantfile).
|
95
|
-
#
|
96
|
-
# The Opscode Platform uses HTTPS. Substitute your organization for
|
97
|
-
# ORGNAME in the URL and validation key.
|
98
|
-
#
|
99
|
-
# If you have your own Chef Server, use the appropriate URL, which may be
|
100
|
-
# HTTP instead of HTTPS depending on your configuration. Also change the
|
101
|
-
# validation key to validation.pem.
|
102
|
-
#
|
103
|
-
# config.vm.provision :chef_client do |chef|
|
104
|
-
# chef.chef_server_url = "https://api.opscode.com/organizations/ORGNAME"
|
105
|
-
# chef.validation_key_path = "ORGNAME-validator.pem"
|
106
|
-
# end
|
107
|
-
#
|
108
|
-
# If you're using the Opscode platform, your validator client is
|
109
|
-
# ORGNAME-validator, replacing ORGNAME with your organization name.
|
110
|
-
#
|
111
|
-
# If you have your own Chef Server, the default validation client name is
|
112
|
-
# chef-validator, unless you changed the configuration.
|
113
|
-
#
|
114
|
-
# chef.validation_client_name = "ORGNAME-validator"
|
115
|
-
provision = <<-SH
|
116
|
-
set -e
|
117
|
-
apt-get update
|
118
|
-
env DEBIAN_FRONTEND=noninteractive apt-get upgrade -y
|
119
|
-
apt-get install python-software-properties curl -y
|
120
|
-
apt-get autoremove -y
|
121
|
-
add-apt-repository -y ppa:webupd8team/java
|
122
|
-
apt-get update
|
123
|
-
echo debconf shared/accepted-oracle-license-v1-1 select true | sudo debconf-set-selections
|
124
|
-
echo debconf shared/accepted-oracle-license-v1-1 seen true | sudo debconf-set-selections
|
125
|
-
apt-get install -y oracle-java$2-installer oracle-java$2-set-default
|
126
|
-
curl -s http://archive.apache.org/dist/cassandra/$1/apache-cassandra-$1-bin.tar.gz | tar -C /opt -xzvf -
|
127
|
-
echo "start on runlevel [2345]
|
128
|
-
stop on runlevel [06]
|
129
|
-
exec /opt/apache-cassandra-$1/bin/cassandra" > /etc/init/cassandra.conf
|
130
|
-
sed -i -e 's/.*broadcast_rpc_address:.*/broadcast_rpc_address: 127.0.0.1/' /opt/apache-cassandra-$1/conf/cassandra.yaml
|
131
|
-
sed -i -e 's/^rpc_address:.*/rpc_address: 0.0.0.0/' /opt/apache-cassandra-$1/conf/cassandra.yaml
|
132
|
-
sed -i -e 's/^start_native_transport:.*/start_native_transport: true/' /opt/apache-cassandra-$1/conf/cassandra.yaml
|
133
|
-
sed -i -e 's/^start_rpc:.*/start_rpc: true/' /opt/apache-cassandra-$1/conf/cassandra.yaml
|
134
|
-
service cassandra start
|
135
|
-
SH
|
136
|
-
|
137
|
-
versions = File.read(File.expand_path('../.cassandra-versions', __FILE__)).each_line
|
138
|
-
.map(&:strip).grep(/(^2\.[12]\.)|(^3.)/)
|
139
|
-
versions.each do |version|
|
140
|
-
java_version = version =~ /^2/ ? '7' : '8'
|
141
|
-
config.vm.define version do |machine|
|
142
|
-
machine.vm.provision :shell, inline: provision,
|
143
|
-
args: [version, java_version]
|
144
|
-
machine.vm.network :forwarded_port, guest: 9042, host: 9042,
|
145
|
-
auto_correct: true
|
146
|
-
machine.vm.network :forwarded_port, guest: 9160, host: 9160,
|
147
|
-
auto_correct: true
|
148
|
-
end
|
149
|
-
end
|
150
|
-
end
|