-
Notifications
You must be signed in to change notification settings - Fork 47
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Add
add_services
instruction to start services in bulk (#912)
Closes #802
- Loading branch information
Guillaume Bouvignies
committed
Jan 23, 2023
1 parent
145df1a
commit e3c3124
Showing
12 changed files
with
707 additions
and
131 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
84 changes: 84 additions & 0 deletions
84
api/golang/core/lib/services/service_config_builder_test.go
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,84 @@ | ||
package services | ||
|
||
import ( | ||
"github.com/kurtosis-tech/kurtosis/api/golang/core/kurtosis_core_rpc_api_bindings" | ||
"github.com/kurtosis-tech/kurtosis/api/golang/core/lib/binding_constructors" | ||
"github.com/stretchr/testify/require" | ||
"testing" | ||
) | ||
|
||
func TestServiceConfigBuilderFrom_Invariant(t *testing.T) { | ||
initialServiceConfig := NewServiceConfigBuilder( | ||
"test-image", | ||
).WithPrivatePorts( | ||
map[string]*kurtosis_core_rpc_api_bindings.Port{ | ||
"grpc": binding_constructors.NewPort(1323, kurtosis_core_rpc_api_bindings.Port_TCP, "https"), | ||
}, | ||
).WithPublicPorts( | ||
map[string]*kurtosis_core_rpc_api_bindings.Port{ | ||
"grpc": binding_constructors.NewPort(1323, kurtosis_core_rpc_api_bindings.Port_TCP, "https"), | ||
}, | ||
).WithEntryPointArgs( | ||
[]string{"echo", "'Hello World!'"}, | ||
).WithCmdArgs( | ||
[]string{"sleep", "999999"}, | ||
).WithEnvVars( | ||
map[string]string{ | ||
"VAR_1": "VALUE", | ||
}, | ||
).WithFilesArtifactMountDirpaths( | ||
map[string]string{ | ||
"/path/to/file": "artifact", | ||
}, | ||
).WithCpuAllocationMillicpus( | ||
1000, | ||
).WithMemoryAllocationMegabytes( | ||
1024, | ||
).WithPrivateIPAddressPlaceholder( | ||
"<IP_ADDRESS>", | ||
).WithSubnetwork( | ||
"subnetwork_1", | ||
).Build() | ||
|
||
newServiceConfigBuilder := NewServiceConfigBuilderFromServiceConfig(initialServiceConfig) | ||
newServiceConfig := newServiceConfigBuilder.Build() | ||
|
||
require.Equal(t, initialServiceConfig, newServiceConfig) | ||
|
||
// modify random values | ||
newServiceConfig.ContainerImageName = "new-test-image" | ||
newServiceConfig.PrivatePorts["grpc"].Number = 9876 | ||
newServiceConfig.PublicPorts["grpc"].MaybeApplicationProtocol = "ftp" | ||
newServiceConfig.EntrypointArgs[0] = "new-echo" | ||
newServiceConfig.CmdArgs[1] = "1234" | ||
newServiceConfig.EnvVars["VAR_1"] = "NEW_VALUE" | ||
newServiceConfig.FilesArtifactMountpoints["new/path/to/file"] = "new-artifact" | ||
newServiceConfig.CpuAllocationMillicpus = 500 | ||
newServiceConfig.MemoryAllocationMegabytes = 512 | ||
newSubnetwork := "new-subnetwork" | ||
newServiceConfig.Subnetwork = &newSubnetwork | ||
|
||
// test that initial value has not changed | ||
require.Equal(t, "test-image", initialServiceConfig.ContainerImageName) | ||
require.Equal(t, binding_constructors.NewPort(1323, kurtosis_core_rpc_api_bindings.Port_TCP, "https"), initialServiceConfig.PrivatePorts["grpc"]) | ||
require.Equal(t, binding_constructors.NewPort(1323, kurtosis_core_rpc_api_bindings.Port_TCP, "https"), initialServiceConfig.PublicPorts["grpc"]) | ||
require.Equal(t, []string{"echo", "'Hello World!'"}, initialServiceConfig.EntrypointArgs) | ||
require.Equal(t, []string{"sleep", "999999"}, initialServiceConfig.CmdArgs) | ||
require.Equal(t, map[string]string{"VAR_1": "VALUE"}, initialServiceConfig.EnvVars) | ||
require.Equal(t, map[string]string{"/path/to/file": "artifact"}, initialServiceConfig.FilesArtifactMountpoints) | ||
require.Equal(t, uint64(1000), initialServiceConfig.CpuAllocationMillicpus) | ||
require.Equal(t, uint64(1024), initialServiceConfig.MemoryAllocationMegabytes) | ||
require.Equal(t, "subnetwork_1", *initialServiceConfig.Subnetwork) | ||
|
||
// test that new value are as expected | ||
require.Equal(t, "new-test-image", newServiceConfig.ContainerImageName) | ||
require.Equal(t, binding_constructors.NewPort(9876, kurtosis_core_rpc_api_bindings.Port_TCP, "https"), newServiceConfig.PrivatePorts["grpc"]) | ||
require.Equal(t, binding_constructors.NewPort(1323, kurtosis_core_rpc_api_bindings.Port_TCP, "ftp"), newServiceConfig.PublicPorts["grpc"]) | ||
require.Equal(t, []string{"new-echo", "'Hello World!'"}, newServiceConfig.EntrypointArgs) | ||
require.Equal(t, []string{"sleep", "1234"}, newServiceConfig.CmdArgs) | ||
require.Equal(t, map[string]string{"VAR_1": "NEW_VALUE"}, newServiceConfig.EnvVars) | ||
require.Equal(t, map[string]string{"/path/to/file": "artifact", "new/path/to/file": "new-artifact"}, newServiceConfig.FilesArtifactMountpoints) | ||
require.Equal(t, uint64(500), newServiceConfig.CpuAllocationMillicpus) | ||
require.Equal(t, uint64(512), newServiceConfig.MemoryAllocationMegabytes) | ||
require.Equal(t, "new-subnetwork", *newServiceConfig.Subnetwork) | ||
} |
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
Oops, something went wrong.