Repository: allegro/marathon-consul
Pull request #129 (2016-10-10 14:34:59)

Simplify stopping and renaming applications
This PR removes handling of StopApplication and RestartApplication events, which caused problems in multi-registration scenario and required some rework. It seems we don't need them anymore though, TASK_KILLED events that we handle seem to cover all the cases.

coveralls: 
[![Coverage Status](https://coveralls.io/builds/8263692/badge)](https://coveralls.io/builds/8263692)

Coverage decreased (-1.9%) to 77.327% when pulling **7c00c46f3767979c878a23ff95c70720c052abdd on simplify_stopping_and_renaming_applications** into **01b2f7c237022aa787026f609cf8623d96521021 on develop**.

coveralls: 
[![Coverage Status](https://coveralls.io/builds/8265313/badge)](https://coveralls.io/builds/8265313)

Coverage decreased (-1.9%) to 77.327% when pulling **de799467b489b9686ebdad6ef7aacdc5662c64ef on simplify_stopping_and_renaming_applications** into **734c9e3742932911c9200cbe247a6acbcebff6a9 on develop**.

pbetkier: Just for the record, the issue is that in multi-registration scenario an application maps to multiple names, so after a rename it's possible that some name from the previous configuration still exists in the new one. If we deregister all services matching names from the just stopped / renamed configuration then in such case we also deregister newly registered services from tasks of the new configuration!

Patch:
diff --git a/apps/app.go b/apps/app.go
index c143fdc..208e183 100644
--- a/apps/app.go
+++ b/apps/app.go
@@ -58,36 +58,6 @@ func (app *App) IsConsulApp() bool {
 	return ok
 }
 
-func (app *App) HasSameConsulNamesAs(other *App) bool {
-	thisNames := app.ConsulNames(".")
-	otherNames := other.ConsulNames(".")
-
-	if len(thisNames) != len(otherNames) {
-		return false
-	}
-
-	for i, name := range thisNames {
-		if name != otherNames[i] {
-			return false
-		}
-	}
-	return true
-}
-
-func (app *App) ConsulNames(separator string) []string {
-	definitions := app.findConsulPortDefinitions()
-
-	if len(definitions) == 0 {
-		return []string{app.labelsToName(app.Labels, separator)}
-	}
-
-	var names []string
-	for _, d := range definitions {
-		names = append(names, app.labelsToName(d.Labels, separator))
-	}
-	return names
-}
-
 func (app *App) labelsToRawName(labels map[string]string) string {
 	if value, ok := labels[MarathonConsulLabel]; ok && !isSpecialConsulNameValue(value) {
 		return value
diff --git a/consul/consul.go b/consul/consul.go
index 7daf44a..53539ad 100644
--- a/consul/consul.go
+++ b/consul/consul.go
@@ -270,10 +270,6 @@ func (c *Consul) deregister(toDeregister *service.Service) error {
 	return err
 }
 
-func (c *Consul) ServiceNames(app *apps.App) []string {
-	return app.ConsulNames(c.config.ConsulNameSeparator)
-}
-
 func (c *Consul) marathonTaskToConsulServices(task *apps.Task, app *apps.App) ([]*consulapi.AgentServiceRegistration, error) {
 	IP, err := utils.HostToIPv4(task.Host)
 	if err != nil {
diff --git a/consul/consul_stub.go b/consul/consul_stub.go
index 2d5dabe..681e0b1 100644
--- a/consul/consul_stub.go
+++ b/consul/consul_stub.go
@@ -125,10 +125,6 @@ func (c *Stub) RegisterOnlyFirstRegistrationIntent(task *apps.Task, app *apps.Ap
 	c.services[service.ServiceId(serviceRegistrations[0].ID)] = serviceRegistrations[0]
 }
 
-func (c *Stub) ServiceNames(app *apps.App) []string {
-	return c.consul.ServiceNames(app)
-}
-
 func (c *Stub) DeregisterByTask(taskID apps.TaskID) error {
 	c.Lock()
 	defer c.Unlock()
diff --git a/events/deployment_info.go b/events/deployment_info.go
deleted file mode 100644
index 351a0ee..0000000
--- a/events/deployment_info.go
+++ /dev/null
@@ -1,190 +0,0 @@
-package events
-
-import (
-	"encoding/json"
-	"strings"
-
-	"github.com/allegro/marathon-consul/apps"
-)
-
-type DeploymentEvent struct {
-	Type        string       `json:"eventType"`
-	Plan        *Plan        `json:"plan"`
-	CurrentStep *CurrentStep `json:"currentStep"`
-}
-
-type Plan struct {
-	Original *Deployments `json:"original"`
-	Target   *Deployments `json:"target"`
-}
-
-type Deployments struct {
-	ID     string         `json:"id"`
-	Apps   []*apps.App    `json:"apps"`
-	Groups []*Deployments `json:"groups"`
-}
-
-type CurrentStep struct {
-	Actions []*Action `json:"actions"`
-}
-
-type Action struct {
-	Type  string     `json:"type"`
-	AppID apps.AppID `json:"app"`
-}
-
-func (d *Deployments) groups() []*Deployments {
-	if d.Groups != nil {
-		return d.Groups
-	}
-	return []*Deployments{}
-}
-
-func (d *Deployments) apps() []*apps.App {
-	if d.Apps != nil {
-		return d.Apps
-	}
-	return []*apps.App{}
-}
-
-func (d *DeploymentEvent) originalDeployments() *Deployments {
-	if d.Plan != nil {
-		if d.Plan.Original != nil {
-			return d.Plan.Original
-		}
-	}
-	return &Deployments{}
-}
-
-func (d *DeploymentEvent) targetDeployments() *Deployments {
-	if d.Plan != nil {
-		if d.Plan.Target != nil {
-			return d.Plan.Target
-		}
-	}
-	return &Deployments{}
-}
-
-func (d *DeploymentEvent) actions() []*Action {
-	if d.CurrentStep != nil {
-		if d.CurrentStep.Actions != nil {
-			return d.CurrentStep.Actions
-		}
-	}
-	return []*Action{}
-}
-
-func (d *DeploymentEvent) StoppedConsulApps() []*apps.App {
-	return d.consulAppsWithActionPerformed(d.originalDeployments(), "StopApplication")
-}
-
-func (d *DeploymentEvent) RestartedConsulApps() []*apps.App {
-	return d.consulAppsWithActionPerformed(d.originalDeployments(), "RestartApplication")
-}
-
-func (d *DeploymentEvent) RenamedConsulApps() []*apps.App {
-	original := d.consulAppsWithActionPerformed(d.originalDeployments(), "RestartApplication")
-	renamedApps := []*apps.App{}
-	if len(original) > 0 {
-
-		target := d.consulAppsWithActionPerformed(d.targetDeployments(), "RestartApplication")
-		originalMap := d.appsMap(original)
-		targetMap := d.appsMap(target)
-		for id, originalApp := range originalMap {
-			targetApp, ok := targetMap[id]
-			if !ok || !originalApp.HasSameConsulNamesAs(targetApp) {
-				renamedApps = append(renamedApps, originalApp)
-			}
-		}
-	}
-	return renamedApps
-}
-
-func (d *DeploymentEvent) appsMap(applications []*apps.App) map[apps.AppID]*apps.App {
-	result := make(map[apps.AppID]*apps.App)
-	for _, app := range applications {
-		result[app.ID] = app
-	}
-	return result
-}
-
-func (d *DeploymentEvent) consulAppsWithActionPerformed(deployments *Deployments, actionType string) []*apps.App {
-	appIds := make(map[apps.AppID]struct{})
-	var exists struct{}
-
-	for _, action := range d.actions() {
-		if action.Type == actionType {
-			appIds[action.AppID] = exists
-		}
-	}
-	return d.filterConsulApps(d.findAppsInDeploymentsGroup(appIds, deployments))
-}
-
-func (d *DeploymentEvent) filterConsulApps(allApps []*apps.App) []*apps.App {
-	filtered := []*apps.App{}
-	for _, app := range allApps {
-		if app.IsConsulApp() {
-			filtered = append(filtered, app)
-		}
-	}
-	return filtered
-}
-
-func (d *DeploymentEvent) findAppsInDeploymentsGroup(appIds map[apps.AppID]struct{}, deployment *Deployments) []*apps.App {
-	foundApps := []*apps.App{}
-	filteredAppIds := deployment.filterCurrentGroupAppIds(appIds)
-	foundInCurrentGroup := d.findAppsInCurrentDeploymentGroupApps(filteredAppIds, deployment)
-	foundApps = append(foundApps, foundInCurrentGroup...)
-	foundInChildGroups := d.findAppsInDeploymentChildGroups(filteredAppIds, deployment)
-	foundApps = append(foundApps, foundInChildGroups...)
-	return foundApps
-}
-
-func (d *DeploymentEvent) findAppsInCurrentDeploymentGroupApps(appIds map[apps.AppID]struct{}, deployment *Deployments) []*apps.App {
-	foundApps := []*apps.App{}
-	searchForCount := len(appIds)
-
-	for _, app := range deployment.apps() {
-		if searchForCount < 1 {
-			break
-		}
-		if _, ok := appIds[app.ID]; ok {
-			foundApps = append(foundApps, app)
-			searchForCount--
-		}
-	}
-	return foundApps
-}
-
-func (d *DeploymentEvent) findAppsInDeploymentChildGroups(appIds map[apps.AppID]struct{}, deployment *Deployments) []*apps.App {
-	foundApps := []*apps.App{}
-	searchForCount := len(appIds)
-
-	for _, group := range deployment.groups() {
-		if searchForCount < 1 {
-			break
-		}
-		foundInChildGroup := d.findAppsInDeploymentsGroup(appIds, group)
-		foundApps = append(foundApps, foundInChildGroup...)
-		searchForCount -= len(foundInChildGroup)
-	}
-	return foundApps
-}
-
-func (d *Deployments) filterCurrentGroupAppIds(appIds map[apps.AppID]struct{}) map[apps.AppID]struct{} {
-	filteredAppIds := make(map[apps.AppID]struct{})
-	var exists struct{}
-
-	for appID := range appIds {
-		if strings.HasPrefix(appID.String(), d.ID) {
-			filteredAppIds[appID] = exists
-		}
-	}
-	return filteredAppIds
-}
-
-func ParseDeploymentEvent(jsonBlob []byte) (*DeploymentEvent, error) {
-	deploymentInfo := &DeploymentEvent{}
-	err := json.Unmarshal(jsonBlob, deploymentInfo)
-	return deploymentInfo, err
-}
diff --git a/events/deployment_info.json b/events/deployment_info.json
deleted file mode 100644
index dff3dbe..0000000
--- a/events/deployment_info.json
+++ /dev/null
@@ -1,78 +0,0 @@
-{
-  "plan": {
-    "id": "25b0ad3d-28b3-4dfb-84a2-5ff19af1c467",
-    "original": {
-      "id": "/",
-      "apps": [{
-        "id": "/internalName",
-        "cmd": "python -m SimpleHTTPServer $PORT0",
-        "args": null,
-        "user": null,
-        "env": {},
-        "instances": 1,
-        "cpus": 0.1,
-        "mem": 16,
-        "disk": 0,
-        "executor": "",
-        "constraints": [],
-        "uris": [],
-        "storeUrls": [],
-        "ports": [10000],
-        "requirePorts": false,
-        "backoffSeconds": 1,
-        "backoffFactor": 1.15,
-        "maxLaunchDelaySeconds": 3600,
-        "container": null,
-        "healthChecks": [{
-          "path": "/",
-          "protocol": "HTTP",
-          "portIndex": 0,
-          "gracePeriodSeconds": 300,
-          "intervalSeconds": 60,
-          "timeoutSeconds": 20,
-          "maxConsecutiveFailures": 3,
-          "ignoreHttp1xx": false
-        }],
-        "dependencies": [],
-        "upgradeStrategy": {
-          "minimumHealthCapacity": 1,
-          "maximumOverCapacity": 1
-        },
-        "labels": {
-          "consul": "consulName"
-        },
-        "acceptedResourceRoles": null,
-        "version": "2016-01-18T12:21:04.494Z",
-        "versionInfo": {
-          "lastScalingAt": "2016-01-18T12:21:04.494Z",
-          "lastConfigChangeAt": "2016-01-18T12:21:04.494Z"
-        }
-      }],
-      "groups": [],
-      "dependencies": [],
-      "version": "2016-01-18T12:21:04.494Z"
-    },
-    "target": {
-      "id": "/",
-      "apps": [],
-      "groups": [],
-      "dependencies": [],
-      "version": "2016-01-18T12:22:07.141Z"
-    },
-    "steps": [{
-      "actions": [{
-        "type": "StopApplication",
-        "app": "/mirek"
-      }]
-    }],
-    "version": "2016-01-18T12:22:07.141Z"
-  },
-  "currentStep": {
-    "actions": [{
-      "type": "StopApplication",
-      "app": "/internalName"
-    }]
-  },
-  "eventType": "deployment_info",
-  "timestamp": "2016-01-18T12:22:07.170Z"
-}
\ No newline at end of file
diff --git a/events/deployment_step_success.json b/events/deployment_step_success.json
deleted file mode 100644
index 637559d..0000000
--- a/events/deployment_step_success.json
+++ /dev/null
@@ -1,238 +0,0 @@
-{
-  "plan": {
-    "id": "5f9e565a-d2f7-418e-bccf-161810de5672",
-    "original": {
-      "id": "/",
-      "apps": [
-        {
-          "id": "/other",
-          "cmd": "python -m SimpleHTTPServer $PORT0",
-          "args": null,
-          "user": null,
-          "env": {},
-          "instances": 2,
-          "cpus": 0.1,
-          "mem": 16,
-          "disk": 0,
-          "executor": "",
-          "constraints": [],
-          "uris": [],
-          "storeUrls": [],
-          "ports": [
-            10000
-          ],
-          "requirePorts": false,
-          "backoffSeconds": 1,
-          "backoffFactor": 1.15,
-          "maxLaunchDelaySeconds": 3600,
-          "container": null,
-          "healthChecks": [
-            {
-              "path": "/",
-              "protocol": "HTTP",
-              "portIndex": 0,
-              "gracePeriodSeconds": 300,
-              "intervalSeconds": 60,
-              "timeoutSeconds": 20,
-              "maxConsecutiveFailures": 3,
-              "ignoreHttp1xx": false
-            }
-          ],
-          "dependencies": [],
-          "upgradeStrategy": {
-            "minimumHealthCapacity": 1,
-            "maximumOverCapacity": 1
-          },
-          "labels": {
-            "consul": "true"
-          },
-          "acceptedResourceRoles": null,
-          "version": "2016-01-19T14:07:00.013Z",
-          "versionInfo": {
-            "lastScalingAt": "2016-01-19T14:07:00.013Z",
-            "lastConfigChangeAt": "2016-01-19T14:07:00.013Z"
-          }
-        },
-        {
-          "id": "/a",
-          "cmd": "python -m SimpleHTTPServer $PORT0",
-          "args": null,
-          "user": null,
-          "env": {},
-          "instances": 1,
-          "cpus": 0.1,
-          "mem": 16,
-          "disk": 0,
-          "executor": "",
-          "constraints": [],
-          "uris": [],
-          "storeUrls": [],
-          "ports": [
-            10001
-          ],
-          "requirePorts": false,
-          "backoffSeconds": 1,
-          "backoffFactor": 1.15,
-          "maxLaunchDelaySeconds": 3600,
-          "container": null,
-          "healthChecks": [
-            {
-              "path": "/",
-              "protocol": "HTTP",
-              "portIndex": 0,
-              "gracePeriodSeconds": 300,
-              "intervalSeconds": 60,
-              "timeoutSeconds": 20,
-              "maxConsecutiveFailures": 3,
-              "ignoreHttp1xx": false
-            }
-          ],
-          "dependencies": [],
-          "upgradeStrategy": {
-            "minimumHealthCapacity": 1,
-            "maximumOverCapacity": 1
-          },
-          "labels": {
-            "consul": "b"
-          },
-          "acceptedResourceRoles": null,
-          "version": "2016-01-19T14:32:43.064Z",
-          "versionInfo": {
-            "lastScalingAt": "2016-01-19T14:32:43.064Z",
-            "lastConfigChangeAt": "2016-01-19T14:32:43.064Z"
-          }
-        }
-      ],
-      "groups": [],
-      "dependencies": [],
-      "version": "2016-01-19T14:32:43.064Z"
-    },
-    "target": {
-      "id": "/",
-      "apps": [
-        {
-          "id": "/other",
-          "cmd": "python -m SimpleHTTPServer $PORT0",
-          "args": null,
-          "user": null,
-          "env": {},
-          "instances": 2,
-          "cpus": 0.1,
-          "mem": 16,
-          "disk": 0,
-          "executor": "",
-          "constraints": [],
-          "uris": [],
-          "storeUrls": [],
-          "ports": [
-            10000
-          ],
-          "requirePorts": false,
-          "backoffSeconds": 1,
-          "backoffFactor": 1.15,
-          "maxLaunchDelaySeconds": 3600,
-          "container": null,
-          "healthChecks": [
-            {
-              "path": "/",
-              "protocol": "HTTP",
-              "portIndex": 0,
-              "gracePeriodSeconds": 300,
-              "intervalSeconds": 60,
-              "timeoutSeconds": 20,
-              "maxConsecutiveFailures": 3,
-              "ignoreHttp1xx": false
-            }
-          ],
-          "dependencies": [],
-          "upgradeStrategy": {
-            "minimumHealthCapacity": 1,
-            "maximumOverCapacity": 1
-          },
-          "labels": {
-            "consul": "true"
-          },
-          "acceptedResourceRoles": null,
-          "version": "2016-01-19T14:07:00.013Z",
-          "versionInfo": {
-            "lastScalingAt": "2016-01-19T14:07:00.013Z",
-            "lastConfigChangeAt": "2016-01-19T14:07:00.013Z"
-          }
-        },
-        {
-          "id": "/a",
-          "cmd": "python -m SimpleHTTPServer $PORT0",
-          "args": null,
-          "user": null,
-          "env": {},
-          "instances": 1,
-          "cpus": 0.1,
-          "mem": 16,
-          "disk": 0,
-          "executor": "",
-          "constraints": [],
-          "uris": [],
-          "storeUrls": [],
-          "ports": [
-            10001
-          ],
-          "requirePorts": false,
-          "backoffSeconds": 1,
-          "backoffFactor": 1.15,
-          "maxLaunchDelaySeconds": 3600,
-          "container": null,
-          "healthChecks": [
-            {
-              "path": "/",
-              "protocol": "HTTP",
-              "portIndex": 0,
-              "gracePeriodSeconds": 300,
-              "intervalSeconds": 60,
-              "timeoutSeconds": 20,
-              "maxConsecutiveFailures": 3,
-              "ignoreHttp1xx": false
-            }
-          ],
-          "dependencies": [],
-          "upgradeStrategy": {
-            "minimumHealthCapacity": 1,
-            "maximumOverCapacity": 1
-          },
-          "labels": {
-            "consul": "c"
-          },
-          "acceptedResourceRoles": null,
-          "version": "2016-01-20T10:12:08.248Z",
-          "versionInfo": {
-            "lastScalingAt": "2016-01-20T10:12:08.248Z",
-            "lastConfigChangeAt": "2016-01-20T10:12:08.248Z"
-          }
-        }
-      ],
-      "groups": [],
-      "dependencies": [],
-      "version": "2016-01-20T10:12:08.248Z"
-    },
-    "steps": [
-      {
-        "actions": [
-          {
-            "type": "RestartApplication",
-            "app": "/a"
-          }
-        ]
-      }
-    ],
-    "version": "2016-01-20T10:12:08.248Z"
-  },
-  "currentStep": {
-    "actions": [
-      {
-        "type": "RestartApplication",
-        "app": "/a"
-      }
-    ]
-  },
-  "eventType": "deployment_step_success",
-  "timestamp": "2016-01-20T10:13:08.412Z"
-}
diff --git a/events/deployment_step_success_with_groups.json b/events/deployment_step_success_with_groups.json
deleted file mode 100644
index f7fd631..0000000
--- a/events/deployment_step_success_with_groups.json
+++ /dev/null
@@ -1,148 +0,0 @@
-{
-  "plan": {
-    "id": "eaeaade6-f485-4271-9058-913a885efa27",
-    "original": {
-      "id": "/",
-      "apps": [],
-      "groups": [{
-        "id": "/com.example",
-        "apps": [],
-        "groups": [{
-          "id": "/com.example/things",
-          "apps": [{
-            "id": "/com.example/things/something",
-            "cmd": "python -m SimpleHTTPServer $PORT0",
-            "args": null,
-            "user": null,
-            "env": {},
-            "instances": 1,
-            "cpus": 0.1,
-            "mem": 16,
-            "disk": 0,
-            "executor": "",
-            "constraints": [],
-            "uris": [],
-            "storeUrls": [],
-            "ports": [10000],
-            "requirePorts": false,
-            "backoffSeconds": 1,
-            "backoffFactor": 1.15,
-            "maxLaunchDelaySeconds": 3600,
-            "container": null,
-            "healthChecks": [{
-              "path": "/",
-              "protocol": "HTTP",
-              "portIndex": 0,
-              "gracePeriodSeconds": 300,
-              "intervalSeconds": 60,
-              "timeoutSeconds": 20,
-              "maxConsecutiveFailures": 3,
-              "ignoreHttp1xx": false
-            }],
-            "dependencies": [],
-            "upgradeStrategy": {
-              "minimumHealthCapacity": 1,
-              "maximumOverCapacity": 1
-            },
-            "labels": {
-              "consul": "something"
-            },
-            "acceptedResourceRoles": null,
-            "ipAddress": null,
-            "version": "2016-01-27T08:36:36.016Z",
-            "versionInfo": {
-              "lastScalingAt": "2016-01-27T08:36:36.016Z",
-              "lastConfigChangeAt": "2016-01-27T08:36:36.016Z"
-            }
-          }],
-          "groups": [],
-          "dependencies": [],
-          "version": "2016-01-27T08:36:36.016Z"
-        }],
-        "dependencies": [],
-        "version": "2016-01-27T08:36:36.016Z"
-      }],
-      "dependencies": [],
-      "version": "2016-01-27T08:36:36.016Z"
-    },
-    "target": {
-      "id": "/",
-      "apps": [],
-      "groups": [{
-        "id": "/com.example",
-        "apps": [],
-        "groups": [{
-          "id": "/com.example/things",
-          "apps": [{
-            "id": "/com.example/things/something",
-            "cmd": "python -m SimpleHTTPServer $PORT0",
-            "args": null,
-            "user": null,
-            "env": {},
-            "instances": 1,
-            "cpus": 0.1,
-            "mem": 16,
-            "disk": 0,
-            "executor": "",
-            "constraints": [],
-            "uris": [],
-            "storeUrls": [],
-            "ports": [10000],
-            "requirePorts": false,
-            "backoffSeconds": 1,
-            "backoffFactor": 1.15,
-            "maxLaunchDelaySeconds": 3600,
-            "container": null,
-            "healthChecks": [{
-              "path": "/",
-              "protocol": "HTTP",
-              "portIndex": 0,
-              "gracePeriodSeconds": 300,
-              "intervalSeconds": 60,
-              "timeoutSeconds": 20,
-              "maxConsecutiveFailures": 3,
-              "ignoreHttp1xx": false
-            }],
-            "dependencies": [],
-            "upgradeStrategy": {
-              "minimumHealthCapacity": 1,
-              "maximumOverCapacity": 1
-            },
-            "labels": {
-              "consul": "somethingDifferent"
-            },
-            "acceptedResourceRoles": null,
-            "ipAddress": null,
-            "version": "2016-01-27T08:38:43.039Z",
-            "versionInfo": {
-              "lastScalingAt": "2016-01-27T08:38:43.039Z",
-              "lastConfigChangeAt": "2016-01-27T08:38:43.039Z"
-            }
-          }],
-          "groups": [],
-          "dependencies": [],
-          "version": "2016-01-27T08:38:43.039Z"
-        }],
-        "dependencies": [],
-        "version": "2016-01-27T08:38:43.039Z"
-      }],
-      "dependencies": [],
-      "version": "2016-01-27T08:38:43.039Z"
-    },
-    "steps": [{
-      "actions": [{
-        "type": "RestartApplication",
-        "app": "/com.example/things/something"
-      }]
-    }],
-    "version": "2016-01-27T08:38:43.039Z"
-  },
-  "currentStep": {
-    "actions": [{
-      "type": "RestartApplication",
-      "app": "/com.example/things/something"
-    }]
-  },
-  "eventType": "deployment_step_success",
-  "timestamp": "2016-01-27T08:39:43.235Z"
-}
\ No newline at end of file
diff --git a/service/service.go b/service/service.go
index 52307e9..6a4c2a3 100644
--- a/service/service.go
+++ b/service/service.go
@@ -40,5 +40,4 @@ type ServiceRegistry interface {
 	Register(task *apps.Task, app *apps.App) error
 	DeregisterByTask(taskId apps.TaskID) error
 	Deregister(toDeregister *Service) error
-	ServiceNames(app *apps.App) []string
 }
diff --git a/web/event_handler.go b/web/event_handler.go
index 4ae16e6..23a754a 100644
--- a/web/event_handler.go
+++ b/web/event_handler.go
@@ -11,7 +11,6 @@ import (
 	"github.com/allegro/marathon-consul/marathon"
 	"github.com/allegro/marathon-consul/metrics"
 	"github.com/allegro/marathon-consul/service"
-	"github.com/allegro/marathon-consul/utils"
 )
 
 type event struct {
@@ -78,10 +77,6 @@ func (fh *eventHandler) handleEvent(eventType string, body []byte) error {
 		return fh.handleHealthStatusEvent(body)
 	case "unhealthy_task_kill_event":
 		return fh.handleUnhealthyTaskKillEvent(body)
-	case "deployment_info":
-		return fh.handleDeploymentInfo(body)
-	case "deployment_step_success":
-		return fh.handleDeploymentStepSuccess(body)
 	default:
 		log.WithField("EventType", eventType).Debug("Not handled event type")
 		return nil
@@ -179,76 +174,6 @@ func (fh *eventHandler) handleUnhealthyTaskKillEvent(body []byte) error {
 	return fh.deregister(task.ID)
 }
 
-//This handler is used when an application is stopped
-func (fh *eventHandler) handleDeploymentInfo(body []byte) error {
-	deploymentEvent, err := events.ParseDeploymentEvent(body)
-
-	if err != nil {
-		log.WithError(err).WithField("Body", body).Error("Could not parse event body")
-		return err
-	}
-
-	errors := []error{}
-	for _, app := range deploymentEvent.StoppedConsulApps() {
-		errors = append(errors, fh.deregisterAllAppServices(app)...)
-	}
-	return utils.MergeErrorsOrNil(errors, "handling deregistration")
-}
-
-//This handler is used when an application is restarted and renamed
-func (fh *eventHandler) handleDeploymentStepSuccess(body []byte) error {
-	deploymentEvent, err := events.ParseDeploymentEvent(body)
-
-	if err != nil {
-		log.WithError(err).WithField("Body", body).Error("Could not parse event body")
-		return err
-	}
-
-	errors := []error{}
-	for _, app := range deploymentEvent.RenamedConsulApps() {
-		errors = append(errors, fh.deregisterAllAppServices(app)...)
-	}
-	return utils.MergeErrorsOrNil(errors, "handling deregistration")
-}
-
-func (fh *eventHandler) deregisterAllAppServices(app *apps.App) []error {
-	errors := []error{}
-	serviceNames := fh.serviceRegistry.ServiceNames(app)
-
-	log.WithField("AppId", app.ID).WithField("ServiceNames", serviceNames).Info("Deregistering all services")
-
-	var allServices []*service.Service
-	for _, name := range serviceNames {
-		services, err := fh.serviceRegistry.GetServices(name)
-		if err != nil {
-			log.WithField("Id", app.ID).WithError(err).Error("There was a problem getting Consul services")
-			errors = append(errors, err)
-			return errors
-		}
-		allServices = append(allServices, services...)
-	}
-
-	if len(allServices) == 0 {
-		log.WithField("AppId", app.ID).WithField("ServiceNames", serviceNames).Info("No matching Consul services found")
-		return errors
-	}
-
-	for _, service := range allServices {
-		taskID, err := service.TaskId()
-		if err != nil {
-			errors = append(errors, err)
-			continue
-		}
-		if taskID.AppID() == app.ID {
-			err = fh.deregister(taskID)
-			if err != nil {
-				errors = append(errors, err)
-			}
-		}
-	}
-	return errors
-}
-
 func (fh *eventHandler) deregister(taskID apps.TaskID) error {
 	err := fh.serviceRegistry.DeregisterByTask(taskID)
 	if err != nil {


Test patch:
diff --git a/apps/app_test.go b/apps/app_test.go
index c3ec573..01987c3 100644
--- a/apps/app_test.go
+++ b/apps/app_test.go
@@ -331,191 +331,6 @@ func TestRegistrationIntent_MultipleIntentsViaPortDefinitionIfMultipleContainCon
 	assert.Equal(t, []string{"common-tag", "second-tag"}, intents[1].Tags)
 }
 
-func TestConsulNames_WithoutPortDefinitions(t *testing.T) {
-	t.Parallel()
-
-	// given
-	app := &App{
-		ID:     "context/app-name",
-		Labels: map[string]string{"consul": ""},
-	}
-
-	// expect
-	assert.Equal(t, []string{"context.app-name"}, app.ConsulNames("."))
-}
-
-func TestConsulNames_WithPortDefinitions(t *testing.T) {
-	t.Parallel()
-
-	// given
-	app := &App{
-		ID:     "context/app-name",
-		Labels: map[string]string{"consul": ""},
-		PortDefinitions: []PortDefinition{
-			{
-				Labels: map[string]string{"consul": "some/name"},
-			},
-			{
-				Labels: map[string]string{"consul": "yet-another/name"},
-			},
-		},
-	}
-
-	// expect
-	assert.Equal(t, []string{"some.name", "yet-another.name"}, app.ConsulNames("."))
-}
-
-func TestHasSameConsulNamesAs_SameConfigsWithoutPortDefinitions(t *testing.T) {
-	t.Parallel()
-
-	// given
-	app := &App{
-		ID:     "app-name",
-		Labels: map[string]string{"consul": "true"},
-	}
-
-	// expect
-	assert.True(t, app.HasSameConsulNamesAs(app))
-}
-
-func TestHasSameConsulNamesAs_DifferentConfigsSameNameWithoutPortDefinitions(t *testing.T) {
-	t.Parallel()
-
-	// given
-	app := &App{
-		ID:     "app-name",
-		Labels: map[string]string{"consul": "true"},
-	}
-	other := &App{
-		ID:     "app-name",
-		Labels: map[string]string{"consul": "app-name"},
-	}
-
-	// expect
-	assert.True(t, app.HasSameConsulNamesAs(other))
-	assert.True(t, other.HasSameConsulNamesAs(other))
-}
-
-func TestHasSameConsulNamesAs_DifferentConfigsWithoutPortDefinitions(t *testing.T) {
-	t.Parallel()
-
-	// given
-	app := &App{
-		ID:     "app-name",
-		Labels: map[string]string{"consul": "some-name"},
-	}
-	other := &App{
-		ID:     "app-name",
-		Labels: map[string]string{"consul": "different-name"},
-	}
-
-	// expect
-	assert.False(t, app.HasSameConsulNamesAs(other))
-}
-
-func TestHasSameConsulNamesAs_SameConfigsWithPortDefinitions(t *testing.T) {
-	t.Parallel()
-
-	// given
-	app := &App{
-		ID:     "app-name",
-		Labels: map[string]string{"consul": "true"},
-		PortDefinitions: []PortDefinition{
-			{
-				Labels: map[string]string{"consul": "true"},
-			},
-		},
-	}
-
-	// expect
-	assert.True(t, app.HasSameConsulNamesAs(app))
-}
-
-func TestHasSameConsulNamesAs_DifferentConfigsSameNamesWithPortDefinitions(t *testing.T) {
-	t.Parallel()
-
-	// given
-	app := &App{
-		ID:     "app-name",
-		Labels: map[string]string{"consul": "true"},
-		PortDefinitions: []PortDefinition{
-			{
-				Labels: map[string]string{"consul": "true"},
-			},
-		},
-	}
-	other := &App{
-		ID:     "app-name",
-		Labels: map[string]string{"consul": "true"},
-		PortDefinitions: []PortDefinition{
-			{
-				Labels: map[string]string{"consul": "app-name"},
-			},
-		},
-	}
-
-	// expect
-	assert.True(t, app.HasSameConsulNamesAs(other))
-	assert.True(t, other.HasSameConsulNamesAs(app))
-}
-
-func TestHasSameConsulNamesAs_DifferentConfigsDifferentNamesWithPortDefinitions(t *testing.T) {
-	t.Parallel()
-
-	// given
-	app := &App{
-		ID:     "app-name",
-		Labels: map[string]string{"consul": "true"},
-		PortDefinitions: []PortDefinition{
-			{
-				Labels: map[string]string{"consul": "some-name"},
-			},
-		},
-	}
-	other := &App{
-		ID:     "app-name",
-		Labels: map[string]string{"consul": "true"},
-		PortDefinitions: []PortDefinition{
-			{
-				Labels: map[string]string{"consul": "other-name"},
-			},
-		},
-	}
-
-	// expect
-	assert.False(t, app.HasSameConsulNamesAs(other))
-}
-
-func TestHasSameConsulNamesAs_DifferentConfigsDifferentNumberOfRegitrationsWithPortDefinitions(t *testing.T) {
-	t.Parallel()
-
-	// given
-	app := &App{
-		ID:     "app-name",
-		Labels: map[string]string{"consul": "true"},
-		PortDefinitions: []PortDefinition{
-			{
-				Labels: map[string]string{"consul": "some-name"},
-			},
-		},
-	}
-	other := &App{
-		ID:     "app-name",
-		Labels: map[string]string{"consul": "true"},
-		PortDefinitions: []PortDefinition{
-			{
-				Labels: map[string]string{"consul": "some-name"},
-			},
-			{
-				Labels: map[string]string{"consul": "yet-another-name"},
-			},
-		},
-	}
-
-	// expect
-	assert.False(t, app.HasSameConsulNamesAs(other))
-}
-
 func TestRegistrationIntentsNumber_NotConsulApp(t *testing.T) {
 	t.Parallel()
 
diff --git a/events/deployment_info_test.go b/events/deployment_info_test.go
deleted file mode 100644
index e6f7905..0000000
--- a/events/deployment_info_test.go
+++ /dev/null
@@ -1,393 +0,0 @@
-package events
-
-import (
-	"io/ioutil"
-	"testing"
-
-	"github.com/allegro/marathon-consul/apps"
-	"github.com/stretchr/testify/assert"
-)
-
-func TestParseDeploymentInfo(t *testing.T) {
-	t.Parallel()
-	// given
-	blob, _ := ioutil.ReadFile("deployment_info.json")
-
-	// when
-	deploymentInfo, err := ParseDeploymentEvent(blob)
-	action := deploymentInfo.actions()[0]
-	app := deploymentInfo.originalDeployments().apps()[0]
-
-	// then
-	assert.NoError(t, err)
-	assert.Equal(t, "StopApplication", action.Type)
-	assert.Equal(t, "/internalName", action.AppID.String())
-	assert.Equal(t, "/internalName", app.ID.String())
-	assert.Equal(t, "consulName", app.Labels["consul"])
-}
-
-func TestParseDeploymentStepSuccess(t *testing.T) {
-	t.Parallel()
-	// given
-	blob, _ := ioutil.ReadFile("deployment_step_success.json")
-
-	// when
-	deploymentInfo, err := ParseDeploymentEvent(blob)
-	action := deploymentInfo.actions()[0]
-	app := deploymentInfo.RestartedConsulApps()[0]
-
-	// then
-	assert.NoError(t, err)
-	assert.Equal(t, "RestartApplication", action.Type)
-	assert.Equal(t, "/a", action.AppID.String())
-	assert.Equal(t, "/a", app.ID.String())
-	assert.Equal(t, "b", app.Labels["consul"])
-}
-
-func TestParseDeploymentStepSuccessWithGroups(t *testing.T) {
-	t.Parallel()
-	// given
-	blob, _ := ioutil.ReadFile("deployment_step_success_with_groups.json")
-
-	// when
-	deploymentInfo, err := ParseDeploymentEvent(blob)
-	action := deploymentInfo.actions()[0]
-	app := deploymentInfo.RestartedConsulApps()[0]
-
-	// then
-	assert.NoError(t, err)
-	assert.Equal(t, "RestartApplication", action.Type)
-	assert.Equal(t, "/com.example/things/something", action.AppID.String())
-	assert.Equal(t, "/com.example/things/something", app.ID.String())
-	assert.Equal(t, "something", app.Labels["consul"])
-}
-
-func TestOriginalDeployments_OnEmpty(t *testing.T) {
-	t.Parallel()
-	// given
-	deploymentInfo := &DeploymentEvent{}
-
-	// when
-	deployments := deploymentInfo.originalDeployments()
-
-	// then
-	assert.NotNil(t, deployments)
-}
-
-func TestTargetDeployments_OnEmpty(t *testing.T) {
-	t.Parallel()
-	// given
-	deploymentInfo := &DeploymentEvent{}
-
-	// when
-	deployments := deploymentInfo.targetDeployments()
-
-	// then
-	assert.NotNil(t, deployments)
-}
-
-func TestActions_OnEmpty(t *testing.T) {
-	t.Parallel()
-	// given
-	deploymentInfo := &DeploymentEvent{}
-
-	// when
-	actions := deploymentInfo.actions()
-
-	// then
-	assert.Len(t, actions, 0)
-}
-
-func TestStoppedConsulApps(t *testing.T) {
-	t.Parallel()
-	// given
-	deploymentInfo := &DeploymentEvent{
-		Plan: &Plan{
-			Original: &Deployments{
-				Apps: []*apps.App{
-					{ID: "app1"},
-					{ID: "app2", Labels: map[string]string{"consul": ""}},
-					{ID: "app3", Labels: map[string]string{"consul": ""}},
-					{ID: "app4"},
-				},
-			},
-		},
-		CurrentStep: &CurrentStep{
-			Actions: []*Action{
-				{Type: "StartApplication", AppID: "app1"},
-				{Type: "StopApplication", AppID: "app2"},
-				{Type: "StopApplication", AppID: "app3"},
-				{Type: "StopApplication", AppID: "app4"},
-			},
-		},
-	}
-
-	// when
-	stoppedApps := deploymentInfo.StoppedConsulApps()
-
-	// then
-	assert.Len(t, stoppedApps, 2)
-	assert.Contains(t, stoppedApps, deploymentInfo.originalDeployments().apps()[1])
-	assert.Contains(t, stoppedApps, deploymentInfo.originalDeployments().apps()[2])
-}
-
-func TestRestartedConsulApps(t *testing.T) {
-	t.Parallel()
-	// given
-	deploymentInfo := &DeploymentEvent{
-		Plan: &Plan{
-			Original: &Deployments{
-				Apps: []*apps.App{
-					{ID: "app1"},
-					{ID: "app2", Labels: map[string]string{"consul": ""}},
-					{ID: "app3", Labels: map[string]string{"consul": "someName"}},
-					{ID: "app4"},
-				},
-			},
-		},
-		CurrentStep: &CurrentStep{
-			Actions: []*Action{
-				{Type: "StartApplication", AppID: "app1"},
-				{Type: "RestartApplication", AppID: "app2"},
-				{Type: "RestartApplication", AppID: "app3"},
-				{Type: "RestartApplication", AppID: "app4"},
-			},
-		},
-	}
-
-	// when
-	restartedApps := deploymentInfo.RestartedConsulApps()
-
-	// then
-	assert.Len(t, restartedApps, 2)
-	assert.Contains(t, restartedApps, deploymentInfo.originalDeployments().apps()[1])
-	assert.Contains(t, restartedApps, deploymentInfo.originalDeployments().apps()[2])
-}
-
-func TestStoppedConsulApps_NoStoppedApps(t *testing.T) {
-	t.Parallel()
-	// given
-	deploymentInfo := &DeploymentEvent{
-		Plan: &Plan{
-			Original: &Deployments{
-				Apps: []*apps.App{
-					{ID: "app1"},
-				},
-			},
-		},
-		CurrentStep: &CurrentStep{
-			Actions: []*Action{
-				{Type: "StartApplication", AppID: "app1"},
-			},
-		},
-	}
-
-	// when
-	stoppedApps := deploymentInfo.StoppedConsulApps()
-
-	// then
-	assert.Len(t, stoppedApps, 0)
-}
-
-func TestStoppedConsulApps_OnEmpty(t *testing.T) {
-	t.Parallel()
-	// given
-	deploymentInfo := &DeploymentEvent{}
-
-	// when
-	stoppedApps := deploymentInfo.StoppedConsulApps()
-
-	// then
-	assert.Len(t, stoppedApps, 0)
-}
-
-func TestRenamedConsulApps(t *testing.T) {
-	t.Parallel()
-	// given
-	deploymentInfo := &DeploymentEvent{
-		Plan: &Plan{
-			Original: &Deployments{
-				Apps: []*apps.App{
-					{ID: "app1", Labels: map[string]string{"consul": "same"}},
-					{ID: "app2"},
-					{ID: "app3", Labels: map[string]string{"consul": "customName"}},
-				},
-			},
-			Target: &Deployments{
-				Apps: []*apps.App{
-					{ID: "app1", Labels: map[string]string{"consul": "same"}},
-					{ID: "app2"},
-					{ID: "app3", Labels: map[string]string{"consul": "newCustomName"}},
-				},
-			},
-		},
-		CurrentStep: &CurrentStep{
-			Actions: []*Action{
-				{Type: "RestartApplication", AppID: "app1"},
-				{Type: "StartApplication", AppID: "app2"},
-				{Type: "RestartApplication", AppID: "app3"},
-			},
-		},
-	}
-
-	// when
-	renamedApps := deploymentInfo.RenamedConsulApps()
-
-	// then
-	assert.Len(t, renamedApps, 1)
-	assert.Contains(t, renamedApps, deploymentInfo.originalDeployments().apps()[2])
-}
-
-func TestRenamedConsulApps_OnEmptyPlan(t *testing.T) {
-	t.Parallel()
-	// given
-	deploymentInfo := &DeploymentEvent{
-		CurrentStep: &CurrentStep{
-			Actions: []*Action{
-				{Type: "RestartApplication", AppID: "app2"},
-				{Type: "StartApplication", AppID: "app1"},
-				{Type: "RestartApplication", AppID: "app3"},
-			},
-		},
-	}
-
-	// when
-	renamedApps := deploymentInfo.RenamedConsulApps()
-
-	// then
-	assert.Len(t, renamedApps, 0)
-}
-
-func TestRenamedConsulApps_OnConsulTrueCase(t *testing.T) {
-	t.Parallel()
-	// given
-	deploymentInfo := &DeploymentEvent{
-		Plan: &Plan{
-			Original: &Deployments{
-				Apps: []*apps.App{
-					{ID: "app1"},
-					{ID: "app2"},
-				},
-			},
-			Target: &Deployments{
-				Apps: []*apps.App{
-					{ID: "app1", Labels: map[string]string{"consul": "true"}},
-					{ID: "app2"},
-				},
-			},
-		},
-		CurrentStep: &CurrentStep{
-			Actions: []*Action{
-				{Type: "RestartApplication", AppID: "app1"},
-				{Type: "RestartApplication", AppID: "app2"},
-			},
-		},
-	}
-
-	// when
-	renamedApps := deploymentInfo.RenamedConsulApps()
-
-	// then
-	assert.Len(t, renamedApps, 0)
-}
-
-func TestRenamedConsulApps_OnCustomNameAdded(t *testing.T) {
-	t.Parallel()
-	// given
-	deploymentInfo := &DeploymentEvent{
-		Plan: &Plan{
-			Original: &Deployments{
-				Apps: []*apps.App{
-					{ID: "app1", Labels: map[string]string{"consul": ""}},
-					{ID: "app2"},
-				},
-			},
-			Target: &Deployments{
-				Apps: []*apps.App{
-					{ID: "app1", Labels: map[string]string{"consul": "customName"}},
-					{ID: "app2"},
-				},
-			},
-		},
-		CurrentStep: &CurrentStep{
-			Actions: []*Action{
-				{Type: "RestartApplication", AppID: "app1"},
-				{Type: "StartApplication", AppID: "app2"},
-			},
-		},
-	}
-
-	// when
-	renamedApps := deploymentInfo.RenamedConsulApps()
-
-	// then
-	assert.Len(t, renamedApps, 1)
-	assert.Contains(t, renamedApps, deploymentInfo.originalDeployments().apps()[0])
-}
-
-func TestRenamedConsulApps_OnCustomNameAddedToNonConsulApp(t *testing.T) {
-	t.Parallel()
-	// given
-	deploymentInfo := &DeploymentEvent{
-		Plan: &Plan{
-			Original: &Deployments{
-				Apps: []*apps.App{
-					{ID: "app1"},
-					{ID: "app2"},
-				},
-			},
-			Target: &Deployments{
-				Apps: []*apps.App{
-					{ID: "app1", Labels: map[string]string{"consul": "customName"}},
-					{ID: "app2"},
-				},
-			},
-		},
-		CurrentStep: &CurrentStep{
-			Actions: []*Action{
-				{Type: "RestartApplication", AppID: "app1"},
-				{Type: "StartApplication", AppID: "app2"},
-			},
-		},
-	}
-
-	// when
-	renamedApps := deploymentInfo.RenamedConsulApps()
-
-	// then
-	assert.Len(t, renamedApps, 0)
-}
-
-func TestRenamedConsulApps_OnConsulLabelRemoved(t *testing.T) {
-	t.Parallel()
-	// given
-	deploymentInfo := &DeploymentEvent{
-		Plan: &Plan{
-			Original: &Deployments{
-				Apps: []*apps.App{
-					{ID: "app1", Labels: map[string]string{"consul": "customName"}},
-					{ID: "app2"},
-				},
-			},
-			Target: &Deployments{
-				Apps: []*apps.App{
-					{ID: "app1"},
-					{ID: "app2"},
-				},
-			},
-		},
-		CurrentStep: &CurrentStep{
-			Actions: []*Action{
-				{Type: "RestartApplication", AppID: "app1"},
-				{Type: "StartApplication", AppID: "app2"},
-			},
-		},
-	}
-
-	// when
-	renamedApps := deploymentInfo.RenamedConsulApps()
-
-	// then
-	assert.Len(t, renamedApps, 1)
-	assert.Contains(t, renamedApps, deploymentInfo.originalDeployments().apps()[0])
-}
diff --git a/sync/error_service_registry_stub_test.go b/sync/error_service_registry_stub_test.go
index 44a505d..18bfcd9 100644
--- a/sync/error_service_registry_stub_test.go
+++ b/sync/error_service_registry_stub_test.go
@@ -29,7 +29,3 @@ func (c errorServiceRegistry) DeregisterByTask(taskID apps.TaskID) error {
 func (c errorServiceRegistry) Deregister(toDeregister *service.Service) error {
 	return errors.New("Error occured")
 }
-
-func (c errorServiceRegistry) ServiceNames(app *apps.App) []string {
-	return []string{}
-}
diff --git a/sync/sync_test.go b/sync/sync_test.go
index 27cfc01..11c87b3 100644
--- a/sync/sync_test.go
+++ b/sync/sync_test.go
@@ -165,10 +165,6 @@ func (c *ConsulServicesMock) DeregisterByTask(taskID apps.TaskID) error {
 	return nil
 }
 
-func (c *ConsulServicesMock) ServiceNames(app *apps.App) []string {
-	return []string{}
-}
-
 func (c *ConsulServicesMock) Deregister(toDeregister *service.Service) error {
 	return nil
 }
diff --git a/web/event_handler_test.go b/web/event_handler_test.go
index f13e2df..3d46300 100644
--- a/web/event_handler_test.go
+++ b/web/event_handler_test.go
@@ -2,16 +2,13 @@ package web
 
 import (
 	"bytes"
-	"encoding/json"
 	"errors"
-	"fmt"
 	"net/http"
 	"net/http/httptest"
 	"testing"
 
 	"github.com/allegro/marathon-consul/apps"
 	"github.com/allegro/marathon-consul/consul"
-	"github.com/allegro/marathon-consul/events"
 	"github.com/allegro/marathon-consul/marathon"
 	. "github.com/allegro/marathon-consul/utils"
 	"github.com/stretchr/testify/assert"
@@ -135,363 +132,6 @@ func TestWebHandler_HandleAppInvalidBody(t *testing.T) {
 	assert.Equal(t, "no event\n", recorder.Body.String())
 }
 
-func TestWebHandler_HandleDeploymentInfoWithStopApplicationAction(t *testing.T) {
-	t.Parallel()
-
-	// given
-	app := ConsulApp("/test/app", 3)
-	marathon := marathon.MarathonerStubForApps()
-	service := newConsulStubWithApplicationsTasksRegistered(app)
-	assert.Len(t, service.RegisteredTaskIDs(), 3)
-	handle, stop := NewHandler(Config{WorkersCount: 1}, marathon, service)
-	app.Tasks = []apps.Task{} // tasks are not available in this event
-	body, _ := json.Marshal(deploymentInfoWithStopApplicationActionForApps(app))
-	req, _ := http.NewRequest("POST", "/events", bytes.NewBuffer([]byte(body)))
-
-	// when
-	recorder := httptest.NewRecorder()
-	handle(recorder, req)
-	stop()
-
-	// then
-	assertAccepted(t, recorder)
-	assert.Empty(t, service.RegisteredTaskIDs())
-	assert.False(t, marathon.Interactions())
-}
-
-func TestWebHandler_handleDeploymentInfoWithStopApplicationForOneApp(t *testing.T) {
-	t.Parallel()
-
-	// given
-	green := ConsulApp("/test/app.green", 3)
-	green.Labels[apps.MarathonConsulLabel] = "app"
-	blue := ConsulApp("/test/app.blue", 2)
-	blue.Labels[apps.MarathonConsulLabel] = "app"
-	marathon := marathon.MarathonerStubForApps()
-	service := newConsulStubWithApplicationsTasksRegistered(green, blue)
-	assert.Len(t, service.RegisteredTaskIDs(), 5)
-	handle, stop := NewHandler(Config{WorkersCount: 1}, marathon, service)
-	body, _ := json.Marshal(deploymentInfoWithStopApplicationActionForApps(green))
-	req, _ := http.NewRequest("POST", "/events", bytes.NewBuffer([]byte(body)))
-
-	// when
-	recorder := httptest.NewRecorder()
-	handle(recorder, req)
-	stop()
-
-	// then
-	assertAccepted(t, recorder)
-	assert.Len(t, service.RegisteredTaskIDs(), 2)
-	assert.False(t, marathon.Interactions())
-}
-
-func TestWebHandler_HandleDeploymentInfoWithStopApplicationActionForMultipleApps(t *testing.T) {
-	t.Parallel()
-
-	// given
-	app1 := ConsulApp("/test/app", 3)
-	app2 := ConsulApp("/test/otherapp", 2)
-	marathon := marathon.MarathonerStubForApps()
-	service := newConsulStubWithApplicationsTasksRegistered(app1, app2)
-	assert.Len(t, service.RegisteredTaskIDs(), 5)
-	handle, stop := NewHandler(Config{WorkersCount: 1}, marathon, service)
-	body, _ := json.Marshal(deploymentInfoWithStopApplicationActionForApps(app1, app2))
-	req, _ := http.NewRequest("POST", "/events", bytes.NewBuffer([]byte(body)))
-
-	// when
-	recorder := httptest.NewRecorder()
-	handle(recorder, req)
-	stop()
-
-	// then
-	assertAccepted(t, recorder)
-	assert.Len(t, service.RegisteredTaskIDs(), 0)
-	assert.False(t, marathon.Interactions())
-}
-
-func TestWebHandler_HandleDeploymentInfoWithStopApplicationActionForMultipleAppsAndProblemsDeregisteringOne(t *testing.T) {
-	t.Parallel()
-
-	// given
-	app1 := ConsulApp("/test/app", 3)
-	app2 := ConsulApp("/test/otherapp", 2)
-	marathon := marathon.MarathonerStubForApps()
-	service := newConsulStubWithApplicationsTasksRegistered(app1, app2)
-	service.FailDeregisterByTaskForID("test_app.1")
-	assert.Len(t, service.RegisteredTaskIDs(), 5)
-	handle, stop := NewHandler(Config{WorkersCount: 1}, marathon, service)
-	body, _ := json.Marshal(deploymentInfoWithStopApplicationActionForApps(app1, app2))
-	req, _ := http.NewRequest("POST", "/events", bytes.NewBuffer([]byte(body)))
-
-	// when
-	recorder := httptest.NewRecorder()
-	handle(recorder, req)
-	stop()
-
-	// then
-	assertAccepted(t, recorder)
-	assert.Len(t, service.RegisteredTaskIDs(), 1)
-	assert.False(t, marathon.Interactions())
-}
-
-func TestWebHandler_HandleDeploymentInfoWithStopApplicationActionWithNoServicesRegistered(t *testing.T) {
-	t.Parallel()
-
-	// given
-	app := ConsulApp("/test/app", 3)
-	marathon := marathon.MarathonerStubForApps()
-	service := consul.NewConsulStub()
-	assert.Len(t, service.RegisteredTaskIDs(), 0)
-	handle, stop := NewHandler(Config{WorkersCount: 1}, marathon, service)
-	body, _ := json.Marshal(deploymentInfoWithStopApplicationActionForApps(app))
-	req, _ := http.NewRequest("POST", "/events", bytes.NewBuffer([]byte(body)))
-
-	// when
-	recorder := httptest.NewRecorder()
-	handle(recorder, req)
-	stop()
-
-	// then
-	assertAccepted(t, recorder)
-	assert.Len(t, service.RegisteredTaskIDs(), 0)
-	assert.False(t, marathon.Interactions())
-}
-
-func TestWebHandler_HandleDeploymentInfoWithInvalidBody(t *testing.T) {
-	t.Parallel()
-
-	// given
-	app := ConsulApp("/test/app", 3)
-	marathon := marathon.MarathonerStubForApps()
-	service := newConsulStubWithApplicationsTasksRegistered(app)
-	assert.Len(t, service.RegisteredTaskIDs(), 3)
-	handle, stop := NewHandler(Config{WorkersCount: 1}, marathon, service)
-	req, _ := http.NewRequest("POST", "/events", bytes.NewBuffer([]byte(`{"eventType":"deployment_info", "Plan": 123}`)))
-
-	// when
-	recorder := httptest.NewRecorder()
-	handle(recorder, req)
-	stop()
-
-	// then
-	assertAccepted(t, recorder)
-	assert.Len(t, service.RegisteredTaskIDs(), 3)
-	assert.False(t, marathon.Interactions())
-}
-
-func TestWebHandler_HandleDeploymentInfoWithStopApplicationActionForNonConsulApp(t *testing.T) {
-	t.Parallel()
-
-	// given
-	app := NonConsulApp("/test/app", 3)
-	marathon := marathon.MarathonerStubForApps()
-	service := newConsulStubWithApplicationsTasksRegistered(app)
-	assert.Len(t, service.RegisteredTaskIDs(), 3)
-	handle, stop := NewHandler(Config{WorkersCount: 1}, marathon, service)
-	body, _ := json.Marshal(deploymentInfoWithStopApplicationActionForApps(app))
-	req, _ := http.NewRequest("POST", "/events", bytes.NewBuffer([]byte(body)))
-
-	// when
-	recorder := httptest.NewRecorder()
-	handle(recorder, req)
-	stop()
-
-	// then
-	assertAccepted(t, recorder)
-	assert.Len(t, service.RegisteredTaskIDs(), 3)
-	assert.False(t, marathon.Interactions())
-}
-
-func TestWebHandler_HandleDeploymentInfoWithStopApplicationActionForCustomServiceName(t *testing.T) {
-	t.Parallel()
-
-	// given
-	app := ConsulApp("/test/app", 3)
-	app.Labels["consul"] = "someCustomServiceName"
-	marathon := marathon.MarathonerStubForApps()
-	service := newConsulStubWithApplicationsTasksRegistered(app)
-	assert.Len(t, service.RegisteredTaskIDs(), 3)
-	handle, stop := NewHandler(Config{WorkersCount: 1}, marathon, service)
-	body, _ := json.Marshal(deploymentInfoWithStopApplicationActionForApps(app))
-	req, _ := http.NewRequest("POST", "/events", bytes.NewBuffer([]byte(body)))
-
-	// when
-	recorder := httptest.NewRecorder()
-	handle(recorder, req)
-	stop()
-
-	// then
-	assertAccepted(t, recorder)
-	assert.Len(t, service.RegisteredTaskIDs(), 0)
-	assert.False(t, marathon.Interactions())
-}
-
-func TestWebHandler_NotHandleDeploymentInfoWithScaleApplicationAction(t *testing.T) {
-	t.Parallel()
-
-	// given
-	app := ConsulApp("/test/app", 3)
-	marathon := marathon.MarathonerStubForApps()
-	service := newConsulStubWithApplicationsTasksRegistered(app)
-	assert.Len(t, service.RegisteredTaskIDs(), 3)
-	handle, stop := NewHandler(Config{WorkersCount: 1}, marathon, service)
-	deploymentInfo := deploymentInfoWithStopApplicationActionForApps(app)
-	deploymentInfo.CurrentStep.Actions[0].Type = "ScaleApplication"
-	body, _ := json.Marshal(deploymentInfo)
-	req, _ := http.NewRequest("POST", "/events", bytes.NewBuffer([]byte(body)))
-
-	// when
-	recorder := httptest.NewRecorder()
-	handle(recorder, req)
-	stop()
-
-	// then
-	assertAccepted(t, recorder)
-	assert.Len(t, service.RegisteredTaskIDs(), 3)
-	assert.False(t, marathon.Interactions())
-}
-
-func TestWebHandler_HandleDeploymentInfoWithStopApplicationActionAndProblemsDeregistering(t *testing.T) {
-	t.Parallel()
-
-	// given
-	app := ConsulApp("/test/app", 3)
-	marathon := marathon.MarathonerStubForApps()
-	service := newConsulStubWithApplicationsTasksRegistered(app)
-	service.FailDeregisterByTaskForID("test_app.1")
-	assert.Len(t, service.RegisteredTaskIDs(), 3)
-	handle, stop := NewHandler(Config{WorkersCount: 1}, marathon, service)
-	body, _ := json.Marshal(deploymentInfoWithStopApplicationActionForApps(app))
-	req, _ := http.NewRequest("POST", "/events", bytes.NewBuffer([]byte(body)))
-
-	// when
-	recorder := httptest.NewRecorder()
-	handle(recorder, req)
-	stop()
-
-	// then
-	assertAccepted(t, recorder)
-	assert.Len(t, service.RegisteredTaskIDs(), 1)
-	assert.False(t, marathon.Interactions())
-}
-
-func deploymentInfoWithStopApplicationActionForApps(applications ...*apps.App) *events.DeploymentEvent {
-
-	deploymentInfo := &events.DeploymentEvent{
-		Type: "deployment_info",
-		Plan: &events.Plan{
-			Original: &events.Deployments{
-				Apps: []*apps.App{},
-			},
-		},
-		CurrentStep: &events.CurrentStep{
-			Actions: []*events.Action{},
-		},
-	}
-	for _, app := range applications {
-		deploymentInfo.Plan.Original.Apps = append(deploymentInfo.Plan.Original.Apps, app)
-		deploymentInfo.CurrentStep.Actions = append(deploymentInfo.CurrentStep.Actions, &events.Action{AppID: app.ID, Type: "StopApplication"})
-	}
-	return deploymentInfo
-}
-
-func TestWebHandler_HandleDeploymentStepSuccessWithRestartAndRenameApplicationAction(t *testing.T) {
-	t.Parallel()
-
-	// given
-	app := ConsulApp("/test/app", 3)
-	marathon := marathon.MarathonerStubForApps()
-	service := newConsulStubWithApplicationsTasksRegistered(app)
-	assert.Len(t, service.RegisteredTaskIDs(), 3)
-	handle, stop := NewHandler(Config{WorkersCount: 1}, marathon, service)
-	body, _ := json.Marshal(deploymentStepSuccessWithRestartAndRenameApplicationActionForApps(app))
-	req, _ := http.NewRequest("POST", "/events", bytes.NewBuffer([]byte(body)))
-
-	// when
-	recorder := httptest.NewRecorder()
-	handle(recorder, req)
-	stop()
-
-	// then
-	assertAccepted(t, recorder)
-	assert.Len(t, service.RegisteredTaskIDs(), 0)
-	assert.False(t, marathon.Interactions())
-}
-
-func TestWebHandler_HandleDeploymentStepSuccessWithInvalidBody(t *testing.T) {
-	t.Parallel()
-
-	// given
-	app := ConsulApp("/test/app", 3)
-	marathon := marathon.MarathonerStubForApps()
-	service := newConsulStubWithApplicationsTasksRegistered(app)
-	assert.Len(t, service.RegisteredTaskIDs(), 3)
-	handle, stop := NewHandler(Config{WorkersCount: 1}, marathon, service)
-	req, _ := http.NewRequest("POST", "/events", bytes.NewBuffer([]byte(`{"eventType":"deployment_step_success", "Plan": 123}`)))
-
-	// when
-	recorder := httptest.NewRecorder()
-	handle(recorder, req)
-	stop()
-
-	// then
-	assertAccepted(t, recorder)
-	assert.Len(t, service.RegisteredTaskIDs(), 3)
-	assert.False(t, marathon.Interactions())
-}
-
-func TestWebHandler_HandleDeploymentStepSuccessWithRestartApplicationActionForMultipleAppsAndProblemsDeregisteringOne(t *testing.T) {
-	t.Parallel()
-
-	// given
-	app1 := ConsulApp("/test/app", 3)
-	app2 := ConsulApp("/test/otherapp", 2)
-	marathon := marathon.MarathonerStubForApps()
-	service := newConsulStubWithApplicationsTasksRegistered(app1, app2)
-	service.FailDeregisterByTaskForID("test_app.1")
-	assert.Len(t, service.RegisteredTaskIDs(), 5)
-	handle, stop := NewHandler(Config{WorkersCount: 1}, marathon, service)
-	body, _ := json.Marshal(deploymentStepSuccessWithRestartAndRenameApplicationActionForApps(app1, app2))
-	req, _ := http.NewRequest("POST", "/events", bytes.NewBuffer([]byte(body)))
-
-	// when
-	recorder := httptest.NewRecorder()
-	handle(recorder, req)
-	stop()
-
-	// then
-	assertAccepted(t, recorder)
-	assert.Len(t, service.RegisteredTaskIDs(), 1)
-	assert.False(t, marathon.Interactions())
-}
-
-func deploymentStepSuccessWithRestartAndRenameApplicationActionForApps(applications ...*apps.App) *events.DeploymentEvent {
-	deploymentInfo := &events.DeploymentEvent{
-		Type: "deployment_step_success",
-		Plan: &events.Plan{
-			Original: &events.Deployments{
-				Apps: []*apps.App{},
-			},
-			Target: &events.Deployments{
-				Apps: []*apps.App{},
-			},
-		},
-		CurrentStep: &events.CurrentStep{
-			Actions: []*events.Action{},
-		},
-	}
-	for _, app := range applications {
-		deploymentInfo.Plan.Original.Apps = append(deploymentInfo.Plan.Original.Apps, app)
-		targetApp := &apps.App{ID: app.ID, Labels: map[string]string{}}
-		if name, ok := app.Labels["consul"]; ok {
-			targetApp.Labels["consul"] = fmt.Sprintf("New%s", name)
-		}
-		deploymentInfo.Plan.Target.Apps = append(deploymentInfo.Plan.Target.Apps, targetApp)
-		deploymentInfo.CurrentStep.Actions = append(deploymentInfo.CurrentStep.Actions, &events.Action{AppID: app.ID, Type: "RestartApplication"})
-	}
-	return deploymentInfo
-}
-
 func TestWebHandler_NotHandleStatusEventWithInvalidBody(t *testing.T) {
 	t.Parallel()