mirror of
https://github.com/kemko/nomad.git
synced 2026-01-06 18:35:44 +03:00
mock: add default host network
This commit is contained in:
@@ -37,6 +37,12 @@ func MockJob() *api.Job {
|
||||
Delay: helper.TimeToPtr(1 * time.Minute),
|
||||
Mode: helper.StringToPtr("delay"),
|
||||
},
|
||||
Networks: []*api.NetworkResource{
|
||||
{
|
||||
Mode: "host",
|
||||
DynamicPorts: []api.Port{{Label: "http"}, {Label: "admin"}},
|
||||
},
|
||||
},
|
||||
Tasks: []*api.Task{
|
||||
{
|
||||
Name: "web",
|
||||
@@ -72,12 +78,6 @@ func MockJob() *api.Job {
|
||||
Resources: &api.Resources{
|
||||
CPU: helper.IntToPtr(500),
|
||||
MemoryMB: helper.IntToPtr(256),
|
||||
Networks: []*api.NetworkResource{
|
||||
{
|
||||
MBits: helper.IntToPtr(50),
|
||||
DynamicPorts: []api.Port{{Label: "http"}, {Label: "admin"}},
|
||||
},
|
||||
},
|
||||
},
|
||||
Meta: map[string]string{
|
||||
"foo": "bar",
|
||||
|
||||
@@ -183,6 +183,7 @@ func TestJobEndpoint_Register_Connect(t *testing.T) {
|
||||
|
||||
// Create the register request
|
||||
job := mock.Job()
|
||||
job.TaskGroups[0].Tasks[0].Services = nil
|
||||
job.TaskGroups[0].Networks = structs.Networks{{
|
||||
Mode: "bridge",
|
||||
}}
|
||||
@@ -453,6 +454,7 @@ func TestJobEndpoint_Register_ConnectExposeCheck(t *testing.T) {
|
||||
|
||||
// Setup the job we are going to register
|
||||
job := mock.Job()
|
||||
job.TaskGroups[0].Tasks[0].Services = nil
|
||||
job.TaskGroups[0].Networks = structs.Networks{{
|
||||
Mode: "bridge",
|
||||
DynamicPorts: []structs.Port{{
|
||||
@@ -571,6 +573,7 @@ func TestJobEndpoint_Register_ConnectWithSidecarTask(t *testing.T) {
|
||||
Mode: "bridge",
|
||||
},
|
||||
}
|
||||
job.TaskGroups[0].Tasks[0].Services = nil
|
||||
job.TaskGroups[0].Services = []*structs.Service{
|
||||
{
|
||||
Name: "backend",
|
||||
@@ -665,11 +668,7 @@ func TestJobEndpoint_Register_Connect_AllowUnauthenticatedFalse(t *testing.T) {
|
||||
|
||||
// Create the register request
|
||||
job := mock.Job()
|
||||
job.TaskGroups[0].Networks = structs.Networks{
|
||||
{
|
||||
Mode: "bridge",
|
||||
},
|
||||
}
|
||||
job.TaskGroups[0].Networks[0].Mode = "bridge"
|
||||
job.TaskGroups[0].Services = []*structs.Service{
|
||||
{
|
||||
Name: "service1", // matches consul.ExamplePolicyID1
|
||||
|
||||
@@ -77,6 +77,13 @@ func Node() *structs.Node {
|
||||
Mode: "host",
|
||||
Device: "eth0",
|
||||
Speed: 1000,
|
||||
Addresses: []structs.NodeNetworkAddress{
|
||||
{
|
||||
Alias: "default",
|
||||
Address: "192.168.0.100",
|
||||
Family: structs.NodeNetworkAF_IPv4,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -211,6 +218,7 @@ func Job() *structs.Job {
|
||||
Migrate: structs.DefaultMigrateStrategy(),
|
||||
Networks: []*structs.NetworkResource{
|
||||
{
|
||||
Mode: "host",
|
||||
DynamicPorts: []structs.Port{
|
||||
{Label: "http"},
|
||||
{Label: "admin"},
|
||||
|
||||
Reference in New Issue
Block a user