Skip to content

Commit 2e56ae5

Browse files
authored
Improve status conditions
1 parent 9edf7c0 commit 2e56ae5

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

iterative/utils/logger.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -72,13 +72,13 @@ func (f *tpiFormatter) Format(entry *logrus.Entry) ([]byte, error) {
7272

7373
message = fmt.Sprintf("\x1b[%dmStatus: queued 🔵\x1b[0m", colors["DEBUG"])
7474

75-
if status["succeeded"] != nil && status["succeeded"].(int) > 0 {
75+
if status["succeeded"] != nil && status["succeeded"].(int) >= d.Get("parallelism").(int) {
7676
message = fmt.Sprintf("\x1b[%dmStatus: completed succesfully 🟢\x1b[0m", colors["SUCCESS"])
7777
}
7878
if status["failed"] != nil && status["failed"].(int) > 0 {
7979
message = fmt.Sprintf("\x1b[%dmStatus: completed with errors 🔴\x1b[0m", colors["ERROR"])
8080
}
81-
if status["running"] != nil && status["running"].(int) > 0 {
81+
if status["running"] != nil && status["running"].(int) >= d.Get("parallelism").(int) {
8282
message = fmt.Sprintf("\x1b[%dmStatus: running 🟡\x1b[0m", colors["WARNING"])
8383
}
8484
}

iterative/utils/logger_test.go

+9
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import (
99
func TestState(t *testing.T) {
1010
d := generateSchemaData(t, map[string]interface{}{
1111
"name": "mytask",
12+
"parallelism": "1",
1213
"status": map[string]interface{}{
1314
"running": 0,
1415
"failed": 0,
@@ -22,6 +23,7 @@ func TestState(t *testing.T) {
2223
func TestState2(t *testing.T) {
2324
d := generateSchemaData(t, map[string]interface{}{
2425
"name": "mytask",
26+
"parallelism": "1",
2527
"status": map[string]interface{}{
2628
"running": 0,
2729
"failed": 1,
@@ -35,6 +37,7 @@ func TestState2(t *testing.T) {
3537
func TestState3(t *testing.T) {
3638
d := generateSchemaData(t, map[string]interface{}{
3739
"name": "mytask",
40+
"parallelism": "1",
3841
"status": map[string]interface{}{
3942
"running": 0,
4043
"succeeded": 1,
@@ -141,6 +144,12 @@ func generateSchemaData(t *testing.T, raw map[string]interface{}) *schema.Resour
141144
Type: schema.TypeString,
142145
},
143146
},
147+
"parallelism": {
148+
Type: schema.TypeInt,
149+
ForceNew: true,
150+
Optional: true,
151+
Default: 1,
152+
},
144153
"script": {
145154
Type: schema.TypeString,
146155
ForceNew: true,

0 commit comments

Comments
 (0)