示例#1
0
func (appRunner *appRunner) updateLrpRoutes(name string, routes RouteOverrides) error {
	appRoutes := route_helpers.AppRoutes{}

	routeMap := make(map[uint16][]string)
	for _, override := range routes {
		routeMap[override.Port] = append(routeMap[override.Port], appRunner.appendDomain(override.HostnamePrefix))
	}
	for port, hostnames := range routeMap {
		appRoutes = append(appRoutes, route_helpers.AppRoute{
			Hostnames: hostnames,
			Port:      port,
		})
	}

	err := appRunner.receptorClient.UpdateDesiredLRP(
		name,
		receptor.DesiredLRPUpdateRequest{
			Routes: appRoutes.RoutingInfo(),
		},
	)

	return err
}
import (
	"encoding/json"

	. "github.com/onsi/ginkgo"
	. "github.com/onsi/gomega"

	"github.com/cloudfoundry-incubator/ltc/route_helpers"
	. "github.com/cloudfoundry-incubator/ltc/test_helpers/matchers"
	"github.com/cloudfoundry-incubator/receptor"
)

var _ = Describe("RoutingInfoHelpers", func() {
	var (
		appRoute1 route_helpers.AppRoute
		appRoute2 route_helpers.AppRoute
		appRoute3 route_helpers.AppRoute

		appRoutes route_helpers.AppRoutes
	)

	BeforeEach(func() {
		appRoute1 = route_helpers.AppRoute{
			Hostnames: []string{"foo1.example.com", "bar1.examaple.com"},
			Port:      11111,
		}
		appRoute2 = route_helpers.AppRoute{
			Hostnames: []string{"foo2.example.com", "bar2.examaple.com"},
			Port:      22222,
		}
		appRoute3 = route_helpers.AppRoute{
			Hostnames: []string{"foo3.example.com", "bar3.examaple.com"},