MCPcopy Create free account
hub / github.com/apache/mesos / TEST

Function TEST

src/tests/common/http_tests.cpp:47–159  ·  view source on GitHub ↗

This test ensures we don't break the API when it comes to JSON representation of tasks.

Source from the content-addressed store, hash-verified

45// This test ensures we don't break the API when it comes to JSON
46// representation of tasks.
47TEST(HTTPTest, ModelTask)
48{
49 TaskID taskId;
50 taskId.set_value("t");
51
52 SlaveID slaveId;
53 slaveId.set_value("s");
54
55 ExecutorID executorId;
56 executorId.set_value("t");
57
58 FrameworkID frameworkId;
59 frameworkId.set_value("f");
60
61 TaskState state = TASK_RUNNING;
62
63 vector<TaskStatus> statuses;
64
65 TaskStatus status;
66 status.mutable_task_id()->CopyFrom(taskId);
67 status.set_state(state);
68 status.mutable_slave_id()->CopyFrom(slaveId);
69 status.mutable_executor_id()->CopyFrom(executorId);
70 status.set_timestamp(0.0);
71
72 statuses.push_back(status);
73
74 Labels labels;
75 labels.add_labels()->CopyFrom(createLabel("ACTION", "port:7987 DENY"));
76
77 Ports ports;
78 Port* port = ports.add_ports();
79 port->set_number(80);
80 port->mutable_labels()->CopyFrom(labels);
81
82 DiscoveryInfo discovery;
83 discovery.set_visibility(DiscoveryInfo::CLUSTER);
84 discovery.set_name("discover");
85 discovery.mutable_ports()->CopyFrom(ports);
86
87 TaskInfo taskInfo;
88 taskInfo.set_name("task");
89 taskInfo.mutable_task_id()->CopyFrom(taskId);
90 taskInfo.mutable_slave_id()->CopyFrom(slaveId);
91 taskInfo.mutable_command()->set_value("echo hello");
92 taskInfo.mutable_command()->set_user("user1");
93 taskInfo.mutable_discovery()->CopyFrom(discovery);
94 (*taskInfo.mutable_limits())["cpus"].set_value(1.0);
95 (*taskInfo.mutable_limits())["mem"].set_value(32);
96
97 Task task = createTask(taskInfo, state, frameworkId);
98 task.add_statuses()->CopyFrom(statuses[0]);
99
100 JSON::Value object = model(task);
101
102 Try<JSON::Value> expected = JSON::parse(
103 "{"
104 " \"executor_id\":\"\","

Callers

nothing calls this directly

Calls 15

createLabelFunction · 0.85
protobufFunction · 0.85
jsonifyFunction · 0.85
asV1ProtobufClass · 0.85
CopyFromMethod · 0.80
set_numberMethod · 0.80
set_some_slave_fieldMethod · 0.80
add_some_slave_fieldsMethod · 0.80
set_some_slave_enumMethod · 0.80
add_some_slave_enumsMethod · 0.80

Tested by

no test coverage detected