anyt 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: e0756730d4647d657a15da9bb7297bc56422b0b7
4
+ data.tar.gz: 7800b2a9f44d44082c3a210b6b30d599dc7284a6
5
+ SHA512:
6
+ metadata.gz: 886ca9223f53368f8b673ee4122737efc56656fba24e0dde191ea937994bd9b3023774e34023fe0f753407a884ff6c729341ec66a9ea6581eefd4260937f4565
7
+ data.tar.gz: a238898763b662e5954689e85ede1605495967d87cf645a9edab68bddbfa1e87433459fce2d71159b740622cb9ba5e424f50af2f1fa8bbbbe62673bf46ca4dc4
@@ -0,0 +1,43 @@
1
+ # Numerous always-ignore extensions
2
+ *.diff
3
+ *.err
4
+ *.orig
5
+ *.log
6
+ *.rej
7
+ *.swo
8
+ *.swp
9
+ *.vi
10
+ *~
11
+ *.sass-cache
12
+ *.iml
13
+ .idea/
14
+
15
+ # Sublime
16
+ *.sublime-project
17
+ *.sublime-workspace
18
+
19
+ # OS or Editor folders
20
+ .DS_Store
21
+ .cache
22
+ .project
23
+ .settings
24
+ .tmproj
25
+ Thumbs.db
26
+
27
+ .bundle/
28
+ log/*.log
29
+ *.gz
30
+ pkg/
31
+ spec/dummy/db/*.sqlite3
32
+ spec/dummy/db/*.sqlite3-journal
33
+ spec/dummy/tmp/
34
+
35
+ Gemfile.local
36
+ Gemfile.lock
37
+ .rspec
38
+ *.gem
39
+ tmp/
40
+ coverage/
41
+
42
+ # ctags tags
43
+ tags
@@ -0,0 +1,68 @@
1
+ AllCops:
2
+ # Include gemspec and Rakefile
3
+ Include:
4
+ - 'lib/**/*.rb'
5
+ - 'lib/**/*.rake'
6
+ - 'spec/**/*.rb'
7
+ Exclude:
8
+ - 'bin/**/*'
9
+ - 'spec/dummy/**/*'
10
+ - 'tmp/**/*'
11
+ - 'vendor/**/*'
12
+ - 'bench/**/*'
13
+ - 'lib/anycable/rpc/**/*'
14
+ - '*.gemspec'
15
+ - 'Rakefile'
16
+ - 'Gemfile'
17
+ DisplayCopNames: true
18
+ StyleGuideCopsOnly: false
19
+ TargetRubyVersion: 2.4
20
+
21
+ Rails:
22
+ Enabled: false
23
+
24
+ Style/AccessorMethodName:
25
+ Enabled: false
26
+
27
+ Style/TrivialAccessors:
28
+ Enabled: false
29
+
30
+ Style/Documentation:
31
+ Exclude:
32
+ - 'spec/**/*.rb'
33
+ - 'lib/**/*_test.rb'
34
+ - 'lib/anyt/dummy/**/*'
35
+
36
+ Style/StringLiterals:
37
+ Enabled: false
38
+
39
+ Style/BlockDelimiters:
40
+ Exclude:
41
+ - 'spec/**/*.rb'
42
+
43
+ Style/PercentLiteralDelimiters:
44
+ Enabled: false
45
+
46
+ Style/FormatString:
47
+ Enabled: false
48
+
49
+ Style/ClassAndModuleChildren:
50
+ Enabled: false
51
+
52
+ Lint/AmbiguousRegexpLiteral:
53
+ Enabled: false
54
+
55
+ Metrics/MethodLength:
56
+ Exclude:
57
+ - 'spec/**/*.rb'
58
+ - 'lib/**/*_test.rb'
59
+
60
+ Metrics/BlockLength:
61
+ Exclude:
62
+ - 'spec/**/*.rb'
63
+ - 'lib/**/*_test.rb'
64
+
65
+ Metrics/LineLength:
66
+ Max: 100
67
+ Exclude:
68
+ - 'spec/**/*.rb'
data/Gemfile ADDED
@@ -0,0 +1,6 @@
1
+ # frozen_string_literal: true
2
+
3
+ source "https://rubygems.org"
4
+
5
+ # Specify your gem's dependencies in anyt.gemspec
6
+ gemspec
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2017 palkan
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
13
+ all 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
21
+ THE SOFTWARE.
@@ -0,0 +1,20 @@
1
+ Copyright 2016 palkan
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,5 @@
1
+ lint:
2
+ bundle exec rubocop
3
+
4
+ test:
5
+ bin/anyt --self-check
@@ -0,0 +1,35 @@
1
+ [![Circle CI](https://circleci.com/gh/anycable/anycablebility/tree/master.svg?style=svg)](https://circleci.com/gh/anycable/anycablebility/tree/master) [![Gitter](https://img.shields.io/badge/gitter-join%20chat%20%E2%86%92-brightgreen.svg)](https://gitter.im/anycable/anycablebility)
2
+
3
+ # Anycable Conformance Testing Tool
4
+
5
+ AnyT is a command-line tool to test your [AnyCable](http://anycable.io)-compatible WebSocket servers.
6
+ It contains a set of tests to determine which features are supported by the implementation under consideration.
7
+
8
+ ## Installation
9
+
10
+ ```sh
11
+ gem install anyt
12
+ ```
13
+
14
+ ## Usage
15
+
16
+ You should provide a command to run the server and the target URL for WebSocket clients:
17
+
18
+ ```sh
19
+ anyt -c "anycable-go" --target-url="ws://localhost:8080/cable"
20
+ ```
21
+
22
+ By default it launches gRPC server on `localhost:50051` and use local Redis instance for broadcasts (`localhost:6379`).
23
+
24
+ For more options run:
25
+
26
+ ```sh
27
+ anyt -h
28
+ ```
29
+
30
+ ## Contributing
31
+
32
+ Bug reports and pull requests are welcome on GitHub at https://github.com/anycable/anyt/issues.
33
+
34
+ ## License
35
+ The library is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
@@ -0,0 +1,41 @@
1
+ # coding: utf-8
2
+ # frozen_string_literal: true
3
+
4
+ lib = File.expand_path("../lib", __FILE__)
5
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
6
+
7
+ require "anyt/version"
8
+
9
+ Gem::Specification.new do |spec|
10
+ spec.name = "anyt"
11
+ spec.version = Anyt::VERSION
12
+ spec.authors = ["palkan"]
13
+ spec.email = ["dementiev.vm@gmail.com"]
14
+
15
+ spec.summary = "Anycable conformance testing tool"
16
+ spec.description = "Anycable conformance testing tool"
17
+ spec.homepage = "http://github.com/anycable/anyt"
18
+ spec.license = "MIT"
19
+
20
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
21
+ spec.require_paths = ["lib"]
22
+
23
+ spec.executables << "anyt"
24
+
25
+ spec.add_dependency "rack", "~> 2"
26
+ spec.add_dependency "minitest", "~> 5.10.1"
27
+ spec.add_dependency "minitest-reporters", "~> 1.1.0"
28
+ spec.add_dependency "rails", "~> 5.0"
29
+ spec.add_dependency "anycable-rails", "~> 0.4.6"
30
+ spec.add_dependency "websocket", "~> 1.2.4"
31
+ spec.add_dependency "websocket-client-simple", "~> 0.3.0"
32
+ spec.add_dependency "concurrent-ruby", "~> 1.0.0"
33
+
34
+ spec.add_development_dependency "bundler", "~> 1"
35
+ spec.add_development_dependency "rake", "~> 10.0"
36
+ spec.add_development_dependency "simplecov", ">= 0.3.8"
37
+ spec.add_development_dependency "rubocop", "~> 0.50"
38
+ spec.add_development_dependency "pry", "~> 0.10.4"
39
+ spec.add_development_dependency "puma", "~> 3.6"
40
+ spec.add_development_dependency "pry-byebug"
41
+ end
@@ -0,0 +1,16 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'bundler/setup'
4
+
5
+ require 'anyt'
6
+ require 'anyt/cli'
7
+
8
+ begin
9
+ exit_code = Anyt::Cli.run
10
+ rescue => e
11
+ puts 'Bummer! There is an error:'
12
+ puts e
13
+ exit 1
14
+ end
15
+
16
+ exit exit_code
@@ -0,0 +1,7 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'bundler/setup'
4
+ require 'anyt'
5
+ require 'irb'
6
+
7
+ IRB.start
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,14 @@
1
+ machine:
2
+ ruby:
3
+ version: 2.4.2
4
+ services:
5
+ - redis
6
+
7
+ dependencies:
8
+ pre:
9
+ - gem install bundler
10
+
11
+ test:
12
+ override:
13
+ - make lint
14
+ - make test
@@ -0,0 +1,14 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "anyt/version"
4
+ require "anyt/config"
5
+ require "anyt/utils"
6
+
7
+ # Anycable conformance testing tool
8
+ module Anyt
9
+ class << self
10
+ def config
11
+ @config ||= Config.new
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,119 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "logger"
4
+ require "optparse"
5
+
6
+ require "anyt/rpc"
7
+ require "anyt/command"
8
+ require "anyt/tests"
9
+
10
+ # rubocop: disable Metrics/AbcSize
11
+ # rubocop: disable Metrics/MethodLength
12
+ # rubocop: disable Metrics/BlockLength
13
+ module Anyt
14
+ module Cli # :nodoc:
15
+ class << self
16
+ # CLI entrypoint
17
+ def run
18
+ parse_options!
19
+
20
+ ActionCable.server.config.logger = Rails.logger = Anycable.logger
21
+
22
+ result = 1
23
+
24
+ begin
25
+ # Load all test scenarios
26
+ Tests.load_tests
27
+
28
+ # Start RPC server (unless specified otherwise, e.g. when
29
+ # we want to test Action Cable itself)
30
+ unless @skip_rpc
31
+ require "anycable-rails"
32
+ RPC.start
33
+ end
34
+
35
+ # Start webosocket server under test
36
+ Command.run
37
+
38
+ # Run tests
39
+ result = Tests.run ? 0 : 1
40
+ ensure
41
+ RPC.stop unless @skip_rpc
42
+ Command.stop
43
+ end
44
+
45
+ result
46
+ end
47
+
48
+ private
49
+
50
+ def parse_options!
51
+ parser =
52
+ OptionParser.new do |cli|
53
+ cli.banner = <<~BANNER
54
+ Anyt – AnyCable websocket server conformance tool.
55
+
56
+ Usage: anyt [options]
57
+
58
+ Options:
59
+ BANNER
60
+
61
+ cli.on("-cCOMMAND", "--command=COMMAND", "Command to run WS server.") do |command|
62
+ Anyt.config.command = command
63
+ end
64
+
65
+ cli.on("--target-url=TARGET", "URL of target WebSocket server to test.") do |target|
66
+ Anyt.config.target_url = target
67
+ end
68
+
69
+ cli.on("--redis-url=REDIS_URL", "Redis server URL.") do |redis|
70
+ Anycable.config.redis_url = redis
71
+ end
72
+
73
+ cli.on("--skip-rpc", TrueClass, "Do not run RPC server") do |flag|
74
+ @skip_rpc = flag
75
+ end
76
+
77
+ cli.on("--self-check", "Run tests again Action Cable itself") do
78
+ @skip_rpc = true
79
+ dummy_path = ::File.expand_path(
80
+ "config.ru",
81
+ ::File.join(::File.dirname(__FILE__), "dummy")
82
+ )
83
+ Anyt.config.command = "bundle exec puma #{dummy_path}"
84
+ end
85
+
86
+ cli.on("--only test1,test2,test3", Array, "Run only specified tests") do |only_tests|
87
+ Anyt.config.only_tests = only_tests
88
+ end
89
+
90
+ cli.on("--wait-command=TIMEOUT", Integer,
91
+ "Number of seconds to wait for WS server initialization") do |timeout|
92
+ Anyt.config.wait_command = timeout
93
+ end
94
+
95
+ cli.on("--debug", "Enable debug mode.") do
96
+ Anycable.config.debug = true
97
+ end
98
+
99
+ cli.on("-h", "--help", "Show this message.") do
100
+ puts cli
101
+ exit
102
+ end
103
+
104
+ cli.on("--version", "Print version.") do
105
+ puts Anyt::VERSION
106
+ exit
107
+ end
108
+ end
109
+
110
+ parser.parse!
111
+ rescue OptionParser::InvalidOption => e
112
+ unknown_option = e.args.first
113
+ puts "This option looks unfamiliar: #{unknown_option}. A typo?"
114
+ puts "Use `anyt --help` to list all available options."
115
+ exit 1
116
+ end
117
+ end
118
+ end
119
+ end