Exemple #1
0
func (ft *FacadeTest) Test_PoolCapacity(t *C) {
	hostid := "deadb23f"
	poolid := "pool-id"

	//create pool for test
	rp := pool.New(poolid)
	if err := ft.Facade.AddResourcePool(ft.CTX, rp); err != nil {
		t.Fatalf("Could not add pool for test: %v", err)
	}

	//fill host with required values
	h, err := host.Build("", "65535", poolid, []string{}...)
	h.ID = hostid
	if err != nil {
		t.Fatalf("Unexpected error building host: %v", err)
	}

	err = ft.Facade.AddHost(ft.CTX, h)
	if err != nil {
		t.Errorf("Unexpected error adding host: %v", err)
	}

	// load pool with calculated capacity
	loadedPool, err := ft.Facade.GetResourcePool(ft.CTX, poolid)

	if err != nil {
		t.Fatalf("Unexpected error calculating pool capacity: %v", err)
	}

	if loadedPool.CoreCapacity <= 0 || loadedPool.MemoryCapacity <= 0 {
		t.Fatalf("Unexpected values calculated for %s capacity: CPU - %v : Memory - %v", loadedPool.ID, loadedPool.CoreCapacity, loadedPool.MemoryCapacity)
	}
}
Exemple #2
0
//GetResourcePool gets the pool for the given poolID or nil
func (c *Client) GetResourcePool(poolID string) (*pool.ResourcePool, error) {
	response := pool.New(poolID)
	if err := c.call("GetResourcePool", poolID, response); err != nil {
		return nil, err
	}
	return response, nil
}
Exemple #3
0
func (ft *FacadeTest) Test_GetResourcePools(t *C) {
	result, err := ft.Facade.GetResourcePools(ft.CTX)
	if err != nil {
		t.Fatalf("unexpected error: %v", err)
	}
	if len(result) != 0 {
		pools := make([]pool.ResourcePool, len(result))
		for i, pool := range result {
			pools[i] = pool
		}

		t.Fatalf("unexpected pool found: %v", pools)
	}

	poolID := "Test_GetResourcePools"
	defer ft.Facade.RemoveResourcePool(ft.CTX, poolID)
	rp := pool.New(poolID)
	rp.CoreLimit = 2
	rp.MemoryLimit = 3
	ft.Facade.AddResourcePool(ft.CTX, rp)
	time.Sleep(time.Second * 2)
	result, err = ft.Facade.GetResourcePools(ft.CTX)
	if err == nil && len(result) == 1 {
		result[0].CreatedAt = rp.CreatedAt
		result[0].UpdatedAt = rp.UpdatedAt
		if !result[0].Equals(rp) {
			t.Fatalf("expected [%+v] actual=%s", rp, result)
		}
	} else {
		t.Fatalf("Unexpected Error Retrieving ResourcePools: %v", err)
	}
}
Exemple #4
0
func (ft *FacadeTest) Test_GetPoolsIPs(t *C) {
	assignIPsPool := pool.New("Test_GetPoolsIPs")
	err := ft.Facade.AddResourcePool(ft.CTX, assignIPsPool)
	defer func() {
		ft.Facade.RemoveResourcePool(ft.CTX, assignIPsPool.ID)
	}()

	if err != nil {
		t.Errorf("Failure creating resource pool %-v with error: %s", assignIPsPool, err)
		t.Fail()
	}

	hostID := "deadb21f"
	ipAddress1 := "192.168.100.10"
	ipAddress2 := "10.50.9.1"

	assignIPsHostIPResources := []host.HostIPResource{}
	oneHostIPResource := host.HostIPResource{}
	oneHostIPResource.HostID = hostID
	oneHostIPResource.IPAddress = ipAddress1
	oneHostIPResource.InterfaceName = "eth0"
	assignIPsHostIPResources = append(assignIPsHostIPResources, oneHostIPResource)
	oneHostIPResource.HostID = "A"
	oneHostIPResource.IPAddress = ipAddress2
	oneHostIPResource.InterfaceName = "eth1"
	assignIPsHostIPResources = append(assignIPsHostIPResources, oneHostIPResource)

	assignIPsHost, err := host.Build("", "65535", assignIPsPool.ID, []string{}...)
	if err != nil {
		t.Fatalf("could not build host for test: %v", err)
	}
	assignIPsHost.ID = hostID
	assignIPsHost.PoolID = assignIPsPool.ID
	assignIPsHost.IPs = assignIPsHostIPResources
	err = ft.Facade.AddHost(ft.CTX, assignIPsHost)
	if err != nil {
		t.Fatalf("failed to add host: %v", err)
	}
	defer func() {
		ft.Facade.RemoveHost(ft.CTX, assignIPsHost.ID)
	}()
	time.Sleep(2 * time.Second)
	IPs, err := ft.Facade.GetPoolIPs(ft.CTX, assignIPsPool.ID)
	if err != nil {
		t.Error("GetPoolIps failed")
	}
	if len(IPs.HostIPs) != 2 {
		t.Fatalf("Expected 2 addresses, found %v", len(IPs.HostIPs))
	}

	if IPs.HostIPs[0].IPAddress != ipAddress1 {
		t.Errorf("Unexpected IP address: %v", IPs.HostIPs[0].IPAddress)
	}
	if IPs.HostIPs[1].IPAddress != ipAddress2 {
		t.Errorf("Unexpected IP address: %v", IPs.HostIPs[1].IPAddress)
	}

}
Exemple #5
0
func (ft *FacadeTest) Test_PoolCommitment(t *C) {
	poolid := "pool-id"

	//create pool for test
	rp := pool.New(poolid)
	if err := ft.Facade.AddResourcePool(ft.CTX, rp); err != nil {
		t.Fatalf("Could not add pool for test: %v", err)
	}

	// load pool with calculated capacity
	loadedPool, err := ft.Facade.GetResourcePool(ft.CTX, poolid)

	commitmentErr := ft.Facade.calcPoolCommitment(ft.CTX, loadedPool)

	if commitmentErr != nil {
		t.Fatalf("Unexpected error calculating pool commitment: %v", err)
	}
}
Exemple #6
0
func (ft *FacadeTest) Test_RemoveResourcePool(t *C) {

	poolID := "Test_RemoveResourcePool"
	result, err := ft.Facade.GetResourcePool(ft.CTX, poolID)
	t.Assert(err, IsNil)
	t.Assert(result, IsNil)
	err = ft.Facade.RemoveResourcePool(ft.CTX, poolID)
	t.Assert(err, IsNil)

	rp := pool.New(poolID)
	err = ft.Facade.AddResourcePool(ft.CTX, rp)
	t.Assert(err, IsNil)

	rp, err = ft.Facade.GetResourcePool(ft.CTX, poolID)
	t.Assert(err, IsNil)
	t.Assert(rp.ID, Equals, poolID)

	err = ft.Facade.RemoveResourcePool(ft.CTX, poolID)
	t.Assert(err, IsNil)
	rp, err = ft.Facade.GetResourcePool(ft.CTX, poolID)
	t.Assert(err, IsNil)
	t.Assert(rp, IsNil)
}
Exemple #7
0
func (ft *FacadeTest) Test_GetResourcePool(t *C) {
	poolID := "Test_UpdateResourcePool"
	defer ft.Facade.RemoveResourcePool(ft.CTX, poolID)

	ft.Facade.RemoveResourcePool(ft.CTX, poolID)
	rp := pool.New(poolID)
	rp.CoreLimit = 1
	rp.MemoryLimit = 1
	if err := ft.Facade.AddResourcePool(ft.CTX, rp); err != nil {
		t.Fatalf("Failed to add resource pool: %v", err)
	}

	result, err := ft.Facade.GetResourcePool(ft.CTX, poolID)
	result.CreatedAt = rp.CreatedAt
	result.UpdatedAt = rp.UpdatedAt
	if err == nil {
		if !rp.Equals(result) {
			t.Errorf("Unexpected ResourcePool: expected=%+v, actual=%+v", rp, result)
		}
	} else {
		t.Errorf("Unexpected Error Retrieving ResourcePool: %v", err)
	}
}
Exemple #8
0
func (ft *FacadeTest) Test_UpdateResourcePool(t *C) {
	poolID := "Test_UpdateResourcePool"
	defer ft.Facade.RemoveResourcePool(ft.CTX, poolID)

	myPool := pool.New(poolID)
	ft.Facade.AddResourcePool(ft.CTX, myPool)

	myPool.CoreLimit = 1
	myPool.MemoryLimit = 1
	err := ft.Facade.UpdateResourcePool(ft.CTX, myPool)
	if err != nil {
		t.Errorf("Failure updating resource pool %-v with error: %s", myPool, err)
		t.Fail()
	}

	result, err := ft.Facade.GetResourcePool(ft.CTX, poolID)
	result.CreatedAt = myPool.CreatedAt
	result.UpdatedAt = myPool.UpdatedAt
	if !myPool.Equals(result) {
		t.Errorf("%+v != %+v", myPool, result)
		t.Fail()
	}
}
Exemple #9
0
func (s *FacadeTest) Test_HostRemove(t *C) {
	//create pool for testing
	resoucePool := pool.New("poolid")
	s.Facade.AddResourcePool(s.CTX, resoucePool)
	defer s.Facade.RemoveResourcePool(s.CTX, "poolid")

	//add host1
	h1 := host.Host{
		ID:      "deadb11f",
		PoolID:  "poolid",
		Name:    "h1",
		IPAddr:  "192.168.0.1",
		RPCPort: 65535,
		IPs: []host.HostIPResource{
			host.HostIPResource{
				HostID:    "deadb11f",
				IPAddress: "192.168.0.1",
			},
		},
	}
	err := s.Facade.AddHost(s.CTX, &h1)
	if err != nil {
		t.Fatalf("Failed to add host %+v: %s", h1, err)
	}

	//add host2
	h2 := host.Host{
		ID:      "deadb12f",
		PoolID:  "poolid",
		Name:    "h2",
		IPAddr:  "192.168.0.2",
		RPCPort: 65535,
		IPs: []host.HostIPResource{
			host.HostIPResource{
				HostID:    "deadb12f",
				IPAddress: "192.168.0.2",
			},
		},
	}
	err = s.Facade.AddHost(s.CTX, &h2)
	if err != nil {
		t.Fatalf("Failed to add host %+v: %s", h2, err)
	}
	defer s.Facade.RemoveHost(s.CTX, "host2")

	//add service with address assignment
	s1, _ := service.NewService()
	s1.Name = "name"
	s1.PoolID = "poolid"
	s1.DeploymentID = "deployment_id"
	s1.Launch = "manual"
	s1.Endpoints = []service.ServiceEndpoint{
		service.ServiceEndpoint{},
	}
	s1.Endpoints[0].Name = "name"
	s1.Endpoints[0].AddressConfig = servicedefinition.AddressResourceConfig{Port: 123, Protocol: "tcp"}
	aa := addressassignment.AddressAssignment{ID: "id", HostID: h1.ID}
	s1.Endpoints[0].SetAssignment(aa)
	err = s.Facade.AddService(s.CTX, *s1)
	if err != nil {
		t.Fatalf("Failed to add service %+v: %s", s1, err)
	}
	defer s.Facade.RemoveService(s.CTX, s1.ID)

	request := dao.AssignmentRequest{ServiceID: s1.ID, IPAddress: h1.IPAddr, AutoAssignment: false}
	if err = s.Facade.AssignIPs(s.CTX, request); err != nil {
		t.Fatalf("Failed assigning ip to service: %s", err)
	}

	var serviceRequest dao.ServiceRequest
	services, _ := s.Facade.GetServices(s.CTX, serviceRequest)
	if len(services) <= 0 {
		t.Fatalf("Expected one service in context")
	}
	if len(services[0].Endpoints) <= 0 {
		t.Fatalf("Expected service with one endpoint in context")
	}
	ep := services[0].Endpoints[0]
	if ep.AddressAssignment.IPAddr != h1.IPAddr && ep.AddressAssignment.HostID != h1.ID {
		t.Fatalf("Incorrect IPAddress and HostID before remove host")
	}

	//remove host1
	err = s.Facade.RemoveHost(s.CTX, h1.ID)
	if err != nil {
		t.Fatalf("Failed to remove host: %s", err)
	}
	services, _ = s.Facade.GetServices(s.CTX, serviceRequest)

	if len(services) <= 0 {
		t.Fatalf("Expected one service in context")
	}

	if len(services[0].Endpoints) <= 0 {
		t.Fatalf("Expected service with one endpoint in context")
	}

	ep = services[0].Endpoints[0]
	if ep.AddressAssignment.IPAddr == h2.IPAddr || ep.AddressAssignment.HostID == h2.ID {
		t.Fatalf("Incorrect IPAddress and HostID after remove host")
	}
}
Exemple #10
0
func (s *FacadeTest) Test_HostCRUD(t *C) {
	testid := "deadb10f"
	poolid := "pool-id"
	defer s.Facade.RemoveHost(s.CTX, testid)

	//fill host with required values
	h, err := host.Build("", "65535", poolid, []string{}...)
	h.ID = testid
	if err != nil {
		t.Fatalf("Unexpected error building host: %v", err)
	}
	glog.Infof("Facade test add host %v", h)
	err = s.Facade.AddHost(s.CTX, h)
	//should fail since pool doesn't exist
	if err == nil {
		t.Errorf("Expected error: %v", err)
	}

	//create pool for test
	rp := pool.New(poolid)
	if err := s.Facade.AddResourcePool(s.CTX, rp); err != nil {
		t.Fatalf("Could not add pool for test: %v", err)
	}
	defer s.Facade.RemoveResourcePool(s.CTX, poolid)

	err = s.Facade.AddHost(s.CTX, h)
	if err != nil {
		t.Errorf("Unexpected error adding host: %v", err)
	}

	//Test re-add fails
	err = s.Facade.AddHost(s.CTX, h)
	if err == nil {
		t.Errorf("Expected already exists error: %v", err)
	}

	h2, err := s.Facade.GetHost(s.CTX, testid)
	if err != nil {
		t.Errorf("Unexpected error: %v", err)
	}
	if h2 == nil {
		t.Error("Unexpected nil host")

	} else if !host.HostEquals(t, h, h2) {
		t.Error("Hosts did not match")
	}

	//Test update
	h.Memory = 1024
	err = s.Facade.UpdateHost(s.CTX, h)
	h2, err = s.Facade.GetHost(s.CTX, testid)
	if err != nil {
		t.Errorf("Unexpected error: %v", err)
	}
	if !host.HostEquals(t, h, h2) {
		t.Error("Hosts did not match")
	}

	//test delete
	err = s.Facade.RemoveHost(s.CTX, testid)
	h2, err = s.Facade.GetHost(s.CTX, testid)
	if err != nil && !datastore.IsErrNoSuchEntity(err) {
		t.Errorf("Unexpected error: %v", err)
	}
}
func (dt *DaoTest) TestDaoAutoAssignIPs(t *C) {
	assignIPsPool := pool.New("assignIPsPoolID")
	fmt.Printf("%s\n", assignIPsPool.ID)
	err := dt.Facade.AddResourcePool(dt.CTX, assignIPsPool)
	if err != nil {
		t.Errorf("Failure creating resource pool %-v with error: %s", assignIPsPool, err)
		t.Fail()
	}

	ipAddress1 := "192.168.100.10"
	ipAddress2 := "10.50.9.1"

	assignIPsHostIPResources := []host.HostIPResource{}
	oneHostIPResource := host.HostIPResource{}
	oneHostIPResource.HostID = HOSTID
	oneHostIPResource.IPAddress = ipAddress1
	oneHostIPResource.InterfaceName = "eth0"
	assignIPsHostIPResources = append(assignIPsHostIPResources, oneHostIPResource)
	oneHostIPResource.HostID = HOSTID
	oneHostIPResource.IPAddress = ipAddress2
	oneHostIPResource.InterfaceName = "eth1"
	assignIPsHostIPResources = append(assignIPsHostIPResources, oneHostIPResource)

	assignIPsHost, err := host.Build("", "65535", assignIPsPool.ID, []string{}...)
	if err != nil {
		t.Fatalf("Error creating host: %v", err)
	}
	assignIPsHost.ID = HOSTID
	assignIPsHost.IPs = assignIPsHostIPResources
	err = dt.Facade.AddHost(dt.CTX, assignIPsHost)
	if err != nil {
		t.Fatalf("Failure creating resource host %-v with error: %s", assignIPsHost, err)
	}

	testService := service.Service{
		ID:           "assignIPsServiceID",
		Name:         "testsvc",
		Launch:       "auto",
		PoolID:       assignIPsPool.ID,
		DeploymentID: "deployment_id",
		Endpoints: []service.ServiceEndpoint{
			service.ServiceEndpoint{
				EndpointDefinition: servicedefinition.EndpointDefinition{
					Name:        "AssignIPsEndpointName",
					Protocol:    "tcp",
					PortNumber:  8081,
					Application: "websvc",
					Purpose:     "import",
					AddressConfig: servicedefinition.AddressResourceConfig{
						Port:     8081,
						Protocol: commons.TCP,
					},
				},
			},
		},
	}

	err = dt.Dao.AddService(testService, &id)
	if err != nil {
		t.Fatalf("Failure creating service %-v with error: %s", testService, err)
	}
	assignmentRequest := dao.AssignmentRequest{testService.ID, "", true}
	err = dt.Dao.AssignIPs(assignmentRequest, nil)
	if err != nil {
		t.Errorf("AssignIPs failed: %v", err)
	}

	assignments := []addressassignment.AddressAssignment{}
	err = dt.Dao.GetServiceAddressAssignments(testService.ID, &assignments)
	if err != nil {
		t.Error("GetServiceAddressAssignments failed: %v", err)
	}
	if len(assignments) != 1 {
		t.Error("Expected 1 AddressAssignment but found ", len(assignments))
	}
}
Exemple #12
0
func (ft *FacadeTest) Test_InvalidVirtualIPs(t *C) {
	fmt.Println(" ##### Test_InvalidVirtualIPs")
	myPoolID := "Test_InvalidVirtualIPs"
	assignIPsPool := pool.New(myPoolID)
	err := ft.Facade.AddResourcePool(ft.CTX, assignIPsPool)
	defer func() {
		ft.Facade.RemoveResourcePool(ft.CTX, assignIPsPool.ID)
	}()

	if err != nil {
		t.Errorf("Failure creating resource pool %-v with error: %s", assignIPsPool, err)
		t.Fail()
	}

	hostID := "deadb22f"
	ipAddress1 := "192.168.100.10"

	assignIPsHostIPResources := []host.HostIPResource{}
	oneHostIPResource := host.HostIPResource{}
	oneHostIPResource.HostID = hostID
	oneHostIPResource.IPAddress = ipAddress1
	myInterfaceName := "eth0"
	oneHostIPResource.InterfaceName = myInterfaceName
	assignIPsHostIPResources = append(assignIPsHostIPResources, oneHostIPResource)

	assignIPsHost, err := host.Build("", "65535", assignIPsPool.ID, []string{}...)
	if err != nil {
		t.Fatalf("could not build host for test: %v", err)
	}
	assignIPsHost.ID = hostID
	assignIPsHost.PoolID = assignIPsPool.ID
	assignIPsHost.IPs = assignIPsHostIPResources
	err = ft.Facade.AddHost(ft.CTX, assignIPsHost)
	if err != nil {
		t.Fatalf("failed to add host: %v", err)
	}
	defer func() {
		ft.Facade.RemoveHost(ft.CTX, assignIPsHost.ID)
	}()
	time.Sleep(2 * time.Second)

	invalidIPAddresses := []string{"192.F.100.20", "192.168.100.3*", "192.168.100", "192..168.100.50"}
	// try adding invalid IPs
	if err := ft.Facade.AddVirtualIP(ft.CTX, pool.VirtualIP{PoolID: myPoolID, IP: invalidIPAddresses[0], Netmask: "255.255.255.0", BindInterface: myInterfaceName}); err == nil {
		t.Errorf("AddVirtualIP should have failed on: %v", invalidIPAddresses[0])
	}
	if err := ft.Facade.AddVirtualIP(ft.CTX, pool.VirtualIP{PoolID: myPoolID, IP: invalidIPAddresses[1], Netmask: "255.255.255.0", BindInterface: myInterfaceName}); err == nil {
		t.Errorf("AddVirtualIP should have failed on: %v", invalidIPAddresses[1])
	}
	if err := ft.Facade.AddVirtualIP(ft.CTX, pool.VirtualIP{PoolID: myPoolID, IP: invalidIPAddresses[2], Netmask: "255.255.255.0", BindInterface: myInterfaceName}); err == nil {
		t.Errorf("AddVirtualIP should have failed on: %v", invalidIPAddresses[2])
	}
	if err := ft.Facade.AddVirtualIP(ft.CTX, pool.VirtualIP{PoolID: myPoolID, IP: invalidIPAddresses[3], Netmask: "255.255.255.0", BindInterface: myInterfaceName}); err == nil {
		t.Errorf("AddVirtualIP should have failed on: %v", invalidIPAddresses[3])
	}

	validIPAddress := "192.168.100.20"
	invalidPoolID := "invalidPoolID"
	// try adding a with an invalid poolID
	if err := ft.Facade.AddVirtualIP(ft.CTX, pool.VirtualIP{PoolID: invalidPoolID, IP: validIPAddress, Netmask: "255.255.255.0", BindInterface: myInterfaceName}); err == nil {
		t.Errorf("AddVirtualIP should have failed on invalid pool ID: %v", invalidPoolID)
	}

	// add an already present static IP
	if err := ft.Facade.AddVirtualIP(ft.CTX, pool.VirtualIP{PoolID: myPoolID, IP: ipAddress1, Netmask: "255.255.255.0", BindInterface: myInterfaceName}); err == nil {
		t.Errorf("Added an IP that was already (%v) there... should have failed.", validIPAddress)
	}

	// add a virtual IP
	if err := ft.Facade.AddVirtualIP(ft.CTX, pool.VirtualIP{PoolID: myPoolID, IP: validIPAddress, Netmask: "255.255.255.0", BindInterface: myInterfaceName}); err != nil {
		t.Errorf("AddVirtualIP failed: %v", err)
	}

	// try to add an already added virtual IP
	if err := ft.Facade.AddVirtualIP(ft.CTX, pool.VirtualIP{PoolID: myPoolID, IP: validIPAddress, Netmask: "255.255.255.0", BindInterface: myInterfaceName}); err == nil {
		t.Errorf("Added an IP that was already (%v) there... should have failed.", validIPAddress)
	}

	notAddedIPAddress := "192.168.100.30"
	// try removing a virtual IP that has not been added
	if err := ft.Facade.RemoveVirtualIP(ft.CTX, pool.VirtualIP{PoolID: myPoolID, IP: notAddedIPAddress, Netmask: "255.255.255.0", BindInterface: myInterfaceName}); err == nil {
		t.Errorf("Tried to remove a virtual IP that was NOT in the pool: %v", notAddedIPAddress)
	}

	// try removing a static IP
	if err := ft.Facade.RemoveVirtualIP(ft.CTX, pool.VirtualIP{PoolID: myPoolID, IP: ipAddress1, Netmask: "255.255.255.0", BindInterface: myInterfaceName}); err == nil {
		t.Errorf("Tried to remove a virtual IP that was NOT in the pool: %v", notAddedIPAddress)
	}

	// try removing with an invalid pool ID
	if err := ft.Facade.RemoveVirtualIP(ft.CTX, pool.VirtualIP{PoolID: invalidPoolID, IP: validIPAddress, Netmask: "255.255.255.0", BindInterface: myInterfaceName}); err == nil {
		t.Errorf("Invalid Pool ID (%v) should have failed.", invalidPoolID)
	}
}
Exemple #13
0
func (ft *FacadeTest) Test_VirtualIPs(t *C) {
	fmt.Println(" ##### Test_VirtualIPs")
	myPoolID := "Test_VirtualIPs"
	assignIPsPool := pool.New(myPoolID)
	err := ft.Facade.AddResourcePool(ft.CTX, assignIPsPool)
	defer func() {
		ft.Facade.RemoveResourcePool(ft.CTX, assignIPsPool.ID)
	}()

	if err != nil {
		t.Errorf("Failure creating resource pool %-v with error: %s", assignIPsPool, err)
		t.Fail()
	}

	hostID := "deadb22f"
	ipAddress1 := "192.168.100.10"

	assignIPsHostIPResources := []host.HostIPResource{}
	oneHostIPResource := host.HostIPResource{}
	oneHostIPResource.HostID = hostID
	oneHostIPResource.IPAddress = ipAddress1
	myInterfaceName := "eth0"
	oneHostIPResource.InterfaceName = myInterfaceName
	assignIPsHostIPResources = append(assignIPsHostIPResources, oneHostIPResource)

	assignIPsHost, err := host.Build("", "65535", assignIPsPool.ID, []string{}...)
	if err != nil {
		t.Fatalf("could not build host for test: %v", err)
	}
	assignIPsHost.ID = hostID
	assignIPsHost.PoolID = assignIPsPool.ID
	assignIPsHost.IPs = assignIPsHostIPResources
	err = ft.Facade.AddHost(ft.CTX, assignIPsHost)
	if err != nil {
		t.Fatalf("failed to add host: %v", err)
	}
	defer func() {
		ft.Facade.RemoveHost(ft.CTX, assignIPsHost.ID)
	}()
	time.Sleep(2 * time.Second)
	someIPAddresses := []string{"192.168.100.20", "192.168.100.30", "192.168.100.40", "192.168.100.50"}
	if err := ft.Facade.AddVirtualIP(ft.CTX, pool.VirtualIP{PoolID: myPoolID, IP: someIPAddresses[0], Netmask: "255.255.255.0", BindInterface: myInterfaceName}); err != nil {
		t.Errorf("AddVirtualIP failed: %v", err)
	}
	if err := ft.Facade.AddVirtualIP(ft.CTX, pool.VirtualIP{PoolID: myPoolID, IP: someIPAddresses[1], Netmask: "255.255.255.0", BindInterface: myInterfaceName}); err != nil {
		t.Errorf("AddVirtualIP failed: %v", err)
	}
	if err := ft.Facade.AddVirtualIP(ft.CTX, pool.VirtualIP{PoolID: myPoolID, IP: someIPAddresses[2], Netmask: "255.255.255.0", BindInterface: myInterfaceName}); err != nil {
		t.Errorf("AddVirtualIP failed: %v", err)
	}
	if err := ft.Facade.AddVirtualIP(ft.CTX, pool.VirtualIP{PoolID: myPoolID, IP: someIPAddresses[3], Netmask: "255.255.255.0", BindInterface: myInterfaceName}); err != nil {
		t.Errorf("AddVirtualIP failed: %v", err)
	}
	IPs, err := ft.Facade.GetPoolIPs(ft.CTX, assignIPsPool.ID)
	if err != nil {
		t.Errorf("GetPoolIps failed: %v", err)
	}
	if len(IPs.VirtualIPs) != 4 {
		t.Fatalf("Expected 4 addresses, found %v", len(IPs.VirtualIPs))
	}

	for _, vip := range IPs.VirtualIPs {
		found := false
		for _, anIPAddress := range someIPAddresses {
			if anIPAddress == vip.IP {
				fmt.Println(" ##### Found: ", vip.IP)
				found = true
				break
			}
		}
		if !found {
			t.Errorf("Did not find %v in the model...", vip.IP)
		}
	}

	if err := ft.Facade.RemoveVirtualIP(ft.CTX, pool.VirtualIP{PoolID: myPoolID, IP: someIPAddresses[0], Netmask: "255.255.255.0", BindInterface: myInterfaceName}); err != nil {
		t.Errorf("RemoveVirtualIP failed: %v", err)
	}
	if err := ft.Facade.RemoveVirtualIP(ft.CTX, pool.VirtualIP{PoolID: myPoolID, IP: someIPAddresses[1], Netmask: "255.255.255.0", BindInterface: myInterfaceName}); err != nil {
		t.Errorf("RemoveVirtualIP failed: %v", err)
	}
	if err := ft.Facade.RemoveVirtualIP(ft.CTX, pool.VirtualIP{PoolID: myPoolID, IP: someIPAddresses[3], Netmask: "255.255.255.0", BindInterface: myInterfaceName}); err != nil {
		t.Errorf("RemoveVirtualIP failed: %v", err)
	}
	IPs, err = ft.Facade.GetPoolIPs(ft.CTX, assignIPsPool.ID)
	if err != nil {
		t.Errorf("GetPoolIps failed: %v", err)
	}
	fmt.Println(" ##### IPs.VirtualIPs: ", IPs.VirtualIPs)
	if len(IPs.VirtualIPs) != 1 {
		t.Fatalf("Expected 1 address, found %v", len(IPs.VirtualIPs))
	}

	if IPs.VirtualIPs[0].IP != someIPAddresses[2] {
		t.Fatalf("Expected %v but found %v", someIPAddresses[2], IPs.VirtualIPs[0].IP)
	}

	if err := ft.Facade.RemoveVirtualIP(ft.CTX, pool.VirtualIP{PoolID: myPoolID, IP: someIPAddresses[2], Netmask: "255.255.255.0", BindInterface: myInterfaceName}); err != nil {
		t.Errorf("RemoveVirtualIP failed: %v", err)
	}
}