Skip to content

Commit

Permalink
fix(test): add flags to identify and stub Mesos requests
Browse files Browse the repository at this point in the history
Add flags (query parameters) to identify and stub Mesos Operator API
requests to fix the integration tests that were otherwise failing or
flaky due to parsing errors in the `MesosStateStore`. The store failed
to parse the `GET_MASTER` response as we could only register one stub
for both the `GET_MASTER` and `SUBSCRIBE` requests resulting in JSON
parse errors due to the different response formats (RecoredIO<JSON>,
JSON).

The flags are necessary as Cypress can only stub requests based on the
URL and request method and doesn't provide the means to dynamically stub
requests based on the payload as documented in
cypress-io/cypress#521. We will remove the
flags once the Cypress team rewrote the network handling and added
support for dynamic stubs as documented in
cypress-io/cypress#687 or we've  addressed
https://jira.mesosphere.com/browse/DCOS_OSS-2021.
  • Loading branch information
Orlando Hohmeier committed Dec 29, 2017
1 parent b897de0 commit dd9d8dc
Show file tree
Hide file tree
Showing 9 changed files with 259 additions and 74 deletions.
4 changes: 3 additions & 1 deletion src/js/core/MesosStream.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import { stream } from "@dcos/mesos-client";

export const MesosStreamType = Symbol("MesosStreamType");
export default stream({ type: "SUBSCRIBE" }).publishReplay().refCount();
export default stream({ type: "SUBSCRIBE" }, "/mesos/api/v1?subscribe")
.publishReplay()
.refCount();
5 changes: 4 additions & 1 deletion src/js/stores/MesosStateStore.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,10 @@ class MesosStateStore extends GetSetBaseStore {
subscribe() {
const mesosStream = container.get(MesosStreamType);
const parsers = pipe(...Object.values(mesosStreamParsers));
const getMasterRequest = request({ type: "GET_MASTER" }).retry(3);
const getMasterRequest = request(
{ type: "GET_MASTER" },
"/mesos/api/v1?get_master"
).retry(3);

this.stream = mesosStream
.merge(getMasterRequest)
Expand Down
33 changes: 33 additions & 0 deletions tests/_fixtures/1-service-with-executor-task/mesos-get-master.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
{
"get_master": {
"master_info": {
"address": {
"hostname": "10.0.7.122",
"ip": "10.0.7.122",
"port": 5050
},
"capabilities": [
{
"type": "AGENT_UPDATE"
}
],
"domain": {
"fault_domain": {
"region": {
"name": "region-1"
},
"zone": {
"name": "zone-1"
}
}
},
"hostname": "10.0.7.122",
"id": "b3bd182c-c6d7-463e-8bf0-06cd5807df4e",
"ip": 2198274058,
"pid": "master@10.0.7.122:5050",
"port": 5050,
"version": "0.27.0"
}
},
"type": "GET_MASTER"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
{
"get_master": {
"master_info": {
"address": {
"hostname": "10.0.4.58",
"ip": "10.0.4.58",
"port": 5050
},
"capabilities": [
{
"type": "AGENT_UPDATE"
}
],
"domain": {
"fault_domain": {
"region": {
"name": "region-1"
},
"zone": {
"name": "zone-1"
}
}
},
"hostname": "10.0.4.58",
"id": "74f1836b-6784-4030-816e-aacbdd45ff57",
"ip": 2198274058,
"pid": "master@10.0.4.58:5050",
"port": 5050,
"version": "1.2.0"
}
},
"type": "GET_MASTER"
}
33 changes: 33 additions & 0 deletions tests/_fixtures/marathon-1-task/mesos-get-master.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
{
"get_master": {
"master_info": {
"address": {
"hostname": "172.17.8.101",
"ip": "172.17.8.101",
"port": 5050
},
"capabilities": [
{
"type": "AGENT_UPDATE"
}
],
"domain": {
"fault_domain": {
"region": {
"name": "region-1"
},
"zone": {
"name": "zone-1"
}
}
},
"hostname": "172.17.8.101",
"id": "20151004-214809-1695027628-5050-12268",
"ip": 2198274058,
"pid": "master@172.17.8.101:5050",
"port": 5050,
"version": "0.23.0"
}
},
"type": "GET_MASTER"
}
Loading

0 comments on commit dd9d8dc

Please sign in to comment.