rhoconnect 3.0.0.rc1 → 3.0.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.
- data/{CHANGELOG → CHANGELOG.md} +8 -1
- data/CREDITS +6 -1
- data/Gemfile.lock +19 -1
- data/Rakefile +12 -13
- data/bench/blobapp/settings/license.key +1 -1
- data/doc/authentication.txt +1 -1
- data/doc/install.txt +1 -1
- data/doc/rest-api.txt +11 -0
- data/doc/settings.txt +0 -22
- data/generators/templates/application/Gemfile +2 -0
- data/generators/templates/application/config.ru +5 -0
- data/install.sh +17 -6
- data/installer/{utils → unix-like}/create_texts.rb +2 -2
- data/installer/unix-like/rho_connect_install_checkers.rb +2 -3
- data/installer/unix-like/rho_connect_install_constants.rb +22 -29
- data/installer/unix-like/rho_connect_install_installers.rb +18 -43
- data/installer/unix-like/rho_connect_install_utilities.rb +1 -0
- data/installer/unix-like/rhoinstaller.rb +12 -5
- data/installer/utils/constants.rb +45 -0
- data/installer/utils/nix_installation.rake +0 -0
- data/installer/utils/unix_install_test.rb +258 -0
- data/lib/rhoconnect/api/source/push_deletes.rb +4 -1
- data/lib/rhoconnect/api/source/push_objects.rb +4 -1
- data/lib/rhoconnect/document.rb +8 -0
- data/lib/rhoconnect/source.rb +7 -33
- data/lib/rhoconnect/source_adapter.rb +9 -5
- data/lib/rhoconnect/source_sync.rb +49 -29
- data/lib/rhoconnect/store.rb +51 -0
- data/lib/rhoconnect/tasks.rb +20 -1
- data/lib/rhoconnect/version.rb +1 -1
- data/rhoconnect.gemspec +1 -1
- data/spec/source_sync_spec.rb +0 -50
- data/spec/store_spec.rb +36 -1
- data/tasks/redis.rake +17 -0
- metadata +9 -9
- data/installer/utils/install_test.rb +0 -152
data/spec/store_spec.rb
CHANGED
@@ -48,7 +48,42 @@ describe "Store" do
|
|
48
48
|
Store.put_data('mydata', data)
|
49
49
|
Store.get_data('mydata').should == data
|
50
50
|
end
|
51
|
-
|
51
|
+
|
52
|
+
it "should update_objects with simple data and one changed attribute" do
|
53
|
+
data = { '1' => { 'hello' => 'world', "attr1" => 'value1' } }
|
54
|
+
update_data = { '1' => {'attr1' => 'value2'}}
|
55
|
+
Store.put_data('mydata', data)
|
56
|
+
Store.get_data('mydata').should == data
|
57
|
+
Store.update_objects('mydata', update_data)
|
58
|
+
data['1'].merge!(update_data['1'])
|
59
|
+
Store.get_data('mydata').should == data
|
60
|
+
end
|
61
|
+
|
62
|
+
it "should update_objects with simple data and verify that srem and sadd is called only on affected fields" do
|
63
|
+
data = { '1' => { 'hello' => 'world', "attr1" => 'value1' } }
|
64
|
+
update_data = { '1' => {'attr1' => 'value2', 'new_attr' => 'new_val', 'hello' => 'world'},
|
65
|
+
'2' => {'whole_new_object' => 'new_value' } }
|
66
|
+
Store.put_data('mydata', data)
|
67
|
+
Store.db.should_receive(:srem).exactly(1).times
|
68
|
+
Store.db.should_receive(:sadd).exactly(3).times
|
69
|
+
Store.update_objects('mydata', update_data)
|
70
|
+
end
|
71
|
+
|
72
|
+
it "should delete_objects with simple data" do
|
73
|
+
data = { '1' => { 'hello' => 'world', "attr1" => 'value1' } }
|
74
|
+
Store.put_data('mydata', data)
|
75
|
+
Store.delete_objects('mydata', ['1'])
|
76
|
+
Store.get_data('mydata').should == {}
|
77
|
+
end
|
78
|
+
|
79
|
+
it "should delete_objects with simple data and verify that srem is called only on affected fields" do
|
80
|
+
data = { '1' => { 'hello' => 'world', "attr1" => 'value1' } }
|
81
|
+
Store.put_data('mydata', data)
|
82
|
+
Store.db.should_receive(:srem).exactly(2).times
|
83
|
+
Store.db.should_receive(:sadd).exactly(0).times
|
84
|
+
Store.delete_objects('mydata', ['1'])
|
85
|
+
end
|
86
|
+
|
52
87
|
it "should add simple array data to new set" do
|
53
88
|
@data = ['1','2','3']
|
54
89
|
Store.put_data(@s.docname(:md),@data).should == true
|
data/tasks/redis.rake
CHANGED
@@ -68,6 +68,18 @@ class RedisRunner
|
|
68
68
|
sh command
|
69
69
|
end
|
70
70
|
end
|
71
|
+
|
72
|
+
# this function is used with Rhostudio where there is no terminal
|
73
|
+
def self.startbg
|
74
|
+
if windows?
|
75
|
+
puts "Starting redis in a new window..."
|
76
|
+
sh "start #{File.join(redis_home,'redis-server')} #{File.join(redis_home,'redis.conf')}" rescue
|
77
|
+
"redis-server not installed on your path, please run 'rake redis:install' first."
|
78
|
+
else
|
79
|
+
puts "Starting redis ..."
|
80
|
+
system("redis-server #{redisconfdir} &")
|
81
|
+
end
|
82
|
+
end
|
71
83
|
|
72
84
|
def self.attach
|
73
85
|
exec "dtach -a #{dtach_socket}"
|
@@ -90,6 +102,11 @@ namespace :redis do
|
|
90
102
|
task :start do
|
91
103
|
RedisRunner.start
|
92
104
|
end
|
105
|
+
|
106
|
+
# desc 'Start redis' without dtach - for Rhostudio (internal)
|
107
|
+
task :startbg do
|
108
|
+
RedisRunner.startbg
|
109
|
+
end
|
93
110
|
|
94
111
|
desc 'Stop redis'
|
95
112
|
task :stop do
|
metadata
CHANGED
@@ -1,15 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rhoconnect
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
5
|
-
prerelease:
|
4
|
+
hash: 7
|
5
|
+
prerelease:
|
6
6
|
segments:
|
7
7
|
- 3
|
8
8
|
- 0
|
9
9
|
- 0
|
10
|
-
|
11
|
-
- 1
|
12
|
-
version: 3.0.0.rc1
|
10
|
+
version: 3.0.0
|
13
11
|
platform: ruby
|
14
12
|
authors:
|
15
13
|
- Rhomobile
|
@@ -17,7 +15,7 @@ autorequire:
|
|
17
15
|
bindir: bin
|
18
16
|
cert_chain: []
|
19
17
|
|
20
|
-
date: 2011-09-
|
18
|
+
date: 2011-09-30 00:00:00 Z
|
21
19
|
dependencies:
|
22
20
|
- !ruby/object:Gem::Dependency
|
23
21
|
type: :runtime
|
@@ -187,7 +185,7 @@ extra_rdoc_files:
|
|
187
185
|
- LICENSE
|
188
186
|
- README.md
|
189
187
|
files:
|
190
|
-
- CHANGELOG
|
188
|
+
- CHANGELOG.md
|
191
189
|
- CREDITS
|
192
190
|
- Gemfile
|
193
191
|
- Gemfile.lock
|
@@ -311,6 +309,7 @@ files:
|
|
311
309
|
- generators/templates/application/spec/spec_helper.rb
|
312
310
|
- generators/templates/source/source_adapter.rb
|
313
311
|
- generators/templates/source/source_spec.rb
|
312
|
+
- installer/unix-like/create_texts.rb
|
314
313
|
- installer/unix-like/post_install.sh
|
315
314
|
- installer/unix-like/post_uninstall.sh
|
316
315
|
- installer/unix-like/pre_install.sh
|
@@ -324,8 +323,9 @@ files:
|
|
324
323
|
- installer/unix-like/rho_connect_install_utilities.rb
|
325
324
|
- installer/unix-like/rho_connect_install_yum.rb
|
326
325
|
- installer/unix-like/rhoinstaller.rb
|
327
|
-
- installer/utils/
|
328
|
-
- installer/utils/
|
326
|
+
- installer/utils/constants.rb
|
327
|
+
- installer/utils/nix_installation.rake
|
328
|
+
- installer/utils/unix_install_test.rb
|
329
329
|
- installer/windows/configUi.ini
|
330
330
|
- installer/windows/EnvVarUpdate.nsh
|
331
331
|
- installer/windows/icon.ico
|
@@ -1,152 +0,0 @@
|
|
1
|
-
#! /usr/bin/env ruby
|
2
|
-
|
3
|
-
require 'rhoconnect/version'
|
4
|
-
require 'rubygems'
|
5
|
-
require 'fog'
|
6
|
-
require 'readline'
|
7
|
-
require 'optparse'
|
8
|
-
|
9
|
-
# CONSTANTS
|
10
|
-
|
11
|
-
REGION = 'us-west-1'
|
12
|
-
SLEEP = 45
|
13
|
-
SSH_KEY = '/home/mike/.ssh/alexdevkey.pem'
|
14
|
-
SCP_KEY = '/home/mike/.scp/alexdevkey.pem'
|
15
|
-
ACCESS_KEY_FILE = '/Users/rhomobile/.ec2'
|
16
|
-
LOCAL_FILE = ''
|
17
|
-
REMOTE_FILE = "/home/#{USER}/rhoconnect"
|
18
|
-
UBUNTU_STACK = { :image_id => 'ami-3d491a78',
|
19
|
-
:flavor_id => 'm1.small',
|
20
|
-
:key_name => 'alexdevkey',
|
21
|
-
:groups => 'load-test',
|
22
|
-
:user => 'ubuntu' }
|
23
|
-
CENTOS_STACK = { :image_id => 'ami-13346656',
|
24
|
-
:flavor_id => 'm1.small',
|
25
|
-
:key_name => 'alexdevkey',
|
26
|
-
:groups => 'load-test',
|
27
|
-
:user => 'root' }
|
28
|
-
STACKS = [ UBUNTU_STACK, CENTOS_STACK ]
|
29
|
-
|
30
|
-
# METHODS
|
31
|
-
|
32
|
-
# cmd
|
33
|
-
# easily issue system commands in a clear way
|
34
|
-
def cmd(cmd)
|
35
|
-
puts cmd
|
36
|
-
puts `#{cmd}`
|
37
|
-
end #cmd
|
38
|
-
|
39
|
-
# create_ec2_instance
|
40
|
-
# Generates the Fog object and creates a new ec2 instance.
|
41
|
-
def create_ec2_instance
|
42
|
-
make_fog
|
43
|
-
start_new_instance
|
44
|
-
end #create_ec2_instance
|
45
|
-
|
46
|
-
# get_access_keys
|
47
|
-
# Retrieves the access key and secret access key from the above specified file.
|
48
|
-
def get_access_keys
|
49
|
-
lines = IO.readlines ACCESS_KEY_FILE
|
50
|
-
@access_key = lines.first.strip
|
51
|
-
@secret_access_key = lines.last.strip
|
52
|
-
end #get_access_keys
|
53
|
-
|
54
|
-
# make_fog
|
55
|
-
# Generates the Fog object used to create the new ec2 instance.
|
56
|
-
def make_fog
|
57
|
-
get_access_keys
|
58
|
-
@fog = Fog::Compute.new(
|
59
|
-
:provider => 'AWS',
|
60
|
-
:region => REGION,
|
61
|
-
:aws_access_key_id => @access_key,
|
62
|
-
:aws_secret_access_key => @secret_access_key
|
63
|
-
)
|
64
|
-
end #make_fog
|
65
|
-
|
66
|
-
# start_new_instance
|
67
|
-
# Creates a new ec2 instance as per the given stack.
|
68
|
-
def start_new_instance(stack)
|
69
|
-
puts "Creating new instance..."
|
70
|
-
|
71
|
-
@server = @fog.servers.create(stack)
|
72
|
-
@server.wait_for { print "."; STDOUT.flush; ready? }
|
73
|
-
puts
|
74
|
-
if @server.ready?
|
75
|
-
# wait for all services to start on remote VM
|
76
|
-
puts "Waiting #{SLEEP} seconds for services to start on remote VM..."
|
77
|
-
SLEEP.times do
|
78
|
-
sleep( 1 )
|
79
|
-
print "."
|
80
|
-
STDOUT.flush
|
81
|
-
end #do
|
82
|
-
puts
|
83
|
-
|
84
|
-
# save important instance information
|
85
|
-
@host = @server.dns_name
|
86
|
-
@server_id = @server.id
|
87
|
-
else
|
88
|
-
puts "Server timed out."
|
89
|
-
exit
|
90
|
-
end #if
|
91
|
-
end #start_new_instance
|
92
|
-
|
93
|
-
# establish_ssh_connection
|
94
|
-
# Establishes the ssh connection needed to issue commands to the remote machine.
|
95
|
-
def establish_ssh_connection
|
96
|
-
@ssh = Fog::SSH.new( @host, USER, :keys => KEYS )
|
97
|
-
end #establish_ssh_connection
|
98
|
-
|
99
|
-
# establish_scp_connection
|
100
|
-
# Establishes a gateway through which to transfer data
|
101
|
-
def establish_scp_connection
|
102
|
-
@scp = Fog::SCP.new( @host, USER, :keys => KEYS )
|
103
|
-
end #create_scp_connection
|
104
|
-
|
105
|
-
# ssh_cmd
|
106
|
-
# More easily issue commands over the ssh connection.
|
107
|
-
def ssh_cmd(cmd)
|
108
|
-
puts cmd
|
109
|
-
result = @ssh.run(cmd)
|
110
|
-
if result[0] != nil
|
111
|
-
print result[0].stdout
|
112
|
-
end #if
|
113
|
-
end #ssh_cmd
|
114
|
-
|
115
|
-
#
|
116
|
-
def transfer(local_data, remote_data)
|
117
|
-
puts "Attempting to establish SCP connection..."
|
118
|
-
puts "DATA: LOCAL - #{local_data}\t REMOTE - #{remote_data}"
|
119
|
-
@scp.upload( local_data, remote_data, :recursive => true ) do |cd, name, sent, total|
|
120
|
-
print "\r#{name}: #{(sent.to_f * 100 / total.to_f).to_i}%"
|
121
|
-
end #do
|
122
|
-
puts
|
123
|
-
|
124
|
-
end #establish_scp_connection
|
125
|
-
|
126
|
-
# transfer_rhoconnect
|
127
|
-
# Transfers over SCP the rhoconnect repo
|
128
|
-
def transfer_rhoconnect
|
129
|
-
ssh_cmd [ "sudo mkdir -p #{REMOTE_REPO}", "sudo chmod 777 #{REMOTE_REPO}" ]
|
130
|
-
transfer LOCAL_REPO, "#{REMOTE_REPO}"
|
131
|
-
ssh_cmd "sudo tar -xzf -C #{REMOTE_REPO} #{REMOTE_REPO}/rhoconnect.tgz"
|
132
|
-
ssh_cmd "ls -la #{REMOTE_REPO}"
|
133
|
-
end #transfer_rhoconnect
|
134
|
-
|
135
|
-
# destroy_ec2_instance
|
136
|
-
# Terminates the current ec2 instance
|
137
|
-
def destroy_ec2_instance
|
138
|
-
@server.destroy
|
139
|
-
puts "Instance Terminated."
|
140
|
-
end #destroy_ec2_instance
|
141
|
-
|
142
|
-
# SCRIPT
|
143
|
-
|
144
|
-
create_ec2_instance
|
145
|
-
|
146
|
-
# Establish connections
|
147
|
-
establish_ssh_connection
|
148
|
-
establish_scp_connection
|
149
|
-
|
150
|
-
transfer_rhoconnect
|
151
|
-
|
152
|
-
destroy_ec2_instance
|