ACI Provider: Adding Liveness/Readiness probes to ACI sdk (#267)
* Adding Liveness/Readiness probes to ACI sdk * Rename Secure to SecureValue * Slightly modify failure test. * Remove errant t.Fatal line
This commit is contained in:
committed by
Robbie Zhang
parent
047e5f22db
commit
9b06d18023
@@ -217,6 +217,149 @@ func TestListContainerGroup(t *testing.T) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestCreateContainerGroupWithLivenessProbe(t *testing.T) {
|
||||||
|
uid := uuid.New()
|
||||||
|
congainerGroupName := containerGroup + "-" + uid.String()[0:6]
|
||||||
|
cg, err := client.CreateContainerGroup(resourceGroup, congainerGroupName, ContainerGroup{
|
||||||
|
Location: location,
|
||||||
|
ContainerGroupProperties: ContainerGroupProperties{
|
||||||
|
OsType: Linux,
|
||||||
|
Containers: []Container{
|
||||||
|
{
|
||||||
|
Name: "nginx",
|
||||||
|
ContainerProperties: ContainerProperties{
|
||||||
|
Image: "nginx",
|
||||||
|
Command: []string{"nginx", "-g", "daemon off;"},
|
||||||
|
Ports: []ContainerPort{
|
||||||
|
{
|
||||||
|
Protocol: ContainerNetworkProtocolTCP,
|
||||||
|
Port: 80,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
Resources: ResourceRequirements{
|
||||||
|
Requests: &ResourceRequests{
|
||||||
|
CPU: 1,
|
||||||
|
MemoryInGB: 1,
|
||||||
|
},
|
||||||
|
Limits: &ResourceLimits{
|
||||||
|
CPU: 1,
|
||||||
|
MemoryInGB: 1,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
LivenessProbe: &ContainerProbe{
|
||||||
|
HTTPGet: &ContainerHTTPGetProbe{
|
||||||
|
Port: 80,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
})
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
if cg.Name != congainerGroupName {
|
||||||
|
t.Fatalf("resource group name is %s, expected %s", cg.Name, congainerGroupName)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestCreateContainerGroupFailsWithLivenessProbeMissingPort(t *testing.T) {
|
||||||
|
uid := uuid.New()
|
||||||
|
congainerGroupName := containerGroup + "-" + uid.String()[0:6]
|
||||||
|
_, err := client.CreateContainerGroup(resourceGroup, congainerGroupName, ContainerGroup{
|
||||||
|
Location: location,
|
||||||
|
ContainerGroupProperties: ContainerGroupProperties{
|
||||||
|
OsType: Linux,
|
||||||
|
Containers: []Container{
|
||||||
|
{
|
||||||
|
Name: "nginx",
|
||||||
|
ContainerProperties: ContainerProperties{
|
||||||
|
Image: "nginx",
|
||||||
|
Command: []string{"nginx", "-g", "daemon off;"},
|
||||||
|
Ports: []ContainerPort{
|
||||||
|
{
|
||||||
|
Protocol: ContainerNetworkProtocolTCP,
|
||||||
|
Port: 80,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
Resources: ResourceRequirements{
|
||||||
|
Requests: &ResourceRequests{
|
||||||
|
CPU: 1,
|
||||||
|
MemoryInGB: 1,
|
||||||
|
},
|
||||||
|
Limits: &ResourceLimits{
|
||||||
|
CPU: 1,
|
||||||
|
MemoryInGB: 1,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
LivenessProbe: &ContainerProbe{
|
||||||
|
HTTPGet: &ContainerHTTPGetProbe{
|
||||||
|
Path: "/",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
})
|
||||||
|
if err == nil {
|
||||||
|
t.Fatal("expected failure")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestCreateContainerGroupWithReadinessProbe(t *testing.T) {
|
||||||
|
uid := uuid.New()
|
||||||
|
congainerGroupName := containerGroup + "-" + uid.String()[0:6]
|
||||||
|
cg, err := client.CreateContainerGroup(resourceGroup, congainerGroupName, ContainerGroup{
|
||||||
|
Location: location,
|
||||||
|
ContainerGroupProperties: ContainerGroupProperties{
|
||||||
|
OsType: Linux,
|
||||||
|
Containers: []Container{
|
||||||
|
{
|
||||||
|
Name: "nginx",
|
||||||
|
ContainerProperties: ContainerProperties{
|
||||||
|
Image: "nginx",
|
||||||
|
Command: []string{"nginx", "-g", "daemon off;"},
|
||||||
|
Ports: []ContainerPort{
|
||||||
|
{
|
||||||
|
Protocol: ContainerNetworkProtocolTCP,
|
||||||
|
Port: 80,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
Resources: ResourceRequirements{
|
||||||
|
Requests: &ResourceRequests{
|
||||||
|
CPU: 1,
|
||||||
|
MemoryInGB: 1,
|
||||||
|
},
|
||||||
|
Limits: &ResourceLimits{
|
||||||
|
CPU: 1,
|
||||||
|
MemoryInGB: 1,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
ReadinessProbe: &ContainerProbe{
|
||||||
|
HTTPGet: &ContainerHTTPGetProbe{
|
||||||
|
Port: 80,
|
||||||
|
Path: "/",
|
||||||
|
},
|
||||||
|
InitialDelaySeconds: 5,
|
||||||
|
SuccessThreshold: 3,
|
||||||
|
FailureThreshold: 5,
|
||||||
|
TimeoutSeconds: 120,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
})
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
if cg.Name != congainerGroupName {
|
||||||
|
t.Fatalf("resource group name is %s, expected %s", cg.Name, congainerGroupName)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func TestDeleteContainerGroup(t *testing.T) {
|
func TestDeleteContainerGroup(t *testing.T) {
|
||||||
err := client.DeleteContainerGroup(resourceGroup, containerGroup)
|
err := client.DeleteContainerGroup(resourceGroup, containerGroup)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|||||||
@@ -121,6 +121,8 @@ type ContainerProperties struct {
|
|||||||
InstanceView ContainerPropertiesInstanceView `json:"instanceView,omitempty"`
|
InstanceView ContainerPropertiesInstanceView `json:"instanceView,omitempty"`
|
||||||
Resources ResourceRequirements `json:"resources,omitempty"`
|
Resources ResourceRequirements `json:"resources,omitempty"`
|
||||||
VolumeMounts []VolumeMount `json:"volumeMounts,omitempty"`
|
VolumeMounts []VolumeMount `json:"volumeMounts,omitempty"`
|
||||||
|
LivenessProbe *ContainerProbe `json:"livenessProbe,omitempty"`
|
||||||
|
ReadinessProbe *ContainerProbe `json:"readinessProbe,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// ContainerPropertiesInstanceView is the instance view of the container instance. Only valid in response.
|
// ContainerPropertiesInstanceView is the instance view of the container instance. Only valid in response.
|
||||||
@@ -142,8 +144,9 @@ type ContainerState struct {
|
|||||||
|
|
||||||
// EnvironmentVariable is the environment variable to set within the container instance.
|
// EnvironmentVariable is the environment variable to set within the container instance.
|
||||||
type EnvironmentVariable struct {
|
type EnvironmentVariable struct {
|
||||||
Name string `json:"name,omitempty"`
|
Name string `json:"name,omitempty"`
|
||||||
Value string `json:"value,omitempty"`
|
Value string `json:"value,omitempty"`
|
||||||
|
SecureValue string `json:"secureValue,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// Event is a container group or container instance event.
|
// Event is a container group or container instance event.
|
||||||
@@ -293,3 +296,27 @@ type ExecResponse struct {
|
|||||||
WebSocketUri string `json:"webSocketUri,omitempty"`
|
WebSocketUri string `json:"webSocketUri,omitempty"`
|
||||||
Password string `json:"password,omitempty"`
|
Password string `json:"password,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ContainerProbe is a probe definition that can be used for Liveness
|
||||||
|
// or Readiness checks.
|
||||||
|
type ContainerProbe struct {
|
||||||
|
Exec *ContainerExecProbe `json:"exec,omitempty"`
|
||||||
|
HTTPGet *ContainerHTTPGetProbe `json:"httpGet,omitempty"`
|
||||||
|
InitialDelaySeconds int32 `json:"initialDelaySeconds,omitempty"`
|
||||||
|
Period int32 `json:"periodSeconds,omitempty"`
|
||||||
|
FailureThreshold int32 `json:"failureThreshold,omitempty"`
|
||||||
|
SuccessThreshold int32 `json:"successThreshold,omitempty"`
|
||||||
|
TimeoutSeconds int32 `json:"timeoutSeconds,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// ContainerExecProbe defines a command based probe
|
||||||
|
type ContainerExecProbe struct {
|
||||||
|
Command []string `json:"command,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// ContainerHTTPGetProbe defines an HTTP probe
|
||||||
|
type ContainerHTTPGetProbe struct {
|
||||||
|
Port int `json:"port"`
|
||||||
|
Path string `json:"path,omitempty"`
|
||||||
|
Scheme string `json:"scheme,omitempty"`
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user