Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions cns/NetworkContainerContract.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,10 @@ const (
const (
AzureContainerInstance = "AzureContainerInstance"
WebApps = "WebApps"
ClearContainer = "ClearContainer"
Docker = "Docker"
Basic = "Basic"
JobObject = "JobObject"
COW = "COW" // Container on Windows
)

// Orchestrator Types
Expand Down Expand Up @@ -171,7 +171,7 @@ type AttachContainerToNetworkResponse struct {
Response Response
}

// DetachNetworkContainerToNetworkResponse specifies response of detaching network container from network.
// DetachContainerFromNetworkResponse specifies response of detaching network container from network.
type DetachContainerFromNetworkResponse struct {
Response Response
}
Expand Down
1 change: 1 addition & 0 deletions cns/restserver/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ const (
UnexpectedError = 99
)

// ReturnCodeToString - Converts an error code to appropriate string.
func ReturnCodeToString(returnCode int) (s string) {
switch returnCode {
case Success:
Expand Down
6 changes: 3 additions & 3 deletions cns/restserver/restserver.go
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ func (service *HTTPRestService) Stop() {
log.Printf("[Azure CNS] Service stopped.")
}

// Get dnc/service partition key
// GetPartitionKey - Get dnc/service partition key
func (service *HTTPRestService) GetPartitionKey() (dncPartitionKey string) {
service.lock.Lock()
dncPartitionKey = service.dncPartitionKey
Expand Down Expand Up @@ -1025,13 +1025,13 @@ func (service *HTTPRestService) saveNetworkContainerGoalState(req cns.CreateNetw
switch req.NetworkContainerType {
case cns.AzureContainerInstance:
fallthrough
case cns.ClearContainer:
fallthrough
case cns.Docker:
fallthrough
case cns.Basic:
fallthrough
case cns.JobObject:
fallthrough
case cns.COW:
switch service.state.OrchestratorType {
case cns.Kubernetes:
fallthrough
Expand Down
21 changes: 18 additions & 3 deletions cns/restserver/restserver_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -580,7 +580,7 @@ func TestCreateNetworkContainer(t *testing.T) {

// Test create network container of type JobObject
fmt.Println("TestCreateNetworkContainer: JobObject")
err := creatOrUpdateNetworkContainerWithName(t, "testJobObject", "11.0.0.5", "JobObject")
err := creatOrUpdateNetworkContainerWithName(t, "testJobObject", "10.1.0.5", "JobObject")
if err != nil {
t.Errorf("Failed to save the goal state for network container of type JobObject "+
" due to error: %+v", err)
Expand All @@ -596,13 +596,13 @@ func TestCreateNetworkContainer(t *testing.T) {

// Test create network container of type WebApps
fmt.Println("TestCreateNetworkContainer: WebApps")
err = creatOrUpdateNetworkContainerWithName(t, "ethWebApp", "11.0.0.5", "WebApps")
err = creatOrUpdateNetworkContainerWithName(t, "ethWebApp", "192.0.0.5", "WebApps")
if err != nil {
t.Errorf("creatOrUpdateWebAppContainerWithName failed Err:%+v", err)
t.Fatal(err)
}

err = creatOrUpdateNetworkContainerWithName(t, "ethWebApp", "11.0.0.6", "WebApps")
err = creatOrUpdateNetworkContainerWithName(t, "ethWebApp", "192.0.0.6", "WebApps")
if err != nil {
t.Errorf("Updating interface failed Err:%+v", err)
t.Fatal(err)
Expand All @@ -616,6 +616,21 @@ func TestCreateNetworkContainer(t *testing.T) {
t.Fatal(err)
}

// Test create network container of type COW
err = creatOrUpdateNetworkContainerWithName(t, "testCOWContainer", "10.0.0.5", "COW")
if err != nil {
t.Errorf("Failed to save the goal state for network container of type COW"+
" due to error: %+v", err)
t.Fatal(err)
}

fmt.Println("Deleting the saved goal state for network container of type COW")
err = deleteNetworkAdapterWithName(t, "testCOWContainer")
if err != nil {
t.Errorf("Failed to delete the saved goal state due to error: %+v", err)
t.Fatal(err)
}

}

func TestGetNetworkContainerByOrchestratorContext(t *testing.T) {
Expand Down