-
Notifications
You must be signed in to change notification settings - Fork 52
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 #8 in DEVOPS/orgalorg from limit-threading to master
* commit '12ca7aa8dc9eaef38f0d839621105ccda88cbd63': bubble args from craateThreadsPool fix errornous typo move threads size debug rename pool to thread_pool limit threading capabilities & flag -d
- Loading branch information
Showing
10 changed files
with
181 additions
and
69 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
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
10 changes: 10 additions & 0 deletions
10
tests/testcases/commands/can-aggregate-errors-on-the-end-of-execution.test.sh
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 |
---|---|---|
@@ -0,0 +1,10 @@ | ||
tests:not tests:ensure :orgalorg:with-key -e -C echo 1 '&&' exit 1 | ||
|
||
:check-node-output() { | ||
local container_ip="$2" | ||
|
||
tests:assert-stdout "$container_ip 1" | ||
tests:assert-stderr-re "$container_ip.*non-zero code: 1" | ||
} | ||
|
||
containers:do :check-node-output |
2 changes: 1 addition & 1 deletion
2
tests/testcases/verbosity/can-report-internal-errors-in-json-format.test.sh
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,5 +1,5 @@ | ||
tests:not tests:ensure :orgalorg:with-key --json -o example.com -C pwd | ||
|
||
tests:assert-stderr-re '"stream":"stderr"' | ||
tests:assert-stderr-re '"body":".*ERROR.*create runner for address' | ||
tests:assert-stderr-re '"body":".*ERROR.*connect to address' | ||
tests:not tests:assert-stderr '└─' |
2 changes: 1 addition & 1 deletion
2
tests/testcases/verbosity/will-output-hierarchical-errors-by-default.test.sh
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,3 +1,3 @@ | ||
tests:not tests:ensure :orgalorg:with-key -o example.com -C pwd | ||
|
||
tests:assert-stderr "└─ can't create runner" | ||
tests:assert-stderr "└─ can't connect to address" |
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 |
---|---|---|
@@ -0,0 +1,50 @@ | ||
package main | ||
|
||
import ( | ||
"strconv" | ||
|
||
"github.com/seletskiy/hierr" | ||
) | ||
|
||
type threadPool struct { | ||
available chan struct{} | ||
|
||
size int | ||
} | ||
|
||
func newThreadPool(size int) *threadPool { | ||
available := make(chan struct{}, size) | ||
for i := 0; i < size; i++ { | ||
available <- struct{}{} | ||
} | ||
|
||
return &threadPool{ | ||
available, | ||
size, | ||
} | ||
} | ||
|
||
func (pool *threadPool) run(task func()) { | ||
<-pool.available | ||
defer func() { | ||
pool.available <- struct{}{} | ||
}() | ||
|
||
task() | ||
} | ||
|
||
func parseThreadPoolSize(args map[string]interface{}) (int, error) { | ||
var ( | ||
poolSizeRaw = args["--threads"].(string) | ||
) | ||
|
||
poolSize, err := strconv.Atoi(poolSizeRaw) | ||
if err != nil { | ||
return 0, hierr.Errorf( | ||
err, | ||
`can't parse threads count`, | ||
) | ||
} | ||
|
||
return poolSize, nil | ||
} |