knife-windows 3.0.10 → 3.0.11
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.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5ed600d9a1b420d45bc08d7eb66179a9cf83c64434a40b5fed4f54e90d9d286c
|
4
|
+
data.tar.gz: cdf15fe2cd5359009344941b2506fbd8cddc40d1075e8aaa8da56b3206c97626
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4d0bf4cbbeb4a9d24a6a029e8a8e65f8f40e453379ab2552c1694a60c48c130836eafdaa6c4cdc9c2839e0722caf118a1abd26b8ddbcfc72a7cdede4e4a30cd6
|
7
|
+
data.tar.gz: 940797a147aebee7dab7c95f1a9a4ae4ee34b1c4c8888079dbccabf9783383c3a4cd5a75d0ab9527df6e06324d74e015d844d4e20f2f6fc5c740eafc94903db2
|
@@ -118,14 +118,16 @@ class Chef
|
|
118
118
|
def relay_winrm_command(command)
|
119
119
|
Chef::Log.debug(command)
|
120
120
|
@session_results = []
|
121
|
-
|
122
121
|
queue = Queue.new
|
123
122
|
@winrm_sessions.each { |s| queue << s }
|
124
|
-
|
125
|
-
|
123
|
+
num_sessions = locate_config_value(:concurrency)
|
124
|
+
num_targets = @winrm_sessions.length
|
125
|
+
num_sessions = (num_sessions.nil? || num_sessions == 0) ? num_targets : [num_sessions, num_targets].min
|
126
126
|
|
127
|
+
# These nils will kill the Threads once no more sessions are left
|
128
|
+
num_sessions.times { queue << nil }
|
127
129
|
threads = []
|
128
|
-
|
130
|
+
num_sessions.times do
|
129
131
|
threads << Thread.new do
|
130
132
|
while session = queue.pop
|
131
133
|
run_command_in_thread(session, command)
|
@@ -43,8 +43,7 @@ class Chef
|
|
43
43
|
option :concurrency,
|
44
44
|
short: "-C NUM",
|
45
45
|
long: "--concurrency NUM",
|
46
|
-
description: "The number of allowed concurrent connections",
|
47
|
-
default: 1,
|
46
|
+
description: "The number of allowed concurrent connections - default is number of hosts",
|
48
47
|
proc: lambda { |o| o.to_i }
|
49
48
|
end
|
50
49
|
end
|
@@ -495,4 +495,95 @@ describe Chef::Knife::Winrm do
|
|
495
495
|
end
|
496
496
|
end
|
497
497
|
end
|
498
|
+
|
499
|
+
context "Impact of concurrency value when target nodes are 3" do
|
500
|
+
let(:winrm_user) { "testuser" }
|
501
|
+
let(:transport) { "plaintext" }
|
502
|
+
let(:password) { "testpassword" }
|
503
|
+
let(:protocol) { "basic" }
|
504
|
+
let(:knife_args) do
|
505
|
+
[
|
506
|
+
"-m", "localhost knownhost somehost",
|
507
|
+
"-x", winrm_user,
|
508
|
+
"-P", password,
|
509
|
+
"-w", transport,
|
510
|
+
"--winrm-authentication-protocol", protocol,
|
511
|
+
"echo helloworld"
|
512
|
+
]
|
513
|
+
end
|
514
|
+
let(:winrm_connection) { Dummy::Connection.new }
|
515
|
+
|
516
|
+
subject { Chef::Knife::Winrm.new(knife_args) }
|
517
|
+
|
518
|
+
context "when concurrency limit is not set" do
|
519
|
+
it "spawns a number of connection threads equal to the number of target nodes" do
|
520
|
+
allow(subject).to receive(:run_command_in_thread).and_return("echo helloworld")
|
521
|
+
expect(Thread).to receive(:new).exactly(3).times.and_call_original
|
522
|
+
subject.configure_session
|
523
|
+
subject.relay_winrm_command(knife_args.last)
|
524
|
+
end
|
525
|
+
end
|
526
|
+
|
527
|
+
context "when concurrency limit is set" do
|
528
|
+
it "starts only the required number of threads when there are fewer targets than threads" do
|
529
|
+
knife_args.push("-C", "4")
|
530
|
+
allow(subject).to receive(:run_command_in_thread).and_return("echo helloworld")
|
531
|
+
expect(Thread).to receive(:new).exactly(3).times.and_call_original
|
532
|
+
subject.configure_session
|
533
|
+
subject.relay_winrm_command(knife_args.last)
|
534
|
+
end
|
535
|
+
it "starts only the requested number of threads when there are as many targets as threads" do
|
536
|
+
knife_args.push("-C", "3")
|
537
|
+
allow(subject).to receive(:run_command_in_thread).and_return("echo helloworld")
|
538
|
+
expect(Thread).to receive(:new).exactly(3).times.and_call_original
|
539
|
+
subject.configure_session
|
540
|
+
subject.relay_winrm_command(knife_args.last)
|
541
|
+
end
|
542
|
+
it "starts only the requested number of threads when there are more targets then threads" do
|
543
|
+
knife_args.push("-C", "2")
|
544
|
+
allow(subject).to receive(:run_command_in_thread).and_return("echo helloworld")
|
545
|
+
expect(Thread).to receive(:new).exactly(2).times.and_call_original
|
546
|
+
subject.configure_session
|
547
|
+
subject.relay_winrm_command(knife_args.last)
|
548
|
+
end
|
549
|
+
end
|
550
|
+
|
551
|
+
context "should call run_command_in_thread thrice when" do
|
552
|
+
it "concurrency not set" do
|
553
|
+
expect(subject).to receive(:run_command_in_thread).thrice
|
554
|
+
subject.configure_session
|
555
|
+
subject.relay_winrm_command(knife_args.last)
|
556
|
+
end
|
557
|
+
it "concurrency set to 4" do
|
558
|
+
knife_args.push("-C", "4")
|
559
|
+
expect(subject).to receive(:run_command_in_thread).thrice
|
560
|
+
subject.configure_session
|
561
|
+
subject.relay_winrm_command(knife_args.last)
|
562
|
+
end
|
563
|
+
it "concurrency set to 3" do
|
564
|
+
knife_args.push("-C", "3")
|
565
|
+
expect(subject).to receive(:run_command_in_thread).thrice
|
566
|
+
subject.configure_session
|
567
|
+
subject.relay_winrm_command(knife_args.last)
|
568
|
+
end
|
569
|
+
it "concurrency set to 2" do
|
570
|
+
knife_args.push("-C", "2")
|
571
|
+
expect(subject).to receive(:run_command_in_thread).thrice
|
572
|
+
subject.configure_session
|
573
|
+
subject.relay_winrm_command(knife_args.last)
|
574
|
+
end
|
575
|
+
it "concurrency set to 1" do
|
576
|
+
knife_args.push("-C", "1")
|
577
|
+
expect(subject).to receive(:run_command_in_thread).thrice
|
578
|
+
subject.configure_session
|
579
|
+
subject.relay_winrm_command(knife_args.last)
|
580
|
+
end
|
581
|
+
it "concurrency set to 0" do
|
582
|
+
knife_args.push("-C", "0")
|
583
|
+
expect(subject).to receive(:run_command_in_thread).thrice
|
584
|
+
subject.configure_session
|
585
|
+
subject.relay_winrm_command(knife_args.last)
|
586
|
+
end
|
587
|
+
end
|
588
|
+
end
|
498
589
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: knife-windows
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.0.
|
4
|
+
version: 3.0.11
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Seth Chisamore
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-
|
11
|
+
date: 2020-02-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: chef
|