infrataster-plugin-memcached 0.1.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +34 -0
- data/.rspec +2 -0
- data/Gemfile +4 -0
- data/LICENSE +22 -0
- data/README.md +70 -0
- data/Rakefile +10 -0
- data/infrataster-plugin-memcached.gemspec +22 -0
- data/lib/infrataster-plugin-memcached.rb +3 -0
- data/lib/infrataster/contexts/memcached_context.rb +29 -0
- data/lib/infrataster/helpers/memcached_resource_helper.rb +12 -0
- data/lib/infrataster/resources/memcached_resource.rb +22 -0
- data/spec/memcached_spec.rb +24 -0
- data/spec/spec_helper.rb +20 -0
- metadata +129 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 17c99338d2d7f9f4154de05d544290b92a2ad58b
|
4
|
+
data.tar.gz: dcb22887c80e06a96869d43a7e28ace4efa00a89
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: b8cb5987d0bf6df58b4937d1b284e1bb91cfe7643958ddf1ba3efaa045e3994126553147fd84fad9fd831e091ffb81bd436fc3131718b0e9214e1a7c00c030fa
|
7
|
+
data.tar.gz: b7ad8fc8be04d920890b0938de24049ab63b588b7313cb1f4ea4147949b64f190c58048cf901eb7413030c27f86954f239b41ac35642ccde1d7cfa6045cf629a
|
data/.gitignore
ADDED
@@ -0,0 +1,34 @@
|
|
1
|
+
*.gem
|
2
|
+
*.rbc
|
3
|
+
/.config
|
4
|
+
/coverage/
|
5
|
+
/InstalledFiles
|
6
|
+
/pkg/
|
7
|
+
/spec/reports/
|
8
|
+
/test/tmp/
|
9
|
+
/test/version_tmp/
|
10
|
+
/tmp/
|
11
|
+
|
12
|
+
## Specific to RubyMotion:
|
13
|
+
.dat*
|
14
|
+
.repl_history
|
15
|
+
build/
|
16
|
+
|
17
|
+
## Documentation cache and generated files:
|
18
|
+
/.yardoc/
|
19
|
+
/_yardoc/
|
20
|
+
/doc/
|
21
|
+
/rdoc/
|
22
|
+
|
23
|
+
## Environment normalisation:
|
24
|
+
/.bundle/
|
25
|
+
/lib/bundler/man/
|
26
|
+
|
27
|
+
# for a library or gem, you might want to ignore these files since the code is
|
28
|
+
# intended to run in multiple environments; otherwise, check them in:
|
29
|
+
# Gemfile.lock
|
30
|
+
# .ruby-version
|
31
|
+
# .ruby-gemset
|
32
|
+
|
33
|
+
# unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
|
34
|
+
.rvmrc
|
data/.rspec
ADDED
data/Gemfile
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2015 Rahul Khengare
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
13
|
+
copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
21
|
+
SOFTWARE.
|
22
|
+
|
data/README.md
ADDED
@@ -0,0 +1,70 @@
|
|
1
|
+
# infrataster-plugin-memcached
|
2
|
+
Plugin to test and query memcached server using infrataster
|
3
|
+
|
4
|
+
Memcached plugin for [Infrataster](https://github.com/rahulkhengare/infrataster-plugin-memcached)
|
5
|
+
|
6
|
+
## Installation
|
7
|
+
|
8
|
+
Add this line to your Gemfile:
|
9
|
+
|
10
|
+
gem 'infrataster-plugin-memecached'
|
11
|
+
|
12
|
+
And then add the following line to your spec\_helper.rb:
|
13
|
+
|
14
|
+
require 'infrataster-plugin-memcached'
|
15
|
+
|
16
|
+
## Usage
|
17
|
+
|
18
|
+
```ruby
|
19
|
+
describe server(:memcached) do
|
20
|
+
describe memcached("stats") do
|
21
|
+
it 'should show stats' do
|
22
|
+
# checking version from memcached stats
|
23
|
+
# for stats it returns hash
|
24
|
+
result[:version].should == ["1.4.4"]
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
describe memcached("set 'status', 'success'") do
|
29
|
+
it 'should set value' do
|
30
|
+
# Setting value in memcached
|
31
|
+
result.should == nil
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
describe memcached("get 'status'") do
|
36
|
+
it 'should get value' do
|
37
|
+
# Getting value from memcached
|
38
|
+
result.should == 'success'
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
```
|
43
|
+
|
44
|
+
You can specify hostname and port number by options passed to `Infrataster::Server.define`:
|
45
|
+
|
46
|
+
```ruby
|
47
|
+
Infrataster::Server.define(
|
48
|
+
# ...
|
49
|
+
memcached: {host: 'localhost', port: 11211},
|
50
|
+
)
|
51
|
+
```
|
52
|
+
|
53
|
+
|
54
|
+
## TODO
|
55
|
+
As infrataster used for testing behavior of servers (like connections)
|
56
|
+
I have implemented the basic functionality like set and get the value from memcached server.
|
57
|
+
It also get the statistics of memcached server.
|
58
|
+
Currently it does not support following functionality
|
59
|
+
- Functionality for getting multiple value in single get query
|
60
|
+
- Functionality which specify the lifetime of variable in set query.
|
61
|
+
|
62
|
+
|
63
|
+
## Contributing
|
64
|
+
|
65
|
+
1. Fork it ( https://github.com/[my-github-username]/infrataster-plugin-memcached/fork )
|
66
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
67
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
68
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
69
|
+
5. Create a new Pull Request
|
70
|
+
|
data/Rakefile
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
Gem::Specification.new do |spec|
|
3
|
+
spec.name = "infrataster-plugin-memcached"
|
4
|
+
spec.version = '0.1.3'
|
5
|
+
spec.authors = ["Rahul Khengare"]
|
6
|
+
spec.email = ["rahulk1306@gmail.com"]
|
7
|
+
spec.summary = %q{memcached plugin for Infrataster}
|
8
|
+
spec.description = %q{Plugin for Infrataster to test behavior of memcached server}
|
9
|
+
spec.homepage = "https://github.com/rahulkhengare/infrataster-plugin-memcached"
|
10
|
+
spec.license = "MIT"
|
11
|
+
|
12
|
+
spec.files = `git ls-files -z`.split("\x0")
|
13
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
14
|
+
spec.require_paths = ["lib"]
|
15
|
+
|
16
|
+
spec.add_runtime_dependency "infrataster", "~> 0.2"
|
17
|
+
spec.add_runtime_dependency "memcached", "~> 1.8"
|
18
|
+
|
19
|
+
spec.add_development_dependency "bundler", "~> 1.6"
|
20
|
+
spec.add_development_dependency "rake", "~> 0"
|
21
|
+
spec.add_development_dependency "rspec", "~> 3.0"
|
22
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
require 'infrataster'
|
2
|
+
require 'memcached'
|
3
|
+
|
4
|
+
module Infrataster
|
5
|
+
module Contexts
|
6
|
+
class MemcachedContext < BaseContext
|
7
|
+
def result
|
8
|
+
options = {host: 'localhost', port: 11211}
|
9
|
+
if server.options[:memcached]
|
10
|
+
options = options.merge(server.options[:memcached])
|
11
|
+
end
|
12
|
+
|
13
|
+
# Query parse
|
14
|
+
query, arguments = resource.query.split(' ', 2)
|
15
|
+
# For set and get query parse and get arguments
|
16
|
+
if query == "set" or query == "get"
|
17
|
+
arguments = arguments.scan(/'[^']*'/).map{|n| eval n}
|
18
|
+
end
|
19
|
+
|
20
|
+
# Initialize the memcached obj
|
21
|
+
resource.cache = Memcached.new("#{options[:host]}:#{options[:port]}")
|
22
|
+
if resource.cache.respond_to?(query)
|
23
|
+
# Run query
|
24
|
+
resource.cache.method(query).call(*arguments)
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
require 'infrataster'
|
2
|
+
require 'memcached'
|
3
|
+
|
4
|
+
module Infrataster
|
5
|
+
module Resources
|
6
|
+
class MemcachedResource < BaseResource
|
7
|
+
Error = Class.new(StandardError)
|
8
|
+
|
9
|
+
attr_reader :query
|
10
|
+
attr_accessor :cache
|
11
|
+
|
12
|
+
def initialize(query, options={})
|
13
|
+
@query = query
|
14
|
+
@cache = nil
|
15
|
+
end
|
16
|
+
|
17
|
+
def to_s
|
18
|
+
"Memcached : \"#{@query}\""
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe server(:memcached) do
|
4
|
+
describe memcached("stats") do
|
5
|
+
it 'should show stats' do
|
6
|
+
# checking version from memcached stats
|
7
|
+
result[:version].should == ["1.4.4"]
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
describe memcached("set 'status', 'success'") do
|
12
|
+
it 'should set value' do
|
13
|
+
# Setting value in memcached
|
14
|
+
result.should == nil
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
describe memcached("get 'status'") do
|
19
|
+
it 'should get value' do
|
20
|
+
# Getting value from memcached
|
21
|
+
result.should == 'success'
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
require 'infrataster/rspec'
|
2
|
+
require 'infrataster-plugin-memcached'
|
3
|
+
|
4
|
+
Infrataster::Server.define(
|
5
|
+
:memcached,
|
6
|
+
'172.26.126.0/32',
|
7
|
+
memcached: {host: 'localhost', port: 11211},
|
8
|
+
)
|
9
|
+
|
10
|
+
RSpec.configure do |config|
|
11
|
+
config.treat_symbols_as_metadata_keys_with_true_values = true
|
12
|
+
config.run_all_when_everything_filtered = true
|
13
|
+
config.filter_run :focus
|
14
|
+
|
15
|
+
# Run specs in random order to surface order dependencies. If you find an
|
16
|
+
# order dependency and want to debug it, you can fix the order by providing
|
17
|
+
# the seed, which is printed after each run.
|
18
|
+
# --seed 1234
|
19
|
+
config.order = 'random'
|
20
|
+
end
|
metadata
ADDED
@@ -0,0 +1,129 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: infrataster-plugin-memcached
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.3
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Rahul Khengare
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2015-03-10 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: infrataster
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0.2'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0.2'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: memcached
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '1.8'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '1.8'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: bundler
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '1.6'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '1.6'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rake
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: rspec
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - "~>"
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '3.0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - "~>"
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '3.0'
|
83
|
+
description: Plugin for Infrataster to test behavior of memcached server
|
84
|
+
email:
|
85
|
+
- rahulk1306@gmail.com
|
86
|
+
executables: []
|
87
|
+
extensions: []
|
88
|
+
extra_rdoc_files: []
|
89
|
+
files:
|
90
|
+
- ".gitignore"
|
91
|
+
- ".rspec"
|
92
|
+
- Gemfile
|
93
|
+
- LICENSE
|
94
|
+
- README.md
|
95
|
+
- Rakefile
|
96
|
+
- infrataster-plugin-memcached.gemspec
|
97
|
+
- lib/infrataster-plugin-memcached.rb
|
98
|
+
- lib/infrataster/contexts/memcached_context.rb
|
99
|
+
- lib/infrataster/helpers/memcached_resource_helper.rb
|
100
|
+
- lib/infrataster/resources/memcached_resource.rb
|
101
|
+
- spec/memcached_spec.rb
|
102
|
+
- spec/spec_helper.rb
|
103
|
+
homepage: https://github.com/rahulkhengare/infrataster-plugin-memcached
|
104
|
+
licenses:
|
105
|
+
- MIT
|
106
|
+
metadata: {}
|
107
|
+
post_install_message:
|
108
|
+
rdoc_options: []
|
109
|
+
require_paths:
|
110
|
+
- lib
|
111
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
112
|
+
requirements:
|
113
|
+
- - ">="
|
114
|
+
- !ruby/object:Gem::Version
|
115
|
+
version: '0'
|
116
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
117
|
+
requirements:
|
118
|
+
- - ">="
|
119
|
+
- !ruby/object:Gem::Version
|
120
|
+
version: '0'
|
121
|
+
requirements: []
|
122
|
+
rubyforge_project:
|
123
|
+
rubygems_version: 2.2.2
|
124
|
+
signing_key:
|
125
|
+
specification_version: 4
|
126
|
+
summary: memcached plugin for Infrataster
|
127
|
+
test_files:
|
128
|
+
- spec/memcached_spec.rb
|
129
|
+
- spec/spec_helper.rb
|