Skip to content

Commit

Permalink
Merge pull request #196 from ehazlett/hrm-fix
Browse files Browse the repository at this point in the history
Fix HRM migration bug
  • Loading branch information
euanh authored Oct 2, 2018
2 parents 657936f + 72eff15 commit e66097d
Show file tree
Hide file tree
Showing 16 changed files with 66 additions and 44 deletions.
3 changes: 2 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ TEST_INTERLOCK_IMAGE?=
TEST_INTEGRATION_SERVICE_WAIT_TIMEOUT?=
TEST_INTEGRATION_SERVICE_TEST_TIMEOUT?=
TEST_INTEGRATION_EXTENSION?=
TEST_INTEGRATION_TIMEOUT?=25m
TEST_INTEGRATION_TIMEOUT?=20m
TEST_ARGS?=

all: image $(EXTENSIONS)

Expand Down
4 changes: 2 additions & 2 deletions events/exchange.go
Original file line number Diff line number Diff line change
Expand Up @@ -175,11 +175,11 @@ func validateTopic(topic string) error {
}

if topic[0] != '/' {
return errors.Wrapf(errInvalidArgument, "must start with '/'", topic)
return errors.Wrapf(errInvalidArgument, "must start with '/': %s", topic)
}

if len(topic) == 1 {
return errors.Wrapf(errInvalidArgument, "must have at least one component", topic)
return errors.Wrapf(errInvalidArgument, "must have at least one component: %s", topic)
}

return nil
Expand Down
3 changes: 0 additions & 3 deletions server/backend.go
Original file line number Diff line number Diff line change
Expand Up @@ -359,8 +359,5 @@ func isInterlockService(spec swarm.ServiceSpec) bool {
if utils.DefaultBackend(spec) {
return true
}
if utils.IsHRMService(spec) {
return true
}
return hostLabel && portLabel
}
2 changes: 1 addition & 1 deletion server/nodes.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ func (s *Server) getNodeAddresses() (map[string]string, error) {
"node": node.ID,
"hostname": node.Description.Hostname,
"addr": addr,
}).Error("unable to find valid node IP: %s", err)
}).Errorf("unable to find valid node IP: %s", err)
continue
}

Expand Down
3 changes: 2 additions & 1 deletion server/poll.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"github.com/docker/docker/api/types"
"github.com/docker/docker/api/types/filters"
"github.com/docker/docker/api/types/swarm"
"github.com/docker/interlock/server/utils"
"github.com/pkg/errors"
"github.com/sirupsen/logrus"
"golang.org/x/net/context"
Expand Down Expand Up @@ -75,7 +76,7 @@ func (s *Server) poll() error {
continue
}

