-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* chg: fix: instance spec parsing * new: test: add unit tests for instance spec parsing * chg: fix: bugs with ssh during scaling * chg: feat: add protection to wait for EBS to unnatach
- Loading branch information
1 parent
2023cb6
commit 6f0a6de
Showing
8 changed files
with
177 additions
and
24 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
package util | ||
|
||
import ( | ||
"reflect" | ||
"testing" | ||
) | ||
|
||
func TestParseInstanceSpec(t *testing.T) { | ||
type args struct { | ||
spec string | ||
} | ||
tests := []struct { | ||
name string | ||
args args | ||
want InstanceSpec | ||
wantErr bool | ||
}{ | ||
{ | ||
name: "the spec is just the instance type", | ||
args: args{ | ||
spec: "t2.micro", | ||
}, | ||
want: InstanceSpec{ | ||
InstanceType: "t2.micro", | ||
}, | ||
wantErr: false, | ||
}, | ||
{ | ||
name: "the spec is just the instance type on filter format", | ||
args: args{ | ||
spec: "type:t2.micro", | ||
}, | ||
want: InstanceSpec{ | ||
InstanceType: "t2.micro", | ||
}, | ||
wantErr: false, | ||
}, | ||
{ | ||
name: "the spec is just the instance type on filter format with spaces", | ||
args: args{ | ||
spec: "type: t2.micro", | ||
}, | ||
want: InstanceSpec{ | ||
InstanceType: "t2.micro", | ||
}, | ||
wantErr: false, | ||
}, | ||
{ | ||
name: "the spec is just the instance type on filter format with spaces and other filters", | ||
args: args{ | ||
spec: "type: t2.micro, mem: 0.5, cpus: 1", | ||
}, | ||
want: InstanceSpec{ | ||
InstanceType: "t2.micro", | ||
MinMemory: 512, | ||
MinCPU: 1, | ||
}, | ||
wantErr: false, | ||
}, | ||
{ | ||
name: "the spec is the cpu and memory", | ||
args: args{ | ||
spec: "mem:0.5,cpus:1", | ||
}, | ||
want: InstanceSpec{ | ||
MinMemory: 512, | ||
MinCPU: 1, | ||
}, | ||
wantErr: false, | ||
}, | ||
{ | ||
name: "the spec is the cpu and memory is an integer", | ||
args: args{ | ||
spec: "mem:1,cpus:1", | ||
}, | ||
want: InstanceSpec{ | ||
MinMemory: 1024, | ||
MinCPU: 1, | ||
}, | ||
wantErr: false, | ||
}, | ||
} | ||
for _, tt := range tests { | ||
t.Run(tt.name, func(t *testing.T) { | ||
got, err := ParseInstanceSpec(tt.args.spec) | ||
if (err != nil) != tt.wantErr { | ||
t.Errorf("ParseInstanceSpec() error = %v, wantErr %v", err, tt.wantErr) | ||
return | ||
} | ||
if !reflect.DeepEqual(got, tt.want) { | ||
t.Errorf("ParseInstanceSpec() = %v, want %v", got, tt.want) | ||
} | ||
}) | ||
} | ||
} |
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