forked from acaprojects/couchbase-orm
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #33 from CedricCouton/activemodel7-couchbase-ruby-…
…client test migration to actionmodel7 + rails7 + couchbase-ruby-client
- Loading branch information
Showing
28 changed files
with
430 additions
and
244 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,20 @@ | ||
set -x | ||
set -e | ||
apt-get install libev-dev python-httplib2 libssl1.0.0 | ||
wget https://packages.couchbase.com/releases/5.1.0/couchbase-server-enterprise_5.1.0-ubuntu14.04_amd64.deb | ||
dpkg -i couchbase-server-enterprise_5.1.0-ubuntu14.04_amd64.deb | ||
|
||
VERSION=$1 | ||
BUCKET=$2 | ||
USER=$3 | ||
PASSWORD=$4 | ||
|
||
|
||
wget https://packages.couchbase.com/releases/$VERSION/couchbase-server-enterprise_$VERSION-ubuntu20.04_amd64.deb | ||
dpkg -i couchbase-server-enterprise_$VERSION-ubuntu20.04_amd64.deb | ||
sleep 8 | ||
sudo service couchbase-server status | ||
/opt/couchbase/bin/couchbase-cli cluster-init -c 127.0.0.1:8091 --cluster-username=admin --cluster-password=password --cluster-ramsize=320 --cluster-index-ramsize=256 --cluster-fts-ramsize=256 --services=data,index,query,fts | ||
sleep 5 | ||
/opt/couchbase/bin/couchbase-cli server-info -c 127.0.0.1:8091 -u admin -p password | ||
/opt/couchbase/bin/couchbase-cli bucket-create -c 127.0.0.1:8091 -u admin -p password --bucket=default --bucket-type=couchbase --bucket-ramsize=160 --bucket-replica=0 --wait | ||
/opt/couchbase/bin/couchbase-cli bucket-create -c 127.0.0.1:8091 -u admin -p password --bucket=$BUCKET --bucket-type=couchbase --bucket-ramsize=160 --bucket-replica=0 --wait | ||
sleep 1 | ||
/opt/couchbase/bin/couchbase-cli user-manage -c 127.0.0.1:8091 -u admin -p password --set --rbac-username tester --rbac-password password123 --rbac-name "Auto Tester" --roles admin --auth-domain local | ||
curl http://admin:password@localhost:8093/query/service -d 'statement=CREATE INDEX `default_type` ON `default`(`type`)' | ||
/opt/couchbase/bin/couchbase-cli user-manage -c 127.0.0.1:8091 -u admin -p password --set --rbac-username $USER --rbac-password $PASSWORD --rbac-name "Auto Tester" --roles admin --auth-domain local | ||
curl http://admin:password@localhost:8093/query/service -d "statement=CREATE INDEX \`default_type\` ON \`$BUCKET\`(\`type\`)" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,36 @@ | ||
# frozen_string_literal: true, encoding: ASCII-8BIT | ||
|
||
require 'mt-libcouchbase' | ||
require 'couchbase' | ||
|
||
module CouchbaseOrm | ||
class Connection | ||
@options = {} | ||
class << self | ||
attr_accessor :options | ||
@@config = nil | ||
def self.config | ||
@@config || { | ||
:connection_string => "couchbase://#{ENV['COUCHBASE_HOST'] || '127.0.0.1'}", | ||
:username => ENV['COUCHBASE_USER'], | ||
:password => ENV['COUCHBASE_PASSWORD'], | ||
:bucket => ENV['COUCHBASE_BUCKET'] | ||
} | ||
end | ||
|
||
def self.config=(config) | ||
@@config = config | ||
end | ||
|
||
def self.cluster | ||
@cluster ||= begin | ||
cb_config = Couchbase::Configuration.new | ||
cb_config.connection_string = config[:connection_string] || raise(CouchbaseOrm::Error, 'Missing CouchbaseOrm connection string') | ||
cb_config.username = config[:username] || raise(CouchbaseOrm::Error, 'Missing CouchbaseOrm username') | ||
cb_config.password = config[:password] || raise(CouchbaseOrm::Error, 'Missing CouchbaseOrm password') | ||
Couchbase::Cluster.connect(cb_config) | ||
end | ||
end | ||
|
||
def self.bucket | ||
@bucket ||= ::MTLibcouchbase::Bucket.new(**@options) | ||
@bucket ||= begin | ||
bucket_name = config[:bucket] || raise(CouchbaseOrm::Error, 'Missing CouchbaseOrm bucket name') | ||
cluster.bucket(bucket_name) | ||
end | ||
end | ||
end | ||
end | ||
end |
Oops, something went wrong.