if !isInterlockService(s.Spec) {
if !isInterlockService(s.Spec) && !utils.IsHRMService(s.Spec) {
logrus.WithFields(logrus.Fields{
"service": s.Spec.Name,
"task": t.ID,
Expand Down
4 changes: 3 additions & 1 deletion test/integration/standard/context_root.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,11 @@ import (
func testCreateAppServiceContextRoot(t *testing.T) {
appHost := "demo-context-root.test"
contextRoot := "/app"
netName := "test-net-context-root"
createNet(netName, t)
appServiceID, err := createService(
"--label", "app=demo-test",
"--network", testNetName,
"--network", netName,
"--label", "com.docker.lb.hosts="+appHost,
"--label", "com.docker.lb.port=8080",
"--label", "com.docker.lb.context_root="+contextRoot,
Expand Down
4 changes: 3 additions & 1 deletion test/integration/standard/headers.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,11 @@ import (

func testCreateAppHideInfoHeaders(t *testing.T) {
appHost := "demo-hideinfoheaders.test"
netName := "test-net-headers"
createNet(netName, t)
appServiceID, err := createService(
"--label", "app=demo-hideinfoheaders",
"--network", testNetName,
"--network", netName,
"--label", "com.docker.lb.hosts="+appHost,
"--label", "com.docker.lb.port=8080",
testAppImage)
Expand Down
34 changes: 26 additions & 8 deletions test/integration/standard/hrm.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,11 @@ import (

func testCreateAppServiceHRMSimple(t *testing.T) {
appHost := "demo-hrm-simple.test"
netName := "test-net-hrm-simple"
createNet(netName, t)
appServiceID, err := createService(
"--label", "app=demo-hrm-simple",
"--network", testNetName,
"--network", netName,
"--label", fmt.Sprintf("com.docker.ucp.mesh.http.80-1=external_route=http://%s,internal_port=8080", appHost),
"--name=hrm-simple", testAppImage)
if err != nil {
Expand Down Expand Up @@ -114,9 +116,11 @@ func testCreateAppServiceHRMWithInterlockPortLabel(t *testing.T) {

func testCreateAppServiceHRMStickySessions(t *testing.T) {
appHost := "demo-hrm-sticky.test"
netName := "test-net-hrm-sticky"
createNet(netName, t)
appServiceID, err := createService(
"--label", "app=demo-hrm-sticky",
"--network", testNetName,
"--network", netName,
"--label", fmt.Sprintf("com.docker.ucp.mesh.http.80-1=external_route=http://%s,internal_port=8080,sticky_sessions=true", appHost),
"--name=hrm-sticky-sessions",
testAppImage)
Expand Down Expand Up @@ -167,10 +171,12 @@ func testCreateAppServiceHRMStickySessions(t *testing.T) {

func testCreateAppServiceHRMInterlockStickySessionsLabel(t *testing.T) {
appHost := "demo-hrm-interlock-sticky.test"
netName := "test-net-hrm-sticky-labels"
createNet(netName, t)
appServiceID, err := createService(
"--replicas=5",
"--label", "app=demo-hrm-sticky",
"--network", testNetName,
"--network", netName,
"--detach=false",
"--label", fmt.Sprintf("com.docker.ucp.mesh.http.80-1=external_route=http://%s,internal_port=8080,sticky_sessions=session", appHost),
"--label", interlock.InterlockStickySessionCookieLabel+"=foo",
Expand Down Expand Up @@ -230,9 +236,11 @@ func testCreateAppServiceHRMInterlockStickySessionsLabel(t *testing.T) {
func testCreateAppServiceHRMRedirects(t *testing.T) {
appHost := "demo-hrm-redirect.test"
target := "http://demo.test"
netName := "test-net-hrm-redirects"
createNet(netName, t)
appServiceID, err := createService(
"--label", "app=demo-test",
"--network", testNetName,
"--network", netName,
"--label", fmt.Sprintf("com.docker.ucp.mesh.http.80-1=external_route=http://%s,internal_port=8080,redirect=%s", appHost, target),
"--name=hrm-redirect",
testAppImage)
Expand Down Expand Up @@ -268,9 +276,11 @@ func testCreateAppServiceHRMRedirects(t *testing.T) {
func testCreateAppServiceHRMInterlockRedirectsLabel(t *testing.T) {
appHost := "demo-hrm-interlock-redirect.test"
target := "http://demo.test"
netName := "test-net-hrm-redirects-label"
createNet(netName, t)
appServiceID, err := createService(
"--label", "app=demo-test",
"--network", testNetName,
"--network", netName,
"--label", fmt.Sprintf("com.docker.ucp.mesh.http.80-1=external_route=http://%s,internal_port=8080,redirect=%s", appHost, target),
"--label", interlock.InterlockRedirectsLabel+"=http://foo.example.com",
"--name=hrm-redirects-label",
Expand All @@ -285,8 +295,10 @@ func testCreateAppServiceHRMInterlockRedirectsLabel(t *testing.T) {
for {
resp, err := curl("-sSIL", "http://"+appHost)
if err != nil {
t.Log(err)
continue
}
t.Log(resp)

redirect := common.GetHeaderValue(resp, "location")
if strings.Contains(redirect, target) {
Expand All @@ -305,9 +317,11 @@ func testCreateAppServiceHRMInterlockRedirectsLabel(t *testing.T) {

func testCreateAppServiceHRMContextRoot(t *testing.T) {
appHost := "demo-hrm-simple.test/app"
netName := "test-net-hrm-context-root"
createNet(netName, t)
appServiceID, err := createService(
"--label", "app=demo-hrm-simple",
"--network", testNetName,
"--network", netName,
"--label", fmt.Sprintf("com.docker.ucp.mesh.http.80-1=external_route=http://%s,internal_port=8080", appHost),
"--name=hrm-context-root",
testAppImage)
Expand Down Expand Up @@ -337,8 +351,10 @@ func testCreateAppServiceHRMContextRoot(t *testing.T) {

func testCreateAppServiceHRMInterlockContextRootLabel(t *testing.T) {
appHost := "demo-hrm-interlock-contextroot.test/app"
netName := "test-net-hrm-context-root-label"
createNet(netName, t)
appServiceID, err := createService(
"--network", testNetName,
"--network", netName,
"--label", fmt.Sprintf("com.docker.ucp.mesh.http.80-1=external_route=http://%s,internal_port=8080", appHost),
"--label", interlock.InterlockContextRootLabel+"=/foo",
"--name=hrm-context-root-label",
Expand Down Expand Up @@ -368,8 +384,10 @@ func testCreateAppServiceHRMInterlockContextRootLabel(t *testing.T) {
}

func testCreateAppServiceHRMDefaultBackend(t *testing.T) {
netName := "test-net-hrm-default-backend"
createNet(netName, t)
appServiceID, err := createService(
"--network", testNetName,
"--network", netName,
"--label", fmt.Sprintf("com.docker.ucp.mesh.http.80-1=external_route=http://,internal_port=8080"),
"--name=hrm-default-backend",
testAppImage)
Expand Down
4 changes: 1 addition & 3 deletions test/integration/standard/multi_app_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,10 @@ import (
)

func testCreateMultipleAppNetwork(t *testing.T) {

netNameOne := "demo-test-one"
netNameTwo := "demo-test-two"
createNet(netNameOne, t)
createNet(netNameTwo, t)

appServiceIDOne, err := createService(
"--network",
netNameOne,
Expand Down Expand Up @@ -92,5 +90,5 @@ func testCreateMultipleAppNetwork(t *testing.T) {
err = fmt.Errorf("Did not find %s %s on Interlock Proxy. This network should be used by proxy %s", netIDTwo, netNameTwo, proxyNetworks)
}

t.Log("Multiple service and setwork creation/validation was successful")
t.Log("Multiple service and network creation/validation was successful")
}
4 changes: 3 additions & 1 deletion test/integration/standard/redirects.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,11 @@ import (
func testCreateAppServiceRedirects(t *testing.T) {
appHost := "demo-redirect.test"
target := "http://demo.test"
netName := "test-net-redirects"
createNet(netName, t)
appServiceID, err := createService(
"--label", "app=demo-test",
"--network", testNetName,
"--network", netName,
"--label", "com.docker.lb.hosts="+appHost,
"--label", "com.docker.lb.port=8080",
"--label", "com.docker.lb.redirects=http://"+appHost+","+target,
Expand Down
4 changes: 3 additions & 1 deletion test/integration/standard/replicas.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,12 @@ import (

func testCreateAppServiceReplicas(t *testing.T) {
appHost := "demo-replicas.test"
netName := "test-net-replicas"
createNet(netName, t)
appServiceID, err := createService(
"--detach=false",
"--label", "app=demo-test",
"--network", testNetName,
"--network", netName,
"--label", "com.docker.lb.hosts="+appHost,
"--label", "com.docker.lb.port=8080",
testAppImage)
Expand Down
4 changes: 3 additions & 1 deletion test/integration/standard/ssl.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ func testCreateAppServiceSSLPassthrough(t *testing.T) {
appHost := "demo-passthrough.test"
certName := "demo-passthrough.test.cert"
keyName := "demo-passthrough.test.key"
netName := "test-net-ssl-passthrough"
createNet(netName, t)

// create secrets
certDestPath := filepath.Join("/tmp", "cert.pem")
Expand Down Expand Up @@ -61,7 +63,7 @@ func testCreateAppServiceSSLPassthrough(t *testing.T) {
appServiceID, err := createService(
"--detach=false",
"--label", "app"+app,
"--network", testNetName,
"--network", netName,
"--secret", fmt.Sprintf("source=%s,target=cert.pem", certName),
"--secret", fmt.Sprintf("source=%s,target=key.pem", keyName),
"--label", "com.docker.lb.hosts="+appHost,
Expand Down
4 changes: 3 additions & 1 deletion test/integration/standard/standard_haproxy_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ func testCreateAppServiceHAProxySSLTermination(t *testing.T) {
app := "demo-ssl"
appHost := "demo-ssl.test"
certName := "demo-ssl.test.combined.cert"
netName := "test-net-ssl-haproxy"
createNet(netName, t)

if testCluster.TestExtensionName() != "haproxy" {
t.Skip("skipping haproxy test")
Expand Down Expand Up @@ -47,7 +49,7 @@ func testCreateAppServiceHAProxySSLTermination(t *testing.T) {
appServiceID, err := createService(
"--detach=false",
"--label", "app"+app,
"--network", testNetName,
"--network", netName,
"--label", "com.docker.lb.hosts="+appHost,
"--label", "com.docker.lb.port=8080",
"--label", "com.docker.lb.ssl_cert="+certName,
Expand Down
4 changes: 3 additions & 1 deletion test/integration/standard/standard_nginx_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ func testCreateAppServiceNginxSSLTermination(t *testing.T) {
appHost := "demo-ssl.test"
certName := "demo-ssl.test.cert"
keyName := "demo-ssl.test.key"
netName := "test-net-ssl-nginx"
createNet(netName, t)

if testCluster.TestExtensionName() != "nginx" {
t.Skip("skipping nginx test")
Expand Down Expand Up @@ -64,7 +66,7 @@ func testCreateAppServiceNginxSSLTermination(t *testing.T) {
appServiceID, err := createService(
"--detach=false",
"--label", "app"+app,
"--network", testNetName,
"--network", netName,
"--label", "com.docker.lb.hosts="+appHost,
"--label", "com.docker.lb.port=8080",
"--label", "com.docker.lb.ssl_cert="+certName,
Expand Down
21 changes: 5 additions & 16 deletions test/integration/standard/standard_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -243,23 +243,12 @@ func curl(args ...string) (string, error) {

command = append(command, args...)

successChan := make(chan string, 1)
go func() {
for {
resp, err := commonManager.WaitForExec(command, serviceWaitTimeout)
if err != nil {
continue
}

successChan <- resp
}
}()
select {
case resp := <-successChan:
return resp, nil
case <-time.After(serviceTestTimeout):
return "", errors.New("curl timed out: " + strings.Join(args, " "))
resp, err := commonManager.WaitForExec(command, serviceWaitTimeout)
if err != nil {
return resp, err
}

return resp, nil
}

func createService(args ...string) (string, error) {
Expand Down
8 changes: 6 additions & 2 deletions test/integration/standard/sticky_sessions.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,11 @@ import (

func testCreateAppServiceStickySessions(t *testing.T) {
appHost := "demo-session.test"
netName := "test-net-sticky-sessions"
createNet(netName, t)
appServiceID, err := createService(
"--label", "app=demo-sticky",
"--network", testNetName,
"--network", netName,
"--label", "com.docker.lb.hosts="+appHost,
"--label", "com.docker.lb.port=8080",
"--label", "com.docker.lb.sticky_session_cookie=session",
Expand Down Expand Up @@ -60,9 +62,11 @@ func testCreateAppServiceStickySessions(t *testing.T) {

func testCreateAppServiceIPHash(t *testing.T) {
appHost := "demo-ip-hash.test"
netName := "test-net-ip-hash"
createNet(netName, t)
appServiceID, err := createService(
"--label", "app=demo-ip-hash",
"--network", testNetName,
"--network", netName,
"--label", "com.docker.lb.hosts="+appHost,
"--label", "com.docker.lb.port=8080",
"--label", "com.docker.lb.ip_hash=true",
Expand Down

0 comments on commit e66097d

Please sign in to comment.