You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hawq.apache.org by wl...@apache.org on 2016/07/06 01:45:08 UTC
[1/5] incubator-hawq git commit: HAWQ-891. Refine libyarn codes
Repository: incubator-hawq
Updated Branches:
refs/heads/master 8b79e10fd -> 383818c28
http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/383818c2/depends/libyarn/test/unit/TestRecords/TestApplicationSubmisionContext.cpp
----------------------------------------------------------------------
diff --git a/depends/libyarn/test/unit/TestRecords/TestApplicationSubmisionContext.cpp b/depends/libyarn/test/unit/TestRecords/TestApplicationSubmisionContext.cpp
new file mode 100644
index 0000000..2f12bae
--- /dev/null
+++ b/depends/libyarn/test/unit/TestRecords/TestApplicationSubmisionContext.cpp
@@ -0,0 +1,156 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+#include <string>
+
+#include "gtest/gtest.h"
+#include "gmock/gmock.h"
+
+#include "records/ApplicationSubmissionContext.h"
+
+using std::string;
+using namespace libyarn;
+using namespace testing;
+
+class TestApplicationSubmissionContext: public ::testing::Test {
+protected:
+ ApplicationSubmissionContext applicationContext;
+};
+
+TEST_F(TestApplicationSubmissionContext, TestGetApplicationId)
+{
+ ApplicationId id;
+ ApplicationId retId;
+
+ applicationContext.setApplicationId(id);
+ retId = applicationContext.getApplicationId();
+
+ /* The operator '==' is not defined for class ApplicationId,
+ so we can't compare id and retId here. */
+
+ SUCCEED();
+}
+
+TEST_F(TestApplicationSubmissionContext, TestGetApplicationName)
+{
+ string name("name");
+ string retName;
+
+ applicationContext.setApplicationName(name);
+ retName = applicationContext.getApplicationName();
+
+ EXPECT_EQ(name, retName);
+}
+
+TEST_F(TestApplicationSubmissionContext, TestGetQueue)
+{
+ string queue("queue");
+ string retQueue;
+
+ applicationContext.setQueue(queue);
+ retQueue = applicationContext.getQueue();
+
+ EXPECT_EQ(queue, retQueue);
+}
+
+TEST_F(TestApplicationSubmissionContext, TestGetPriority)
+{
+ Priority priority;
+ Priority retPriority;
+
+ applicationContext.setPriority(priority);
+ retPriority = applicationContext.getPriority();
+
+ /* The operator '==' is not defined for class Priority,
+ so we can't compare priority and retPriority here. */
+
+ SUCCEED();
+}
+
+TEST_F(TestApplicationSubmissionContext, TestGetAMContainerSpec)
+{
+ ContainerLaunchContext context;
+ ContainerLaunchContext retContext;
+
+ applicationContext.setAMContainerSpec(context);
+ retContext = applicationContext.getAMContainerSpec();
+
+ /* The operator '==' is not defined for class ContainerLaunchContext,
+ so we can't compare context and retContext here. */
+
+ SUCCEED();
+}
+
+TEST_F(TestApplicationSubmissionContext, TestGetCancelTokensWhenComplete)
+{
+ bool flag = true;
+ bool retFlag;
+
+ applicationContext.setCancelTokensWhenComplete(flag);
+ retFlag = applicationContext.getCancelTokensWhenComplete();
+
+ EXPECT_EQ(flag, retFlag);
+}
+
+TEST_F(TestApplicationSubmissionContext, TestGetUnmanagedAM)
+{
+ bool flag = true;
+ bool retFlag;
+
+ applicationContext.setUnmanagedAM(flag);
+ retFlag = applicationContext.getUnmanagedAM();
+
+ EXPECT_EQ(flag, retFlag);
+}
+
+TEST_F(TestApplicationSubmissionContext, TestGetMaxAppAttempts)
+{
+ int32_t max = -1;
+ int32_t retMax;
+
+ applicationContext.setMaxAppAttempts(max);
+ retMax = applicationContext.getMaxAppAttempts();
+
+ EXPECT_EQ(max, retMax);
+}
+
+TEST_F(TestApplicationSubmissionContext, TestGetResource)
+{
+ Resource resource;
+ Resource retResource;
+
+ applicationContext.setResource(resource);
+ retResource = applicationContext.getResource();
+
+ /* The operator '==' is not defined for class Resource,
+ so we can't compare resource and retResource here. */
+
+ SUCCEED();
+}
+
+TEST_F(TestApplicationSubmissionContext, TestGetApplicationType)
+{
+ string type("type");
+ string retType;
+
+ applicationContext.setApplicationType(type);
+ retType = applicationContext.getApplicationType();
+
+ EXPECT_EQ(type, retType);
+}
http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/383818c2/depends/libyarn/test/unit/TestRecords/TestContainerExceptionMap.cpp
----------------------------------------------------------------------
diff --git a/depends/libyarn/test/unit/TestRecords/TestContainerExceptionMap.cpp b/depends/libyarn/test/unit/TestRecords/TestContainerExceptionMap.cpp
new file mode 100644
index 0000000..ccfd28d
--- /dev/null
+++ b/depends/libyarn/test/unit/TestRecords/TestContainerExceptionMap.cpp
@@ -0,0 +1,59 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+#include "gtest/gtest.h"
+#include "gmock/gmock.h"
+
+#include "records/ContainerExceptionMap.h"
+
+using namespace libyarn;
+using namespace testing;
+
+class TestContainerExceptionMap: public ::testing::Test {
+protected:
+ ContainerExceptionMap containerMap;
+};
+
+TEST_F(TestContainerExceptionMap, TestGetContainerId)
+{
+ ContainerId id;
+ ContainerId retId;
+
+ containerMap.setContainerId(id);
+ retId = containerMap.getContainerId();
+
+ /* The operator '==' is not defined for class ContainerId,
+ so we can't compare id and retId here. */
+
+ SUCCEED();
+}
+
+TEST_F(TestContainerExceptionMap, TestSerializedException)
+{
+ SerializedException exception;
+ SerializedException retException;
+
+ containerMap.setSerializedException(exception);
+ retException = containerMap.getSerializedException();
+
+ /* The operator '==' is not defined for class SerializedException,
+ so we can't compare exception and retException here. */
+
+ SUCCEED();
+}
http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/383818c2/depends/libyarn/test/unit/TestRecords/TestContainerId.cpp
----------------------------------------------------------------------
diff --git a/depends/libyarn/test/unit/TestRecords/TestContainerId.cpp b/depends/libyarn/test/unit/TestRecords/TestContainerId.cpp
new file mode 100644
index 0000000..4092801
--- /dev/null
+++ b/depends/libyarn/test/unit/TestRecords/TestContainerId.cpp
@@ -0,0 +1,59 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+#include "gtest/gtest.h"
+#include "gmock/gmock.h"
+
+#include "records/ContainerId.h"
+
+using namespace libyarn;
+using namespace testing;
+
+class TestContainerId: public ::testing::Test {
+protected:
+ ContainerId containerId;
+};
+
+TEST_F(TestContainerId, TestGetApplicationId)
+{
+ ApplicationId id;
+ ApplicationId retId;
+
+ containerId.setApplicationId(id);
+ retId = containerId.getApplicationId();
+
+ /* The operator '==' is not defined for class ApplicationId,
+ so we can't compare id and retId here. */
+
+ SUCCEED();
+}
+
+TEST_F(TestContainerId, TestGetApplicationAttemptId)
+{
+ ApplicationAttemptId id;
+ ApplicationAttemptId retId;
+
+ containerId.setApplicationAttemptId(id);
+ retId = containerId.getApplicationAttemptId();
+
+ /* The operator '==' is not defined for class ApplicationAttemptId,
+ so we can't compare id and retId here. */
+
+ SUCCEED();
+}
http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/383818c2/depends/libyarn/test/unit/TestRecords/TestContainerLaunchContext.cpp
----------------------------------------------------------------------
diff --git a/depends/libyarn/test/unit/TestRecords/TestContainerLaunchContext.cpp b/depends/libyarn/test/unit/TestRecords/TestContainerLaunchContext.cpp
new file mode 100644
index 0000000..98138df
--- /dev/null
+++ b/depends/libyarn/test/unit/TestRecords/TestContainerLaunchContext.cpp
@@ -0,0 +1,124 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+#include <list>
+#include <string>
+
+#include "gtest/gtest.h"
+#include "gmock/gmock.h"
+
+#include "records/ContainerLaunchContext.h"
+
+using std::list;
+using std::string;
+using namespace libyarn;
+using namespace testing;
+
+class TestContainerLaunchContext: public ::testing::Test {
+protected:
+ ContainerLaunchContext containerContext;
+};
+
+TEST_F(TestContainerLaunchContext, TestGetLocalResources)
+{
+ list<StringLocalResourceMap> maps;
+ list<StringLocalResourceMap> retMaps;
+ StringLocalResourceMap map;
+ maps.push_back(map);
+
+ containerContext.setLocalResources(maps);
+ retMaps = containerContext.getLocalResources();
+
+ /* The operator '==' is not defined for class StringLocalResrouceMap,
+ so we can't compare list and retMaps here. */
+
+ SUCCEED();
+}
+
+TEST_F(TestContainerLaunchContext, TestGetServiceData)
+{
+ list<StringBytesMap> maps;
+ list<StringBytesMap> retMaps;
+ StringBytesMap map;
+ maps.push_back(map);
+
+ containerContext.setServiceData(maps);
+ retMaps = containerContext.getServiceData();
+
+ /* The operator '==' is not defined for class StringBytesMap,
+ so we can't compare list and retMaps here. */
+
+ SUCCEED();
+}
+
+TEST_F(TestContainerLaunchContext, TestGetEnvironment)
+{
+ list<StringStringMap> maps;
+ list<StringStringMap> retMaps;
+ StringStringMap map;
+ maps.push_back(map);
+
+ containerContext.setEnvironment(maps);
+ retMaps = containerContext.getEnvironment();
+
+ /* The operator '==' is not defined for class StringStringMap,
+ so we can't compare list and retMaps here. */
+
+ SUCCEED();
+}
+
+TEST_F(TestContainerLaunchContext, TestGetApplicationACLs)
+{
+ list<ApplicationACLMap> maps;
+ list<ApplicationACLMap> retMaps;
+ ApplicationACLMap map;
+ maps.push_back(map);
+
+ containerContext.setApplicationACLs(maps);
+ retMaps = containerContext.getApplicationACLs();
+
+ /* The operator '==' is not defined for class ApplicationACLMap,
+ so we can't compare list and retMaps here. */
+
+ SUCCEED();
+}
+
+TEST_F(TestContainerLaunchContext, TestGetTokens)
+{
+ string tokens("tokens");
+ string retTokens;
+
+ containerContext.setTokens(tokens);
+ retTokens = containerContext.getTokens();
+
+ EXPECT_EQ(tokens, retTokens);
+}
+
+TEST_F(TestContainerLaunchContext, TestGetCommand)
+{
+ list<string> commands;
+ list<string> retCommands;
+ string command("command");
+ commands.push_back(command);
+
+ containerContext.setCommand(commands);
+ retCommands = containerContext.getCommand();
+
+ EXPECT_EQ(commands, retCommands);
+}
http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/383818c2/depends/libyarn/test/unit/TestRecords/TestContainerReport.cpp
----------------------------------------------------------------------
diff --git a/depends/libyarn/test/unit/TestRecords/TestContainerReport.cpp b/depends/libyarn/test/unit/TestRecords/TestContainerReport.cpp
new file mode 100644
index 0000000..419afa6
--- /dev/null
+++ b/depends/libyarn/test/unit/TestRecords/TestContainerReport.cpp
@@ -0,0 +1,114 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+#include <string>
+
+#include "gtest/gtest.h"
+#include "gmock/gmock.h"
+
+#include "records/ContainerReport.h"
+
+using std::string;
+using namespace libyarn;
+using namespace testing;
+
+class TestContainerReport: public ::testing::Test {
+protected:
+ ContainerReport containerReport;
+};
+
+TEST_F(TestContainerReport, TestGetNodeId)
+{
+ NodeId id;
+ NodeId retId;
+
+ containerReport.setNodeId(id);
+ retId = containerReport.getNodeId();
+
+ /* The operator '==' is not defined for class StringLocalResrouceMap,
+ so we can't compare list and retMap here. */
+
+ SUCCEED();
+}
+
+TEST_F(TestContainerReport, TestGetCreationTime)
+{
+ int64_t time = -1;
+ int64_t retTime;
+
+ containerReport.setCreationTime(time);
+ retTime = containerReport.getCreationTime();
+
+ EXPECT_EQ(time, retTime);
+}
+
+TEST_F(TestContainerReport, TestGetFinishTime)
+{
+ int64_t time = -1;
+ int64_t retTime;
+
+ containerReport.setFinishTime(time);
+ retTime = containerReport.getFinishTime();
+
+ EXPECT_EQ(time, retTime);
+}
+
+TEST_F(TestContainerReport, TestGetContainerExitStatus)
+{
+ ContainerExitStatus status = ContainerExitStatus::ABORTED;
+ ContainerExitStatus retStatus;
+
+ containerReport.setContainerExitStatus(status);
+ retStatus = containerReport.getContainerExitStatus();
+
+ EXPECT_EQ(status, retStatus);
+}
+
+TEST_F(TestContainerReport, TestGetContainerState)
+{
+ ContainerState state = ContainerState::C_NEW;
+ ContainerState retState;
+
+ containerReport.setContainerState(state);
+ retState = containerReport.getContainerState();
+
+ EXPECT_EQ(state, retState);
+}
+
+TEST_F(TestContainerReport, TestGetDiagnostics)
+{
+ string diagnostics("diagnostics");
+ string retDiagnostics;
+
+ containerReport.setDiagnostics(diagnostics);
+ retDiagnostics = containerReport.getDiagnostics();
+
+ EXPECT_EQ(diagnostics, retDiagnostics);
+}
+
+TEST_F(TestContainerReport, TestGetLogUrl)
+{
+ string url("url");
+ string retUrl;
+
+ containerReport.setLogUrl(url);
+ retUrl = containerReport.getLogUrl();
+
+ EXPECT_EQ(url, retUrl);
+}
http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/383818c2/depends/libyarn/test/unit/TestRecords/TestLocalResource.cpp
----------------------------------------------------------------------
diff --git a/depends/libyarn/test/unit/TestRecords/TestLocalResource.cpp b/depends/libyarn/test/unit/TestRecords/TestLocalResource.cpp
new file mode 100644
index 0000000..2ec942d
--- /dev/null
+++ b/depends/libyarn/test/unit/TestRecords/TestLocalResource.cpp
@@ -0,0 +1,119 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+#include <string>
+
+#include "gtest/gtest.h"
+#include "gmock/gmock.h"
+
+#include "records/LocalResource.h"
+
+using std::string;
+using namespace libyarn;
+using namespace testing;
+
+class TestLocalResource: public ::testing::Test {
+protected:
+ LocalResource localResource;
+};
+
+TEST_F(TestLocalResource, TestLocalResource)
+{
+ LocalResourceProto proto;
+ localResource = LocalResource(proto);
+
+ SUCCEED();
+}
+
+TEST_F(TestLocalResource, TestLocalGetProto)
+{
+ LocalResourceProto proto;
+ proto = localResource.getProto();
+
+ SUCCEED();
+}
+
+TEST_F(TestLocalResource, TestGetResource)
+{
+ URL resource;
+ URL retResource;
+
+ localResource.setResource(resource);
+ retResource = localResource.getResource();
+
+ /* The operator '==' is not defined for class URL,
+ so we can't compare resource and retResource here. */
+
+ SUCCEED();
+}
+
+TEST_F(TestLocalResource, TestGetSize)
+{
+ long size = -1;
+ long retSize;
+
+ localResource.setSize(size);
+ retSize = localResource.getSize();
+
+ EXPECT_EQ(size, retSize);
+}
+
+TEST_F(TestLocalResource, TestGetTimeStamp)
+{
+ long timestamp = -1;
+ long retTimestamp;
+
+ localResource.setTimestamp(timestamp);
+ retTimestamp = localResource.getTimestamp();
+
+ EXPECT_EQ(timestamp, retTimestamp);
+}
+
+TEST_F(TestLocalResource, TestGetLocalResourceType)
+{
+ LocalResourceType type = LocalResourceType::ARCHIVE;
+ LocalResourceType retType;
+
+ localResource.setType(type);
+ retType = localResource.getType();
+
+ EXPECT_EQ(type, retType);
+}
+
+TEST_F(TestLocalResource, TestGetLocalResourceVisibility)
+{
+ LocalResourceVisibility visibility = LocalResourceVisibility::PUBLIC;
+ LocalResourceVisibility retVisibility;
+
+ localResource.setVisibility(visibility);
+ retVisibility = localResource.getVisibility();
+
+ EXPECT_EQ(visibility, retVisibility);
+}
+
+TEST_F(TestLocalResource, TestGetPattern)
+{
+ string pattern("pattern");
+ string retPattern;
+
+ localResource.setPattern(pattern);
+ retPattern = localResource.getPattern();
+
+ EXPECT_EQ(pattern, retPattern);
+}
http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/383818c2/depends/libyarn/test/unit/TestRecords/TestNodeReport.cpp
----------------------------------------------------------------------
diff --git a/depends/libyarn/test/unit/TestRecords/TestNodeReport.cpp b/depends/libyarn/test/unit/TestRecords/TestNodeReport.cpp
new file mode 100644
index 0000000..d172490
--- /dev/null
+++ b/depends/libyarn/test/unit/TestRecords/TestNodeReport.cpp
@@ -0,0 +1,81 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+#include <string>
+
+#include "gtest/gtest.h"
+#include "gmock/gmock.h"
+
+#include "records/NodeReport.h"
+
+using std::string;
+using namespace libyarn;
+using namespace testing;
+
+class TestNodeReport: public ::testing::Test {
+protected:
+ NodeReport nodeReport;
+};
+
+TEST_F(TestNodeReport, TestGetHttpAddress)
+{
+ string address("address");
+ string retAddress;
+
+ nodeReport.setHttpAddress(address);
+ retAddress = nodeReport.getHttpAddress();
+
+ EXPECT_EQ(address, retAddress);
+}
+
+TEST_F(TestNodeReport, TestGetUsedResource)
+{
+ Resource resource;
+ Resource retResource;
+
+ nodeReport.setUsedResource(resource);
+ retResource = nodeReport.getUsedResource();
+
+ /* The operator '==' is not defined for class Resource,
+ so we can't compare resource and retResource here. */
+
+ SUCCEED();
+}
+
+TEST_F(TestNodeReport, TestGetHealthReport)
+{
+ string report("report");
+ string retReport;
+
+ nodeReport.setHealthReport(report);
+ retReport = nodeReport.getHealthReport();
+
+ EXPECT_EQ(report, retReport);
+}
+
+TEST_F(TestNodeReport, TestGetLastHealthReportTime)
+{
+ int64_t time = -1;
+ int64_t retTime;
+
+ nodeReport.setLastHealthReportTime(time);
+ retTime = nodeReport.getLastHealthReportTime();
+
+ EXPECT_EQ(time, retTime);
+}
http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/383818c2/depends/libyarn/test/unit/TestRecords/TestPreemptionContainer.cpp
----------------------------------------------------------------------
diff --git a/depends/libyarn/test/unit/TestRecords/TestPreemptionContainer.cpp b/depends/libyarn/test/unit/TestRecords/TestPreemptionContainer.cpp
new file mode 100644
index 0000000..92b7281
--- /dev/null
+++ b/depends/libyarn/test/unit/TestRecords/TestPreemptionContainer.cpp
@@ -0,0 +1,82 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+#include "gtest/gtest.h"
+#include "gmock/gmock.h"
+
+#include "records/PreemptionContainer.h"
+
+using namespace libyarn;
+using namespace testing;
+
+class TestPreemptionContainer: public ::testing::Test {
+protected:
+ PreemptionContainer preemptionContainer;
+};
+
+TEST_F(TestPreemptionContainer, TestPreemptionContainer)
+{
+ PreemptionContainerProto proto;
+ preemptionContainer = PreemptionContainer(proto);
+
+ SUCCEED();
+}
+
+TEST_F(TestPreemptionContainer, TestLocalGetProto)
+{
+ PreemptionContainerProto proto;
+ proto = preemptionContainer.getProto();
+
+ SUCCEED();
+}
+
+TEST_F(TestPreemptionContainer, TestGetContainerId)
+{
+ ContainerId id;
+ ContainerId retId;
+
+ preemptionContainer.setId(id);
+ retId = preemptionContainer.getId();
+
+ /* The operator '==' is not defined for class ContainerId,
+ so we can't compare id and retId here. */
+
+ SUCCEED();
+}
+
+TEST_F(TestPreemptionContainer, TestOperatorLessThan)
+{
+ int32_t id = -1;
+ ApplicationId appId;
+ appId.setId(id);
+ ContainerId containerId;
+ containerId.setApplicationId(appId);
+ preemptionContainer.setId(containerId);
+
+ int32_t id2 = 1;
+ ApplicationId appId2;
+ appId2.setId(id2);
+ ContainerId containerId2;
+ containerId2.setApplicationId(appId2);
+ PreemptionContainer preemptionContainer2;
+ preemptionContainer2.setId(containerId2);
+
+ EXPECT_TRUE(preemptionContainer < preemptionContainer2);
+ EXPECT_FALSE(preemptionContainer2 < preemptionContainer);
+}
http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/383818c2/depends/libyarn/test/unit/TestRecords/TestPreemptionContract.cpp
----------------------------------------------------------------------
diff --git a/depends/libyarn/test/unit/TestRecords/TestPreemptionContract.cpp b/depends/libyarn/test/unit/TestRecords/TestPreemptionContract.cpp
new file mode 100644
index 0000000..64690f8
--- /dev/null
+++ b/depends/libyarn/test/unit/TestRecords/TestPreemptionContract.cpp
@@ -0,0 +1,84 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+#include <list>
+#include <set>
+
+#include "gtest/gtest.h"
+#include "gmock/gmock.h"
+
+#include "records/PreemptionContract.h"
+
+using std::list;
+using std::set;
+using namespace libyarn;
+using namespace testing;
+
+class TestPreemptionContract: public ::testing::Test {
+protected:
+ PreemptionContract preemptionContract;
+};
+
+TEST_F(TestPreemptionContract, TestPreemptionContract)
+{
+ PreemptionContractProto proto;
+ preemptionContract = PreemptionContract(proto);
+
+ SUCCEED();
+}
+
+TEST_F(TestPreemptionContract, TestLocalGetProto)
+{
+ PreemptionContractProto proto;
+ proto = preemptionContract.getProto();
+
+ SUCCEED();
+}
+
+TEST_F(TestPreemptionContract, TestGetContainers)
+{
+ set<PreemptionContainer> containers;
+ set<PreemptionContainer> retContainers;
+ PreemptionContainer container;
+ containers.insert(container);
+
+ preemptionContract.setContainers(containers);
+ retContainers = preemptionContract.getContainers();
+
+ /* The operator '==' is not defined for class PreemptionContainer,
+ so we can't compare containers and retContainers here. */
+
+ SUCCEED();
+}
+
+TEST_F(TestPreemptionContract, TestGetResourceRequest)
+{
+ list<PreemptionResourceRequest> requests;
+ list<PreemptionResourceRequest> retRequests;
+ PreemptionResourceRequest request;
+ requests.push_back(request);
+
+ preemptionContract.setResourceRequest(requests);
+ retRequests = preemptionContract.getResourceRequest();
+
+ /* The operator '==' is not defined for class PreemptionContainer,
+ so we can't compare containers and retContainers here. */
+
+ SUCCEED();
+}
http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/383818c2/depends/libyarn/test/unit/TestRecords/TestPreemptionMessage.cpp
----------------------------------------------------------------------
diff --git a/depends/libyarn/test/unit/TestRecords/TestPreemptionMessage.cpp b/depends/libyarn/test/unit/TestRecords/TestPreemptionMessage.cpp
new file mode 100644
index 0000000..d9b0575
--- /dev/null
+++ b/depends/libyarn/test/unit/TestRecords/TestPreemptionMessage.cpp
@@ -0,0 +1,75 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+#include "gtest/gtest.h"
+#include "gmock/gmock.h"
+
+#include "records/PreemptionMessage.h"
+
+using namespace libyarn;
+using namespace testing;
+
+class TestPreemptionMessage: public ::testing::Test {
+protected:
+ PreemptionMessage preemptionMessage;
+};
+
+TEST_F(TestPreemptionMessage, TestPreemptionMessage)
+{
+ PreemptionMessageProto proto;
+ preemptionMessage = PreemptionMessage(proto);
+
+ SUCCEED();
+}
+
+TEST_F(TestPreemptionMessage, TestLocalGetProto)
+{
+ PreemptionMessageProto proto;
+ proto = preemptionMessage.getProto();
+
+ SUCCEED();
+}
+
+TEST_F(TestPreemptionMessage, TestGetStrictContract)
+{
+ StrictPreemptionContract contract;
+ StrictPreemptionContract retContract;
+
+ preemptionMessage.setStrictContract(contract);
+ retContract = preemptionMessage.getStrictContract();
+
+ /* The operator '==' is not defined for class StricPreemptionContract,
+ so we can't compare contract and retContract here. */
+
+ SUCCEED();
+}
+
+TEST_F(TestPreemptionMessage, TestGetContract)
+{
+ PreemptionContract contract;
+ PreemptionContract retContract;
+
+ preemptionMessage.setContract(contract);
+ retContract = preemptionMessage.getContract();
+
+ /* The operator '==' is not defined for class PreemptionContract,
+ so we can't compare contract and retContract here. */
+
+ SUCCEED();
+}
http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/383818c2/depends/libyarn/test/unit/TestRecords/TestPreemptionResourceRequest.cpp
----------------------------------------------------------------------
diff --git a/depends/libyarn/test/unit/TestRecords/TestPreemptionResourceRequest.cpp b/depends/libyarn/test/unit/TestRecords/TestPreemptionResourceRequest.cpp
new file mode 100644
index 0000000..afd1d6e
--- /dev/null
+++ b/depends/libyarn/test/unit/TestRecords/TestPreemptionResourceRequest.cpp
@@ -0,0 +1,45 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+#include "gtest/gtest.h"
+#include "gmock/gmock.h"
+
+#include "records/PreemptionResourceRequest.h"
+
+using namespace libyarn;
+using namespace testing;
+
+class TestPreemptionResourceRequest: public ::testing::Test {
+protected:
+ PreemptionResourceRequest preemptionRequest;
+};
+
+TEST_F(TestPreemptionResourceRequest, TestGetResourceRequest)
+{
+ ResourceRequest request;
+ ResourceRequest retRequest;
+
+ preemptionRequest.setResourceRequest(request);
+ retRequest = preemptionRequest.getResourceRequest();
+
+ /* The operator '==' is not defined for class ResourceRequest,
+ so we can't compare request and retRequest here. */
+
+ SUCCEED();
+}
http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/383818c2/depends/libyarn/test/unit/TestRecords/TestResourceBlacklistRequest.cpp
----------------------------------------------------------------------
diff --git a/depends/libyarn/test/unit/TestRecords/TestResourceBlacklistRequest.cpp b/depends/libyarn/test/unit/TestRecords/TestResourceBlacklistRequest.cpp
new file mode 100644
index 0000000..d39144b
--- /dev/null
+++ b/depends/libyarn/test/unit/TestRecords/TestResourceBlacklistRequest.cpp
@@ -0,0 +1,88 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+#include <list>
+#include <string>
+
+#include "gtest/gtest.h"
+#include "gmock/gmock.h"
+
+#include "records/ResourceBlacklistRequest.h"
+
+using std::list;
+using std::string;
+using namespace libyarn;
+using namespace testing;
+
+class TestResourceBlacklistRequest: public ::testing::Test {
+protected:
+ ResourceBlacklistRequest blacklistRequest;
+};
+
+TEST_F(TestResourceBlacklistRequest, TestSetBlacklistAdditions)
+{
+ list<string> additions;
+ list<string> retAdditions;
+ string addition("addition");
+ additions.push_back(addition);
+
+ blacklistRequest.setBlacklistAdditions(additions);
+ retAdditions = blacklistRequest.getBlacklistAdditions();
+
+ EXPECT_EQ(additions, retAdditions);
+}
+
+TEST_F(TestResourceBlacklistRequest, TestAddBlacklistAdditions)
+{
+ list<string> additions;
+ list<string> retAdditions;
+ string addition("addition");
+ additions.push_back(addition);
+
+ blacklistRequest.addBlacklistAddition(addition);
+ retAdditions = blacklistRequest.getBlacklistAdditions();
+
+ EXPECT_EQ(additions, retAdditions);
+}
+
+TEST_F(TestResourceBlacklistRequest, TestSetBlacklistRemovals)
+{
+ list<string> removals;
+ list<string> retRemovals;
+ string removal("removal");
+ removals.push_back(removal);
+
+ blacklistRequest.setBlacklistRemovals(removals);
+ retRemovals = blacklistRequest.getBlacklistRemovals();
+
+ EXPECT_EQ(removals, retRemovals);
+}
+
+TEST_F(TestResourceBlacklistRequest, TestAddBlacklistRemovals)
+{
+ list<string> removals;
+ list<string> retRemovals;
+ string removal("removal");
+ removals.push_back(removal);
+
+ blacklistRequest.addBlacklistRemoval(removal);
+ retRemovals = blacklistRequest.getBlacklistRemovals();
+
+ EXPECT_EQ(removals, retRemovals);
+}
http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/383818c2/depends/libyarn/test/unit/TestRecords/TestSerializedException.cpp
----------------------------------------------------------------------
diff --git a/depends/libyarn/test/unit/TestRecords/TestSerializedException.cpp b/depends/libyarn/test/unit/TestRecords/TestSerializedException.cpp
new file mode 100644
index 0000000..248ed07
--- /dev/null
+++ b/depends/libyarn/test/unit/TestRecords/TestSerializedException.cpp
@@ -0,0 +1,81 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+#include <string>
+
+#include "gtest/gtest.h"
+#include "gmock/gmock.h"
+
+#include "records/SerializedException.h"
+
+using std::string;
+using namespace libyarn;
+using namespace testing;
+
+class TestSerializedException: public ::testing::Test {
+protected:
+ SerializedException serializedException;
+};
+
+TEST_F(TestSerializedException, TestGetMessage)
+{
+ string message("message");
+ string retMessage;
+
+ serializedException.setMessage(message);
+ retMessage = serializedException.getMessage();
+
+ EXPECT_EQ(message, retMessage);
+}
+
+TEST_F(TestSerializedException, TestGetTrace)
+{
+ string trace("trace");
+ string retTrace;
+
+ serializedException.setTrace(trace);
+ retTrace = serializedException.getTrace();
+
+ EXPECT_EQ(trace, retTrace);
+}
+
+TEST_F(TestSerializedException, TestGetClassName)
+{
+ string className("className");
+ string retClassName;
+
+ serializedException.setClassName(className);
+ retClassName = serializedException.getClassName();
+
+ EXPECT_EQ(className, retClassName);
+}
+
+TEST_F(TestSerializedException, TestGetCause)
+{
+ SerializedException cause;
+ SerializedException retCause;
+
+ serializedException.setCause(cause);
+ retCause = serializedException.getCause();
+
+ /* The operator '==' is not defined for class SerializedException,
+ so we can't compare cause and retCause here. */
+
+ SUCCEED();
+}
http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/383818c2/depends/libyarn/test/unit/TestRecords/TestStrictPreemptionContract.cpp
----------------------------------------------------------------------
diff --git a/depends/libyarn/test/unit/TestRecords/TestStrictPreemptionContract.cpp b/depends/libyarn/test/unit/TestRecords/TestStrictPreemptionContract.cpp
new file mode 100644
index 0000000..ea02b28
--- /dev/null
+++ b/depends/libyarn/test/unit/TestRecords/TestStrictPreemptionContract.cpp
@@ -0,0 +1,50 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+#include <set>
+
+#include "gtest/gtest.h"
+#include "gmock/gmock.h"
+
+#include "records/StrictPreemptionContract.h"
+
+using std::set;
+using namespace libyarn;
+using namespace testing;
+
+class TestStrictPreemptionContract: public ::testing::Test {
+protected:
+ StrictPreemptionContract strictContract;
+};
+
+TEST_F(TestStrictPreemptionContract, TestGetContainers)
+{
+ set<PreemptionContainer> containers;
+ set<PreemptionContainer> retContainers;
+ PreemptionContainer container;
+ containers.insert(container);
+
+ strictContract.setContainers(containers);
+ retContainers = strictContract.getContainers();
+
+ /* The operator '==' is not defined for class PreemptionContainer,
+ so we can't compare containers and retContainers here. */
+
+ SUCCEED();
+}
http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/383818c2/depends/libyarn/test/unit/TestRecords/TestStringBytesMap.cpp
----------------------------------------------------------------------
diff --git a/depends/libyarn/test/unit/TestRecords/TestStringBytesMap.cpp b/depends/libyarn/test/unit/TestRecords/TestStringBytesMap.cpp
new file mode 100644
index 0000000..a450de8
--- /dev/null
+++ b/depends/libyarn/test/unit/TestRecords/TestStringBytesMap.cpp
@@ -0,0 +1,56 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+#include <string>
+
+#include "gtest/gtest.h"
+#include "gmock/gmock.h"
+
+#include "records/StringBytesMap.h"
+
+using std::string;
+using namespace libyarn;
+using namespace testing;
+
+class TestStringBytesMap: public ::testing::Test {
+protected:
+ StringBytesMap stringMap;
+};
+
+TEST_F(TestStringBytesMap, TestGetKey)
+{
+ string key("key");
+ string retKey;
+
+ stringMap.setKey(key);
+ retKey = stringMap.getKey();
+
+ EXPECT_EQ(key, retKey);
+}
+
+TEST_F(TestStringBytesMap, TestGetValue)
+{
+ string value("value");
+ string retValue;
+
+ stringMap.setValue(value);
+ retValue = stringMap.getValue();
+
+ EXPECT_EQ(value, retValue);
+}
http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/383818c2/depends/libyarn/test/unit/TestRecords/TestStringLocalResourceMap.cpp
----------------------------------------------------------------------
diff --git a/depends/libyarn/test/unit/TestRecords/TestStringLocalResourceMap.cpp b/depends/libyarn/test/unit/TestRecords/TestStringLocalResourceMap.cpp
new file mode 100644
index 0000000..40d4a96
--- /dev/null
+++ b/depends/libyarn/test/unit/TestRecords/TestStringLocalResourceMap.cpp
@@ -0,0 +1,59 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+#include <string>
+
+#include "gtest/gtest.h"
+#include "gmock/gmock.h"
+
+#include "records/StringLocalResourceMap.h"
+
+using std::string;
+using namespace libyarn;
+using namespace testing;
+
+class TestStringLocalResourceMap: public ::testing::Test {
+protected:
+ StringLocalResourceMap stringMap;
+};
+
+TEST_F(TestStringLocalResourceMap, TestGetKey)
+{
+ string key("key");
+ string retKey;
+
+ stringMap.setKey(key);
+ retKey = stringMap.getKey();
+
+ EXPECT_EQ(key, retKey);
+}
+
+TEST_F(TestStringLocalResourceMap, TestGetLocalResource)
+{
+ LocalResource resource;
+ LocalResource retResource;
+
+ stringMap.setLocalResource(resource);
+ retResource = stringMap.getLocalResource();
+
+ /* The operator '==' is not defined for class LocalResource,
+ so we can't compare resource and retResource here. */
+
+ SUCCEED();
+}
http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/383818c2/depends/libyarn/test/unit/TestRecords/TestStringStringMap.cpp
----------------------------------------------------------------------
diff --git a/depends/libyarn/test/unit/TestRecords/TestStringStringMap.cpp b/depends/libyarn/test/unit/TestRecords/TestStringStringMap.cpp
new file mode 100644
index 0000000..0e7f2c9
--- /dev/null
+++ b/depends/libyarn/test/unit/TestRecords/TestStringStringMap.cpp
@@ -0,0 +1,56 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+#include <string>
+
+#include "gtest/gtest.h"
+#include "gmock/gmock.h"
+
+#include "records/StringStringMap.h"
+
+using std::string;
+using namespace libyarn;
+using namespace testing;
+
+class TestStringStringMap: public ::testing::Test {
+protected:
+ StringStringMap stringMap;
+};
+
+TEST_F(TestStringStringMap, TestGetKey)
+{
+ string key("key");
+ string retKey;
+
+ stringMap.setKey(key);
+ retKey = stringMap.getKey();
+
+ EXPECT_EQ(key, retKey);
+}
+
+TEST_F(TestStringStringMap, TestGetValue)
+{
+ string value("value");
+ string retValue;
+
+ stringMap.setValue(value);
+ retValue = stringMap.getValue();
+
+ EXPECT_EQ(value, retValue);
+}
http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/383818c2/depends/libyarn/test/unit/TestRecords/TestURL.cpp
----------------------------------------------------------------------
diff --git a/depends/libyarn/test/unit/TestRecords/TestURL.cpp b/depends/libyarn/test/unit/TestRecords/TestURL.cpp
new file mode 100644
index 0000000..cd7814e
--- /dev/null
+++ b/depends/libyarn/test/unit/TestRecords/TestURL.cpp
@@ -0,0 +1,89 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+#include <string>
+
+#include "gtest/gtest.h"
+#include "gmock/gmock.h"
+
+#include "records/URL.h"
+
+using std::string;
+using namespace libyarn;
+using namespace testing;
+
+class TestURL: public ::testing::Test {
+protected:
+ URL url;
+};
+
+TEST_F(TestURL, TestGetScheme)
+{
+ string scheme("scheme");
+ string retScheme;
+
+ url.setScheme(scheme);
+ retScheme = url.getScheme();
+
+ EXPECT_EQ(scheme, retScheme);
+}
+
+TEST_F(TestURL, TestGetHost)
+{
+ string host("host");
+ string retHost;
+
+ url.setHost(host);
+ retHost = url.getHost();
+
+ EXPECT_EQ(host, retHost);
+}
+
+TEST_F(TestURL, TestGetPort)
+{
+ int32_t port = -1;
+ int32_t retPort;
+
+ url.setPort(port);
+ retPort = url.getPort();
+
+ EXPECT_EQ(port, retPort);
+}
+
+TEST_F(TestURL, TestGetFile)
+{
+ string file("file");
+ string retFile;
+
+ url.setFile(file);
+ retFile = url.getFile();
+
+ EXPECT_EQ(file, retFile);
+}
+
+TEST_F(TestURL, TestGetUserInfo)
+{
+ string userInfo("userInfo");
+ string retUserInfo;
+
+ url.setUserInfo(userInfo);
+ retUserInfo = url.getUserInfo();
+
+ EXPECT_EQ(userInfo, retUserInfo);
+}
[3/5] incubator-hawq git commit: HAWQ-891. Refine libyarn codes
Posted by wl...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/383818c2/depends/libyarn/test/unit/TestLibYarnClient/TestLibYarnClient.cpp
----------------------------------------------------------------------
diff --git a/depends/libyarn/test/unit/TestLibYarnClient/TestLibYarnClient.cpp b/depends/libyarn/test/unit/TestLibYarnClient/TestLibYarnClient.cpp
new file mode 100644
index 0000000..443813c
--- /dev/null
+++ b/depends/libyarn/test/unit/TestLibYarnClient/TestLibYarnClient.cpp
@@ -0,0 +1,1085 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+#include <list>
+#include <map>
+#include <set>
+#include <string>
+
+#include "gtest/gtest.h"
+#include "gmock/gmock.h"
+//#include "Thread.h"
+
+#include "libyarnclient/LibYarnClient.h"
+#include "MockApplicationMaster.h"
+#include "MockApplicationClient.h"
+#include "MockContainerManagement.h"
+#include "TestLibYarnClientStub.h"
+
+using std::string;
+using std::list;
+using std::set;
+using std::map;
+using std::pair;
+using namespace libyarn;
+using namespace testing;
+using namespace Mock;
+
+class MockLibYarnClientStub: public TestLibYarnClientStub {
+public:
+ ~MockLibYarnClientStub(){
+ }
+ MOCK_METHOD0(getApplicationClient, ApplicationClient* ());
+ MOCK_METHOD0(getApplicationMaster, ApplicationMaster* ());
+ MOCK_METHOD0(getContainerManagement, ContainerManagement* ());
+};
+
+class TestLibYarnClient: public ::testing::Test {
+public:
+ TestLibYarnClient(){
+ amUser = "postgres";
+ rmHost = "localhost";
+ rmPort = "8032";
+ schedHost = "localhost";
+ schedPort = "8030";
+ amHost = "localhost";
+ amPort = 0;
+ am_tracking_url = "url";
+ heartbeatInterval = 1000;
+ tokenService = "";
+ user = Yarn::Internal::UserInfo::LocalUser();
+ }
+ ~TestLibYarnClient(){
+ }
+protected:
+ string amUser;
+ string rmHost;
+ string rmPort;
+ string schedHost;
+ string schedPort;
+ string amHost;
+ int32_t amPort;
+ string am_tracking_url;
+ int heartbeatInterval;
+ string tokenService;
+ Yarn::Internal::UserInfo user;
+};
+
+static ResourceRequest BuildRequest(int requestContainer) {
+ ResourceRequest resRequest;
+ string host("*");
+ resRequest.setResourceName(host);
+ Resource capability;
+ capability.setVirtualCores(1);
+ capability.setMemory(1024);
+ resRequest.setCapability(capability);
+ resRequest.setNumContainers(requestContainer);
+ resRequest.setRelaxLocality(true);
+ Priority priority;
+ priority.setPriority(1);
+ resRequest.setPriority(priority);
+ return resRequest;
+}
+
+static list<ContainerReport> BuildContainerReportList(int containerSize, int startPos = 0){
+ list<ContainerReport> containerReports;
+ for (int i = startPos; i < containerSize + startPos; i++) {
+ ContainerReport report;
+ ContainerId containerId;
+ containerId.setId(i+1);
+ report.setId(containerId);
+ containerReports.push_back(report);
+ }
+ return containerReports;
+}
+static AllocateResponse BuildAllocateResponse(int containerNumber, int startPos = 0){
+ AllocateResponse allocateResponse;
+ allocateResponse.setResponseId(10);
+ list<Container> containers;
+ for (int i=startPos;i<containerNumber+startPos;i++){
+ Container container;
+ ContainerId containerId;
+ containerId.setId(i+1);
+ container.setId(containerId);
+ containers.push_back(container);
+ }
+ list<NMToken> nmTokens;
+ for (int i=startPos;i<containerNumber+startPos;i++){
+ NMToken token;
+ nmTokens.push_back(token);
+ }
+ allocateResponse.setAllocatedContainers(containers);
+ allocateResponse.setNMTokens(nmTokens);
+ return allocateResponse;
+}
+
+static ApplicationReport BuildApplicationReport(string passwordStr,YarnApplicationState state){
+ ApplicationReport applicationReport;
+ libyarn::Token token;
+ string password(passwordStr);
+ token.setPassword(password);
+ applicationReport.setAMRMToken(token);
+ applicationReport.setYarnApplicationState(state);
+ return applicationReport;
+}
+
+static ApplicationId BuildApplicationId(int id){
+ ApplicationId appId;
+ appId.setId(id);
+ return appId;
+}
+
+static RegisterApplicationMasterResponse BuildRegisterResponse(){
+ RegisterApplicationMasterResponseProto responseProto;
+ return RegisterApplicationMasterResponse(responseProto);
+}
+
+static StartContainerResponse BuildStartContainerResponse(){
+ StartContainerResponseProto responseProto;
+ return StartContainerResponse(responseProto);
+}
+
+static ContainerStatus BuildContainerStatus(int id){
+ ContainerId containerId;
+ containerId.setId(id);
+ ContainerStatus containerStatus;
+ containerStatus.setContainerId(containerId);
+ return containerStatus;
+}
+
+static QueueInfo BuildQueueinfo(string queue,float capcity,int childNum){
+ QueueInfo queueInfo;
+ queueInfo.setQueueName(queue);
+ queueInfo.setCurrentCapacity(capcity);
+
+ list<QueueInfo> childQueues;
+ for (int i=0;i<childNum;i++){
+ QueueInfo childQueue;
+ string childName("child");
+ childQueue.setQueueName(childName);
+ childQueue.setCurrentCapacity(capcity);
+ childQueues.push_back(childQueue);
+ }
+ queueInfo.setChildQueues(childQueues);
+ return queueInfo;
+
+}
+
+TEST_F(TestLibYarnClient,TestCreateJob){
+ MockApplicationClient *appclient = new MockApplicationClient(amUser,rmHost,rmHost);
+ MockApplicationMaster *amrmclient = new MockApplicationMaster(schedHost,schedPort,user,tokenService);
+ MockContainerManagement *nmclient = new MockContainerManagement();
+ MockLibYarnClientStub stub;
+
+ EXPECT_CALL(*appclient, getNewApplication()).Times(AnyNumber()).WillOnce(Return(BuildApplicationId(1)));
+ EXPECT_CALL((*appclient),submitApplication(_)).Times(AnyNumber()).WillOnce(Return());
+ EXPECT_CALL((*appclient),getApplicationReport(_)).Times(AtLeast(3))
+ .WillOnce(Return(BuildApplicationReport("",YarnApplicationState::FAILED)))
+ .WillOnce(Return(BuildApplicationReport("",YarnApplicationState::ACCEPTED)))
+ .WillRepeatedly(Return(BuildApplicationReport("pass",YarnApplicationState::ACCEPTED)));
+ EXPECT_CALL((*appclient), getMethod()).Times(AnyNumber()).WillRepeatedly(Return(SIMPLE));
+
+ EXPECT_CALL((*amrmclient),registerApplicationMaster(_,_,_)).Times(AnyNumber()).WillRepeatedly(Return(BuildRegisterResponse()));
+ EXPECT_CALL((*amrmclient),allocate(_,_,_,_,_)).Times(AnyNumber()).WillRepeatedly(Return(BuildAllocateResponse(0)));
+
+ EXPECT_CALL(stub, getApplicationClient()).Times(AnyNumber()).WillOnce(Return(appclient));
+ EXPECT_CALL(stub, getApplicationMaster()).Times(AnyNumber()).WillOnce(Return(amrmclient));
+ EXPECT_CALL(stub, getContainerManagement()).Times(AnyNumber()).WillOnce(Return(nmclient));
+
+ LibYarnClient client(amUser, rmHost, rmPort, schedHost, schedPort, amHost, amPort, am_tracking_url,heartbeatInterval, &stub);
+ string jobName("libyarn");
+ string queue("default");
+ string jobId("");
+ int result = client.createJob(jobName,queue,jobId);
+ EXPECT_EQ(result, 0);
+ bool bool_result = client.isJobHealthy();
+ EXPECT_FALSE(bool_result);
+}
+
+TEST_F(TestLibYarnClient,TestCreateJobCanNotRegister){
+ MockApplicationClient *appclient = new MockApplicationClient(amUser,rmHost,rmHost);
+ MockApplicationMaster *amrmclient = new MockApplicationMaster(schedHost,schedPort,user,tokenService);
+ MockContainerManagement *nmclient = new MockContainerManagement();
+ MockLibYarnClientStub stub;
+
+ EXPECT_CALL(*appclient, getNewApplication()).Times(AnyNumber()).WillOnce(Return(BuildApplicationId(1)));
+ EXPECT_CALL((*appclient),submitApplication(_)).Times(AnyNumber()).WillOnce(Return());
+ EXPECT_CALL((*appclient),getApplicationReport(_)).Times(AnyNumber())
+ .WillRepeatedly(Return(BuildApplicationReport("",YarnApplicationState::FAILED)));
+
+ EXPECT_CALL(stub, getApplicationClient()).Times(AnyNumber()).WillOnce(Return(appclient));
+ EXPECT_CALL(stub, getApplicationMaster()).Times(AnyNumber()).WillOnce(Return(amrmclient));
+ EXPECT_CALL(stub, getContainerManagement()).Times(AnyNumber()).WillOnce(Return(nmclient));
+
+ LibYarnClient client(amUser, rmHost, rmPort, schedHost, schedPort, amHost, amPort, am_tracking_url,heartbeatInterval, &stub);
+ string jobName("libyarn");
+ string queue("default");
+ string jobId("");
+ int result = client.createJob(jobName, queue, jobId);
+ EXPECT_EQ(result, 1);
+}
+
+TEST_F(TestLibYarnClient,TestCreateJobException){
+ MockApplicationClient *appclient = new MockApplicationClient(amUser, rmHost,rmHost);
+ MockApplicationMaster *amrmclient = new MockApplicationMaster(schedHost,schedPort,user,tokenService);
+ MockContainerManagement *nmclient = new MockContainerManagement();
+ MockLibYarnClientStub stub;
+
+ EXPECT_CALL(*appclient, getNewApplication()).Times(AnyNumber()).WillOnce(Return(BuildApplicationId(1)));
+
+ EXPECT_CALL((*appclient),submitApplication(_)).Times(AnyNumber())
+ .WillOnce(Throw(YarnNetworkConnectException("", __FILE__, __LINE__, Yarn::Internal::PrintStack(1, STACK_DEPTH).c_str())));
+
+ EXPECT_CALL(stub, getApplicationClient()).Times(AnyNumber()).WillOnce(Return(appclient));
+ EXPECT_CALL(stub, getApplicationMaster()).Times(AnyNumber()).WillOnce(Return(amrmclient));
+ EXPECT_CALL(stub, getContainerManagement()).Times(AnyNumber()).WillOnce(Return(nmclient));
+
+ LibYarnClient client(amUser, rmHost, rmPort, schedHost, schedPort, amHost, amPort, am_tracking_url,heartbeatInterval,&stub);
+ string jobName("libyarn");
+ string queue("default");
+ string jobId("");
+ int result = client.createJob(jobName,queue,jobId);
+ EXPECT_EQ(result, 1);
+}
+
+TEST_F(TestLibYarnClient,TestCreateJobRepeatedCreate){
+ MockApplicationClient *appclient = new MockApplicationClient(amUser,rmHost,rmHost);
+ MockApplicationMaster *amrmclient = new MockApplicationMaster(schedHost,schedPort,user,tokenService);
+ MockContainerManagement *nmclient = new MockContainerManagement();
+ MockLibYarnClientStub stub;
+
+ EXPECT_CALL(*appclient, getNewApplication()).Times(AnyNumber()).WillOnce(Return(BuildApplicationId(1)));
+ EXPECT_CALL((*appclient),submitApplication(_)).Times(AnyNumber()).WillOnce(Return());
+ EXPECT_CALL((*appclient),getApplicationReport(_)).Times(AtLeast(3))
+ .WillOnce(Return(BuildApplicationReport("",YarnApplicationState::FAILED)))
+ .WillOnce(Return(BuildApplicationReport("",YarnApplicationState::ACCEPTED)))
+ .WillRepeatedly(Return(BuildApplicationReport("pass",YarnApplicationState::ACCEPTED)));
+ EXPECT_CALL((*appclient), getMethod()).Times(AnyNumber()).WillRepeatedly(Return(SIMPLE));
+
+ EXPECT_CALL((*amrmclient),registerApplicationMaster(_,_,_)).Times(AnyNumber()).WillRepeatedly(Return(BuildRegisterResponse()));
+ EXPECT_CALL((*amrmclient),allocate(_,_,_,_,_)).Times(AnyNumber()).WillRepeatedly(Return(BuildAllocateResponse(0)));
+
+ EXPECT_CALL(stub, getApplicationClient()).Times(AnyNumber()).WillOnce(Return(appclient));
+ EXPECT_CALL(stub, getApplicationMaster()).Times(AnyNumber()).WillOnce(Return(amrmclient));
+ EXPECT_CALL(stub, getContainerManagement()).Times(AnyNumber()).WillOnce(Return(nmclient));
+
+ LibYarnClient client(amUser, rmHost, rmPort, schedHost, schedPort, amHost, amPort, am_tracking_url,heartbeatInterval, &stub);
+ string jobName("libyarn");
+ string queue("default");
+ string jobId("");
+ int result = client.createJob(jobName, queue, jobId);
+ EXPECT_EQ(result, 0);
+ result = client.createJob(jobName, queue, jobId);
+ EXPECT_EQ(result, 1);
+}
+
+TEST_F(TestLibYarnClient,TestCreateJobWithUnknownMethod){
+ MockApplicationClient *appclient = new MockApplicationClient(amUser,rmHost,rmHost);
+ MockApplicationMaster *amrmclient = new MockApplicationMaster(schedHost,schedPort,user,tokenService);
+ MockContainerManagement *nmclient = new MockContainerManagement();
+ MockLibYarnClientStub stub;
+
+ EXPECT_CALL(*appclient, getNewApplication()).Times(AnyNumber()).WillOnce(Return(BuildApplicationId(1)));
+ EXPECT_CALL((*appclient),submitApplication(_)).Times(AnyNumber()).WillOnce(Return());
+ EXPECT_CALL((*appclient),getApplicationReport(_)).Times(AtLeast(3))
+ .WillOnce(Return(BuildApplicationReport("",YarnApplicationState::FAILED)))
+ .WillOnce(Return(BuildApplicationReport("",YarnApplicationState::ACCEPTED)))
+ .WillRepeatedly(Return(BuildApplicationReport("pass",YarnApplicationState::ACCEPTED)));
+ EXPECT_CALL((*appclient), getMethod()).Times(AtLeast(2)).WillRepeatedly(Return(UNKNOWN));
+
+ EXPECT_CALL((*amrmclient),registerApplicationMaster(_,_,_)).Times(AnyNumber()).WillRepeatedly(Return(BuildRegisterResponse()));
+ EXPECT_CALL((*amrmclient),allocate(_,_,_,_,_)).Times(AnyNumber()).WillRepeatedly(Return(BuildAllocateResponse(0)));
+
+ EXPECT_CALL(stub, getApplicationClient()).Times(AnyNumber()).WillOnce(Return(appclient));
+ EXPECT_CALL(stub, getApplicationMaster()).Times(AnyNumber()).WillOnce(Return(amrmclient));
+ EXPECT_CALL(stub, getContainerManagement()).Times(AnyNumber()).WillOnce(Return(nmclient));
+
+ LibYarnClient client(amUser, rmHost, rmPort, schedHost, schedPort, amHost, amPort, am_tracking_url,heartbeatInterval, &stub);
+ string jobName("libyarn");
+ string queue("default");
+ string jobId("");
+ int result = client.createJob(jobName,queue,jobId);
+ EXPECT_EQ(result, 0);
+}
+
+TEST_F(TestLibYarnClient,TestForceKillJob){
+ MockApplicationClient *appclient = new MockApplicationClient(amUser,rmHost,rmHost);
+ MockApplicationMaster *amrmclient = new MockApplicationMaster(schedHost,schedPort,user,tokenService);
+ MockContainerManagement *nmclient = new MockContainerManagement();
+ MockLibYarnClientStub stub;
+
+ EXPECT_CALL((*nmclient), stopContainer(_, _)).Times(AnyNumber()).WillRepeatedly(Return());
+
+ EXPECT_CALL(stub, getApplicationClient()).Times(AnyNumber()).WillOnce(Return(appclient));
+ EXPECT_CALL(stub, getApplicationMaster()).Times(AnyNumber()).WillOnce(Return(amrmclient));
+ EXPECT_CALL(stub, getContainerManagement()).Times(AnyNumber()).WillOnce(Return(nmclient));
+
+ EXPECT_CALL((*appclient), forceKillApplication(_)).Times(AnyNumber()).WillRepeatedly(Return());
+
+ LibYarnClient client(amUser, rmHost, rmPort, schedHost, schedPort, amHost, amPort, am_tracking_url,heartbeatInterval, &stub);
+ map<int64_t, Container *> jobIdContainers;
+ Container *container = new Container();
+ NodeId nodeId;
+ string rmHost("localhost");
+ int rmPort = 8030;
+ nodeId.setHost(rmHost);
+ nodeId.setPort(rmPort);
+ container->setNodeId(nodeId);
+ jobIdContainers.insert(pair<int64_t, Container *>(0, container));
+ client.jobIdContainers = jobIdContainers;
+
+ string jobName("libyarn");
+ string queue("default");
+ string jobId("");
+ int result = client.forceKillJob(jobId);
+ EXPECT_EQ(result, 0);
+}
+
+TEST_F(TestLibYarnClient,TestForceKillJobInvalidId){
+ MockApplicationClient *appclient = new MockApplicationClient(amUser,rmHost,rmHost);
+ MockApplicationMaster *amrmclient = new MockApplicationMaster(schedHost,schedPort,user,tokenService);
+ MockContainerManagement *nmclient = new MockContainerManagement();
+ MockLibYarnClientStub stub;
+
+ EXPECT_CALL(stub, getApplicationClient()).Times(AnyNumber()).WillOnce(Return(appclient));
+ EXPECT_CALL(stub, getApplicationMaster()).Times(AnyNumber()).WillOnce(Return(amrmclient));
+ EXPECT_CALL(stub, getContainerManagement()).Times(AnyNumber()).WillOnce(Return(nmclient));
+
+ LibYarnClient client(amUser, rmHost, rmPort, schedHost, schedPort, amHost, amPort, am_tracking_url,heartbeatInterval, &stub);
+ string jobId("InvalidId");
+ int result = client.forceKillJob(jobId);
+ EXPECT_EQ(result, 1);
+}
+
+TEST_F(TestLibYarnClient,TestDummyAllocate){
+ MockApplicationClient *appclient = new MockApplicationClient(amUser,rmHost,rmHost);
+ MockApplicationMaster *amrmclient = new MockApplicationMaster(schedHost,schedPort,user,tokenService);
+ MockContainerManagement *nmclient = new MockContainerManagement();
+ MockLibYarnClientStub stub;
+
+ EXPECT_CALL((*amrmclient),allocate(_,_,_,_,_)).Times(AnyNumber()).WillRepeatedly(Return(BuildAllocateResponse(5)));
+
+ EXPECT_CALL(stub, getApplicationClient()).Times(AnyNumber()).WillOnce(Return(appclient));
+ EXPECT_CALL(stub, getApplicationMaster()).Times(AnyNumber()).WillOnce(Return(amrmclient));
+ EXPECT_CALL(stub, getContainerManagement()).Times(AnyNumber()).WillOnce(Return(nmclient));
+
+ LibYarnClient client(amUser, rmHost, rmPort, schedHost, schedPort, amHost, amPort, am_tracking_url,heartbeatInterval,&stub);
+ client.dummyAllocate();
+
+ SUCCEED();
+}
+
+TEST_F(TestLibYarnClient,TestDummyAllocateException){
+ MockApplicationClient *appclient = new MockApplicationClient(amUser,rmHost,rmHost);
+ MockApplicationMaster *amrmclient = new MockApplicationMaster(schedHost,schedPort,user,tokenService);
+ MockContainerManagement *nmclient = new MockContainerManagement();
+ MockLibYarnClientStub stub;
+
+ EXPECT_CALL((*amrmclient),allocate(_,_,_,_,_)).Times(AnyNumber())
+ .WillRepeatedly(Throw(YarnIOException("", __FILE__, __LINE__, Yarn::Internal::PrintStack(1, STACK_DEPTH).c_str())));
+
+ EXPECT_CALL(stub, getApplicationClient()).Times(AnyNumber()).WillOnce(Return(appclient));
+ EXPECT_CALL(stub, getApplicationMaster()).Times(AnyNumber()).WillOnce(Return(amrmclient));
+ EXPECT_CALL(stub, getContainerManagement()).Times(AnyNumber()).WillOnce(Return(nmclient));
+
+ LibYarnClient client(amUser, rmHost, rmPort, schedHost, schedPort, amHost, amPort, am_tracking_url,heartbeatInterval,&stub);
+ EXPECT_THROW(client.dummyAllocate(), YarnException);
+}
+
+
+TEST_F(TestLibYarnClient,TestAddResourceRequest){
+ MockApplicationClient *appclient = new MockApplicationClient(amUser,rmHost,rmHost);
+ MockApplicationMaster *amrmclient = new MockApplicationMaster(schedHost,schedPort,user,tokenService);
+ MockContainerManagement *nmclient = new MockContainerManagement();
+ MockLibYarnClientStub stub;
+
+ EXPECT_CALL(stub, getApplicationClient()).Times(AnyNumber()).WillOnce(Return(appclient));
+ EXPECT_CALL(stub, getApplicationMaster()).Times(AnyNumber()).WillOnce(Return(amrmclient));
+ EXPECT_CALL(stub, getContainerManagement()).Times(AnyNumber()).WillOnce(Return(nmclient));
+
+ LibYarnClient client(amUser, rmHost, rmPort, schedHost, schedPort, amHost, amPort, am_tracking_url,heartbeatInterval,&stub);
+ Resource resource;
+ resource.setMemory(1024);
+ resource.setVirtualCores(1);
+ string host("master");
+ client.addResourceRequest(resource, 10, host, 1, true);
+ list<ResourceRequest> request = client.getAskRequests();
+ EXPECT_EQ(request.size(), 1);
+ list<ResourceRequest>::iterator it = request.begin();
+ EXPECT_EQ(it->getPriority().getPriority(), 1);
+ EXPECT_EQ(it->getNumContainers(), 10);
+ EXPECT_EQ(it->getRelaxLocality(), true);
+ EXPECT_EQ(it->getResourceName(), host);
+}
+
+TEST_F(TestLibYarnClient,TestAddContainerRequests) {
+ MockApplicationClient *appclient = new MockApplicationClient(amUser,rmHost,rmHost);
+ MockApplicationMaster *amrmclient = new MockApplicationMaster(schedHost,schedPort,user,tokenService);
+ MockContainerManagement *nmclient = new MockContainerManagement();
+ MockLibYarnClientStub stub;
+
+ EXPECT_CALL(stub, getApplicationClient()).Times(AnyNumber()).WillOnce(Return(appclient));
+ EXPECT_CALL(stub, getApplicationMaster()).Times(AnyNumber()).WillOnce(Return(amrmclient));
+ EXPECT_CALL(stub, getContainerManagement()).Times(AnyNumber()).WillOnce(Return(nmclient));
+
+ LibYarnClient client(amUser, rmHost, rmPort, schedHost, schedPort, amHost, amPort, am_tracking_url,heartbeatInterval,&stub);
+
+ string jobId("");
+ Resource resource;
+ resource.setMemory(1024);
+ resource.setVirtualCores(1);
+ list<struct LibYarnNodeInfo> preferred;
+ int ret = client.addContainerRequests(jobId, resource, 8, preferred, 1, true);
+ EXPECT_EQ(ret, 0);
+ list<ResourceRequest> request = client.getAskRequests();
+ list<ResourceRequest>::iterator it = request.begin();
+ EXPECT_EQ(it->getPriority().getPriority(), 1);
+ EXPECT_EQ(it->getNumContainers(), 8);
+ EXPECT_EQ(it->getRelaxLocality(), true);
+ EXPECT_EQ(it->getResourceName(), "*");
+ client.clearAskRequests();
+ EXPECT_EQ(client.getAskRequests().size(), 0);
+
+ /* test preferred hosts */
+ LibYarnNodeInfo info1("node1", "", 3);
+ LibYarnNodeInfo info2("node2", "", 2);
+ preferred.push_back(info1);
+ preferred.push_back(info2);
+ ret = client.addContainerRequests(jobId, resource, 8, preferred, 1, false);
+ request = client.getAskRequests();
+ for (it = request.begin(); it != request.end(); ++it) {
+ if (it->getResourceName() == info1.getHost()) {
+ EXPECT_EQ(it->getNumContainers(), 3);
+ EXPECT_EQ(it->getRelaxLocality(), true);
+ } else if (it->getResourceName() == info2.getHost()) {
+ EXPECT_EQ(it->getNumContainers(), 2);
+ EXPECT_EQ(it->getRelaxLocality(), true);
+ } else if (it->getResourceName() == string("/default-rack")) {
+ EXPECT_EQ(it->getNumContainers(), 5);
+ EXPECT_EQ(it->getRelaxLocality(), false);
+ } else if (it->getResourceName() == string("*")) {
+ EXPECT_EQ(it->getNumContainers(), 8);
+ EXPECT_EQ(it->getRelaxLocality(), false);
+ } else {
+ ASSERT_TRUE(false);
+ }
+ EXPECT_EQ(it->getCapability().getMemory(), 1024);
+ EXPECT_EQ(it->getCapability().getVirtualCores(), 1);
+ }
+}
+
+TEST_F(TestLibYarnClient,TestAddContainerRequestsInvalidId) {
+ MockApplicationClient *appclient = new MockApplicationClient(amUser,rmHost,rmHost);
+ MockApplicationMaster *amrmclient = new MockApplicationMaster(schedHost,schedPort,user,tokenService);
+ MockContainerManagement *nmclient = new MockContainerManagement();
+ MockLibYarnClientStub stub;
+
+ EXPECT_CALL(stub, getApplicationClient()).Times(AnyNumber()).WillOnce(Return(appclient));
+ EXPECT_CALL(stub, getApplicationMaster()).Times(AnyNumber()).WillOnce(Return(amrmclient));
+ EXPECT_CALL(stub, getContainerManagement()).Times(AnyNumber()).WillOnce(Return(nmclient));
+
+ LibYarnClient client(amUser, rmHost, rmPort, schedHost, schedPort, amHost, amPort, am_tracking_url,heartbeatInterval,&stub);
+
+ string jobId("InvalidId");
+ Resource resource;
+ resource.setMemory(1024);
+ resource.setVirtualCores(1);
+ list<struct LibYarnNodeInfo> preferred;
+ int ret = client.addContainerRequests(jobId, resource, 8, preferred, 1, true);
+ EXPECT_EQ(ret, 1);
+}
+
+TEST_F(TestLibYarnClient,TestAllocateResources){
+ MockApplicationClient *appclient = new MockApplicationClient(amUser,rmHost,rmHost);
+ MockApplicationMaster *amrmclient = new MockApplicationMaster(schedHost,schedPort,user,tokenService);
+ MockContainerManagement *nmclient = new MockContainerManagement();
+ MockLibYarnClientStub stub;
+
+ EXPECT_CALL((*amrmclient),allocate(_,_,_,_,_)).Times(4)
+ .WillOnce(Return(BuildAllocateResponse(5, 0)))
+ .WillOnce(Return(BuildAllocateResponse(0)))
+ .WillOnce(Return(BuildAllocateResponse(5, 2)))
+ .WillOnce(Return(BuildAllocateResponse(0)));
+ EXPECT_CALL((*appclient),getContainers(_)).Times(4)
+ .WillOnce(Return(BuildContainerReportList(0)))
+ .WillOnce(Return(BuildContainerReportList(5, 0)))
+ .WillOnce(Return(BuildContainerReportList(2, 0)))
+ .WillOnce(Return(BuildContainerReportList(7, 0)));
+
+ EXPECT_CALL(stub, getApplicationClient()).Times(AnyNumber()).WillOnce(Return(appclient));
+ EXPECT_CALL(stub, getApplicationMaster()).Times(AnyNumber()).WillOnce(Return(amrmclient));
+ EXPECT_CALL(stub, getContainerManagement()).Times(AnyNumber()).WillOnce(Return(nmclient));
+
+ LibYarnClient client(amUser, rmHost, rmPort, schedHost, schedPort, amHost, amPort, am_tracking_url,heartbeatInterval,&stub);
+
+ string jobId("");
+ list<string> blackListAdditions;
+ list<string> blackListRemovals;
+ list<Container> allocatedResourcesArray;
+ int result;
+
+ result = client.allocateResources(jobId, blackListAdditions, blackListRemovals,allocatedResourcesArray,2);
+ EXPECT_EQ(allocatedResourcesArray.size(), 2);
+ EXPECT_EQ(result,0);
+ result = client.allocateResources(jobId, blackListAdditions, blackListRemovals, allocatedResourcesArray, 2);
+ EXPECT_EQ(allocatedResourcesArray.size(), 2);
+ EXPECT_EQ(result,0);
+}
+
+TEST_F(TestLibYarnClient,TestAllocateResourcesInvalidId){
+ MockApplicationClient *appclient = new MockApplicationClient(amUser, rmHost,rmHost);
+ MockApplicationMaster *amrmclient = new MockApplicationMaster(schedHost,schedPort,user,tokenService);
+ MockContainerManagement *nmclient = new MockContainerManagement();
+ MockLibYarnClientStub stub;
+
+ EXPECT_CALL(stub, getApplicationClient()).Times(AnyNumber()).WillOnce(Return(appclient));
+ EXPECT_CALL(stub, getApplicationMaster()).Times(AnyNumber()).WillOnce(Return(amrmclient));
+ EXPECT_CALL(stub, getContainerManagement()).Times(AnyNumber()).WillOnce(Return(nmclient));
+
+ LibYarnClient client(amUser,rmHost, rmPort, schedHost, schedPort, amHost, amPort, am_tracking_url,heartbeatInterval,&stub);
+
+ string jobId("InvalidId");
+ list<string> blackListAdditions;
+ list<string> blackListRemovals;
+ list<Container> allocatedResourcesArray;
+ int result;
+ result = client.allocateResources(jobId, blackListAdditions, blackListRemovals, allocatedResourcesArray, 2);
+ EXPECT_EQ(result,1);
+}
+
+TEST_F(TestLibYarnClient,TestAllocateResourcesRetry){
+ MockApplicationClient *appclient = new MockApplicationClient(amUser, rmHost,rmHost);
+ MockApplicationMaster *amrmclient = new MockApplicationMaster(schedHost,schedPort,user,tokenService);
+ MockContainerManagement *nmclient = new MockContainerManagement();
+ MockLibYarnClientStub stub;
+
+ EXPECT_CALL((*appclient),getContainers(_)).Times(AnyNumber())
+ .WillRepeatedly(Return(BuildContainerReportList(0)));
+ EXPECT_CALL((*amrmclient),allocate(_,_,_,_,_)).Times(AnyNumber())
+ .WillOnce(Return(BuildAllocateResponse(0)))
+ .WillRepeatedly(Return(BuildAllocateResponse(5)));
+
+ EXPECT_CALL(stub, getApplicationClient()).Times(AnyNumber()).WillOnce(Return(appclient));
+ EXPECT_CALL(stub, getApplicationMaster()).Times(AnyNumber()).WillOnce(Return(amrmclient));
+ EXPECT_CALL(stub, getContainerManagement()).Times(AnyNumber()).WillOnce(Return(nmclient));
+
+ LibYarnClient client(amUser,rmHost, rmPort, schedHost, schedPort, amHost, amPort, am_tracking_url,heartbeatInterval,&stub);
+
+ string jobId("");
+ list<string> blackListAdditions;
+ list<string> blackListRemovals;
+ list<Container> allocatedResourcesArray;
+ int result;
+ result = client.allocateResources(jobId, blackListAdditions, blackListRemovals, allocatedResourcesArray, 2);
+ EXPECT_EQ(result,0);
+}
+
+TEST_F(TestLibYarnClient,TestAllocateResourcesRetryFailed){
+ MockApplicationClient *appclient = new MockApplicationClient(amUser, rmHost,rmHost);
+ MockApplicationMaster *amrmclient = new MockApplicationMaster(schedHost,schedPort,user,tokenService);
+ MockContainerManagement *nmclient = new MockContainerManagement();
+ MockLibYarnClientStub stub;
+
+ EXPECT_CALL((*appclient),getContainers(_)).Times(AnyNumber())
+ .WillRepeatedly(Return(BuildContainerReportList(0)));
+ EXPECT_CALL((*amrmclient),allocate(_,_,_,_,_)).Times(AnyNumber())
+ .WillRepeatedly(Return(BuildAllocateResponse(0)));
+
+ EXPECT_CALL(stub, getApplicationClient()).Times(AnyNumber()).WillOnce(Return(appclient));
+ EXPECT_CALL(stub, getApplicationMaster()).Times(AnyNumber()).WillOnce(Return(amrmclient));
+ EXPECT_CALL(stub, getContainerManagement()).Times(AnyNumber()).WillOnce(Return(nmclient));
+
+ LibYarnClient client(amUser,rmHost, rmPort, schedHost, schedPort, amHost, amPort, am_tracking_url,heartbeatInterval,&stub);
+
+ string jobId("");
+ list<string> blackListAdditions;
+ list<string> blackListRemovals;
+ list<Container> allocatedResourcesArray;
+ int result;
+ result = client.allocateResources(jobId, blackListAdditions, blackListRemovals, allocatedResourcesArray, 2);
+ EXPECT_EQ(result,0);
+}
+
+TEST_F(TestLibYarnClient,TestAllocateResourcesException){
+ MockApplicationClient *appclient = new MockApplicationClient(amUser, rmHost,rmHost);
+ MockApplicationMaster *amrmclient = new MockApplicationMaster(schedHost,schedPort,user,tokenService);
+ MockContainerManagement *nmclient = new MockContainerManagement();
+ MockLibYarnClientStub stub;
+
+ EXPECT_CALL((*appclient),getContainers(_)).Times(AnyNumber())
+ .WillRepeatedly(Return(BuildContainerReportList(0)));
+ EXPECT_CALL((*amrmclient),allocate(_,_,_,_,_)).Times(1)
+ .WillOnce(Throw(ApplicationMasterNotRegisteredException("", __FILE__, __LINE__, Yarn::Internal::PrintStack(1, STACK_DEPTH).c_str())));
+
+ EXPECT_CALL(stub, getApplicationClient()).Times(AnyNumber()).WillOnce(Return(appclient));
+ EXPECT_CALL(stub, getApplicationMaster()).Times(AnyNumber()).WillOnce(Return(amrmclient));
+ EXPECT_CALL(stub, getContainerManagement()).Times(AnyNumber()).WillOnce(Return(nmclient));
+
+ LibYarnClient client(amUser,rmHost, rmPort, schedHost, schedPort, amHost, amPort, am_tracking_url,heartbeatInterval,&stub);
+
+ string jobId("");
+ list<string> blackListAdditions;
+ list<string> blackListRemovals;
+ list<Container> allocatedResourcesArray;
+ int result;
+ result = client.allocateResources(jobId, blackListAdditions, blackListRemovals, allocatedResourcesArray, 2);
+ EXPECT_EQ(result,1);
+}
+
+TEST_F(TestLibYarnClient,TestActiveResources){
+ MockApplicationClient *appclient = new MockApplicationClient(amUser,rmHost,rmHost);
+ MockApplicationMaster *amrmclient = new MockApplicationMaster(schedHost,schedPort,user,tokenService);
+ MockContainerManagement *nmclient = new MockContainerManagement();
+ MockLibYarnClientStub stub;
+
+ EXPECT_CALL(stub, getApplicationClient()).Times(AnyNumber()).WillOnce(Return(appclient));
+ EXPECT_CALL(stub, getApplicationMaster()).Times(AnyNumber()).WillOnce(Return(amrmclient));
+ EXPECT_CALL(stub, getContainerManagement()).Times(AnyNumber()).WillOnce(Return(nmclient));
+
+ LibYarnClient client(amUser,rmHost, rmPort, schedHost, schedPort, amHost, amPort, am_tracking_url,heartbeatInterval,&stub);
+
+ string jobId("");
+ int activeContainerSize = 3;
+ int64_t activeContainerIds[activeContainerSize];
+ for (int i = 0;i < activeContainerSize;i++){
+ activeContainerIds[i] = i;
+ }
+ int result = client.activeResources(jobId,activeContainerIds,activeContainerSize);
+ EXPECT_EQ(result,0);
+}
+
+TEST_F(TestLibYarnClient,TestActiveResourcesInvalidId){
+ MockApplicationClient *appclient = new MockApplicationClient(amUser,rmHost,rmHost);
+ MockApplicationMaster *amrmclient = new MockApplicationMaster(schedHost,schedPort,user,tokenService);
+ MockContainerManagement *nmclient = new MockContainerManagement();
+ MockLibYarnClientStub stub;
+
+ EXPECT_CALL(stub, getApplicationClient()).Times(AnyNumber()).WillOnce(Return(appclient));
+ EXPECT_CALL(stub, getApplicationMaster()).Times(AnyNumber()).WillOnce(Return(amrmclient));
+ EXPECT_CALL(stub, getContainerManagement()).Times(AnyNumber()).WillOnce(Return(nmclient));
+
+ LibYarnClient client(amUser,rmHost, rmPort, schedHost, schedPort, amHost, amPort, am_tracking_url,heartbeatInterval,&stub);
+
+ string jobId("InvalidId");
+ int activeContainerSize = 3;
+ int64_t activeContainerIds[activeContainerSize];
+ for (int i = 0;i < activeContainerSize;i++){
+ activeContainerIds[i] = i;
+ }
+ int result = client.activeResources(jobId,activeContainerIds,activeContainerSize);
+ EXPECT_EQ(result,1);
+}
+
+TEST_F(TestLibYarnClient,TestReleaseResources){
+ MockApplicationClient *appclient = new MockApplicationClient(amUser,rmHost,rmHost);
+ MockApplicationMaster *amrmclient = new MockApplicationMaster(schedHost,schedPort,user,tokenService);
+ MockContainerManagement *nmclient = new MockContainerManagement();
+ MockLibYarnClientStub stub;
+
+ EXPECT_CALL((*amrmclient),allocate(_,_,_,_,_)).Times(AnyNumber()).WillRepeatedly(Return(BuildAllocateResponse(5)));
+
+ EXPECT_CALL(stub, getApplicationClient()).Times(AnyNumber()).WillOnce(Return(appclient));
+ EXPECT_CALL(stub, getApplicationMaster()).Times(AnyNumber()).WillOnce(Return(amrmclient));
+ EXPECT_CALL(stub, getContainerManagement()).Times(AnyNumber()).WillOnce(Return(nmclient));
+
+ LibYarnClient client(amUser, rmHost, rmPort, schedHost, schedPort, amHost, amPort, am_tracking_url,heartbeatInterval,&stub);
+
+ string jobId("");
+ int releaseContainerSize = 3;
+ int64_t releaseContainerIds[releaseContainerSize];
+ for (int i = 0;i < releaseContainerSize;i++){
+ releaseContainerIds[i] = i;
+ }
+ int result = client.releaseResources(jobId,releaseContainerIds,releaseContainerSize);
+ EXPECT_EQ(result,0);
+}
+
+TEST_F(TestLibYarnClient,TestReleaseResourcesInvalidId){
+ MockApplicationClient *appclient = new MockApplicationClient(amUser,rmHost,rmHost);
+ MockApplicationMaster *amrmclient = new MockApplicationMaster(schedHost,schedPort,user,tokenService);
+ MockContainerManagement *nmclient = new MockContainerManagement();
+ MockLibYarnClientStub stub;
+
+ EXPECT_CALL(stub, getApplicationClient()).Times(AnyNumber()).WillOnce(Return(appclient));
+ EXPECT_CALL(stub, getApplicationMaster()).Times(AnyNumber()).WillOnce(Return(amrmclient));
+ EXPECT_CALL(stub, getContainerManagement()).Times(AnyNumber()).WillOnce(Return(nmclient));
+
+ LibYarnClient client(amUser, rmHost, rmPort, schedHost, schedPort, amHost, amPort, am_tracking_url,heartbeatInterval,&stub);
+
+ string jobId("InvalidId");
+ int releaseContainerSize = 3;
+ int64_t releaseContainerIds[releaseContainerSize];
+ for (int i = 0;i < releaseContainerSize;i++){
+ releaseContainerIds[i] = i;
+ }
+ int result = client.releaseResources(jobId,releaseContainerIds,releaseContainerSize);
+ EXPECT_EQ(result,1);
+}
+
+TEST_F(TestLibYarnClient,TestFinishJob){
+ MockApplicationClient *appclient = new MockApplicationClient(amUser,rmHost,rmHost);
+ MockApplicationMaster *amrmclient = new MockApplicationMaster(schedHost,schedPort,user,tokenService);
+ MockContainerManagement *nmclient = new MockContainerManagement();
+ MockLibYarnClientStub stub;
+
+ EXPECT_CALL((*amrmclient),finishApplicationMaster(_,_,_)).Times(AnyNumber()).WillRepeatedly(Return(true));
+
+ EXPECT_CALL(stub, getApplicationClient()).Times(AnyNumber()).WillOnce(Return(appclient));
+ EXPECT_CALL(stub, getApplicationMaster()).Times(AnyNumber()).WillOnce(Return(amrmclient));
+ EXPECT_CALL(stub, getContainerManagement()).Times(AnyNumber()).WillOnce(Return(nmclient));
+ LibYarnClient client(amUser, rmHost, rmPort, schedHost, schedPort, amHost, amPort, am_tracking_url,heartbeatInterval,&stub);
+
+ string jobId("");
+ int result = client.finishJob(jobId,FinalApplicationStatus::APP_SUCCEEDED);
+ EXPECT_EQ(result,0);
+}
+
+TEST_F(TestLibYarnClient,TestFinishJobInvalidId){
+ MockApplicationClient *appclient = new MockApplicationClient(amUser,rmHost,rmHost);
+ MockApplicationMaster *amrmclient = new MockApplicationMaster(schedHost,schedPort,user,tokenService);
+ MockContainerManagement *nmclient = new MockContainerManagement();
+ MockLibYarnClientStub stub;
+
+ EXPECT_CALL(stub, getApplicationClient()).Times(AnyNumber()).WillOnce(Return(appclient));
+ EXPECT_CALL(stub, getApplicationMaster()).Times(AnyNumber()).WillOnce(Return(amrmclient));
+ EXPECT_CALL(stub, getContainerManagement()).Times(AnyNumber()).WillOnce(Return(nmclient));
+ LibYarnClient client(amUser, rmHost, rmPort, schedHost, schedPort, amHost, amPort, am_tracking_url,heartbeatInterval,&stub);
+
+ string jobId("InvalidId");
+ int result = client.finishJob(jobId,FinalApplicationStatus::APP_SUCCEEDED);
+ EXPECT_EQ(result,1);
+}
+
+TEST_F(TestLibYarnClient,TestGetApplicationReport){
+ MockApplicationClient *appclient = new MockApplicationClient(amUser,rmHost,rmHost);
+ MockApplicationMaster *amrmclient = new MockApplicationMaster(schedHost,schedPort,user,tokenService);
+ MockContainerManagement *nmclient = new MockContainerManagement();
+ MockLibYarnClientStub stub;
+
+ EXPECT_CALL((*appclient),getApplicationReport(_)).Times(AnyNumber())
+ .WillRepeatedly(Return(BuildApplicationReport("pass",YarnApplicationState::ACCEPTED)));
+
+ EXPECT_CALL(stub, getApplicationClient()).Times(AnyNumber()).WillOnce(Return(appclient));
+ EXPECT_CALL(stub, getApplicationMaster()).Times(AnyNumber()).WillOnce(Return(amrmclient));
+ EXPECT_CALL(stub, getContainerManagement()).Times(AnyNumber()).WillOnce(Return(nmclient));
+ LibYarnClient client(amUser, rmHost, rmPort, schedHost, schedPort, amHost, amPort, am_tracking_url,heartbeatInterval,&stub);
+
+ string jobId("");
+ ApplicationReport applicationReport;
+ int result = client.getApplicationReport(jobId,applicationReport);
+ EXPECT_EQ(result,0);
+}
+
+TEST_F(TestLibYarnClient,TestGetApplicationReportInvalidId){
+ MockApplicationClient *appclient = new MockApplicationClient(amUser,rmHost,rmHost);
+ MockApplicationMaster *amrmclient = new MockApplicationMaster(schedHost,schedPort,user,tokenService);
+ MockContainerManagement *nmclient = new MockContainerManagement();
+ MockLibYarnClientStub stub;
+
+ EXPECT_CALL(stub, getApplicationClient()).Times(AnyNumber()).WillOnce(Return(appclient));
+ EXPECT_CALL(stub, getApplicationMaster()).Times(AnyNumber()).WillOnce(Return(amrmclient));
+ EXPECT_CALL(stub, getContainerManagement()).Times(AnyNumber()).WillOnce(Return(nmclient));
+ LibYarnClient client(amUser, rmHost, rmPort, schedHost, schedPort, amHost, amPort, am_tracking_url,heartbeatInterval,&stub);
+
+ string jobId("InvalidId");
+ ApplicationReport applicationReport;
+ int result = client.getApplicationReport(jobId,applicationReport);
+ EXPECT_EQ(result,1);
+}
+
+TEST_F(TestLibYarnClient,TestGetContainerReports){
+ MockApplicationClient *appclient = new MockApplicationClient(amUser,rmHost,rmHost);
+ MockApplicationMaster *amrmclient = new MockApplicationMaster(schedHost,schedPort,user,tokenService);
+ MockContainerManagement *nmclient = new MockContainerManagement();
+ MockLibYarnClientStub stub;
+
+ int containerSize = 3;
+ EXPECT_CALL((*appclient),getContainers(_)).Times(AnyNumber())
+ .WillRepeatedly(Return(BuildContainerReportList(containerSize)));
+
+ EXPECT_CALL(stub, getApplicationClient()).Times(AnyNumber()).WillOnce(Return(appclient));
+ EXPECT_CALL(stub, getApplicationMaster()).Times(AnyNumber()).WillOnce(Return(amrmclient));
+ EXPECT_CALL(stub, getContainerManagement()).Times(AnyNumber()).WillOnce(Return(nmclient));
+ LibYarnClient client(amUser, rmHost, rmPort, schedHost, schedPort, amHost, amPort, am_tracking_url,heartbeatInterval,&stub);
+
+ string jobId("");
+ list<ContainerReport> reports;
+ int result = client.getContainerReports(jobId,reports);
+ EXPECT_EQ(result,0);
+ EXPECT_EQ(int(reports.size()),containerSize);
+}
+
+TEST_F(TestLibYarnClient,TestGetContainerReportsInvalidId){
+ MockApplicationClient *appclient = new MockApplicationClient(amUser,rmHost,rmHost);
+ MockApplicationMaster *amrmclient = new MockApplicationMaster(schedHost,schedPort,user,tokenService);
+ MockContainerManagement *nmclient = new MockContainerManagement();
+ MockLibYarnClientStub stub;
+
+ EXPECT_CALL(stub, getApplicationClient()).Times(AnyNumber()).WillOnce(Return(appclient));
+ EXPECT_CALL(stub, getApplicationMaster()).Times(AnyNumber()).WillOnce(Return(amrmclient));
+ EXPECT_CALL(stub, getContainerManagement()).Times(AnyNumber()).WillOnce(Return(nmclient));
+ LibYarnClient client(amUser, rmHost, rmPort, schedHost, schedPort, amHost, amPort, am_tracking_url,heartbeatInterval,&stub);
+
+ string jobId("InvalidId");
+ list<ContainerReport> reports;
+ int result = client.getContainerReports(jobId,reports);
+ EXPECT_EQ(result,1);
+}
+
+TEST_F(TestLibYarnClient,TestGetContainerStatuses){
+ MockApplicationClient *appclient = new MockApplicationClient(amUser,rmHost,rmHost);
+ MockApplicationMaster *amrmclient = new MockApplicationMaster(schedHost,schedPort,user,tokenService);
+ MockContainerManagement *nmclient = new MockContainerManagement();
+ MockLibYarnClientStub stub;
+
+ EXPECT_CALL(stub, getApplicationClient()).Times(AnyNumber()).WillOnce(Return(appclient));
+ EXPECT_CALL(stub, getApplicationMaster()).Times(AnyNumber()).WillOnce(Return(amrmclient));
+ EXPECT_CALL(stub, getContainerManagement()).Times(AnyNumber()).WillOnce(Return(nmclient));
+ LibYarnClient client(amUser, rmHost, rmPort, schedHost, schedPort, amHost, amPort, am_tracking_url,heartbeatInterval,&stub);
+
+ string jobId("");
+ list<ContainerStatus> containerStatues;
+ int containerSize = 3;
+ int64_t containerIds[containerSize];
+ for (int i = 0;i < containerSize;i++){
+ containerIds[i] = i;
+ }
+ int result = client.getContainerStatuses(jobId,containerIds,containerSize,containerStatues);
+ EXPECT_EQ(result,0);
+ EXPECT_EQ(int(containerStatues.size()),0);
+}
+
+TEST_F(TestLibYarnClient,TestGetContainerStatusesInvalidId){
+ MockApplicationClient *appclient = new MockApplicationClient(amUser,rmHost,rmHost);
+ MockApplicationMaster *amrmclient = new MockApplicationMaster(schedHost,schedPort,user,tokenService);
+ MockContainerManagement *nmclient = new MockContainerManagement();
+ MockLibYarnClientStub stub;
+
+ EXPECT_CALL(stub, getApplicationClient()).Times(AnyNumber()).WillOnce(Return(appclient));
+ EXPECT_CALL(stub, getApplicationMaster()).Times(AnyNumber()).WillOnce(Return(amrmclient));
+ EXPECT_CALL(stub, getContainerManagement()).Times(AnyNumber()).WillOnce(Return(nmclient));
+ LibYarnClient client(amUser, rmHost, rmPort, schedHost, schedPort, amHost, amPort, am_tracking_url,heartbeatInterval,&stub);
+
+ string jobId("InvalidId");
+ list<ContainerStatus> containerStatues;
+ int containerSize = 3;
+ int64_t containerIds[containerSize];
+ for (int i = 0;i < containerSize;i++){
+ containerIds[i] = i;
+ }
+ int result = client.getContainerStatuses(jobId,containerIds,containerSize,containerStatues);
+ EXPECT_EQ(result,1);
+}
+
+TEST_F(TestLibYarnClient,TestGetQueueInfo){
+ MockApplicationClient *appclient = new MockApplicationClient(amUser,rmHost,rmHost);
+ MockApplicationMaster *amrmclient = new MockApplicationMaster(schedHost,schedPort,user,tokenService);
+ MockContainerManagement *nmclient = new MockContainerManagement();
+ MockLibYarnClientStub stub;
+
+ string queue("test");
+ int childNum = 2;
+ float capcity = 0.5;
+ QueueInfo queueInfo = BuildQueueinfo(queue,capcity,childNum);
+ EXPECT_CALL((*appclient),getQueueInfo(_,_,_,_)).Times(AnyNumber())
+ .WillRepeatedly(Return(queueInfo));
+
+ EXPECT_CALL(stub, getApplicationClient()).Times(AnyNumber()).WillOnce(Return(appclient));
+ EXPECT_CALL(stub, getApplicationMaster()).Times(AnyNumber()).WillOnce(Return(amrmclient));
+ EXPECT_CALL(stub, getContainerManagement()).Times(AnyNumber()).WillOnce(Return(nmclient));
+ LibYarnClient client(amUser, rmHost, rmPort, schedHost, schedPort, amHost, amPort, am_tracking_url,heartbeatInterval,&stub);
+
+
+ QueueInfo resultQueue;
+ int result = client.getQueueInfo(queue,true,true,true,resultQueue);
+ EXPECT_EQ(result,0);
+ EXPECT_EQ(resultQueue.getCurrentCapacity(),capcity);
+ EXPECT_STREQ(resultQueue.getQueueName().c_str(),queue.c_str());
+ EXPECT_EQ(int(resultQueue.getChildQueues().size()),childNum);
+}
+
+TEST_F(TestLibYarnClient,TestGetQueueInfoException){
+ MockApplicationClient *appclient = new MockApplicationClient(amUser,rmHost,rmHost);
+ MockApplicationMaster *amrmclient = new MockApplicationMaster(schedHost,schedPort,user,tokenService);
+ MockContainerManagement *nmclient = new MockContainerManagement();
+ MockLibYarnClientStub stub;
+
+ EXPECT_CALL((*appclient),getQueueInfo(_,_,_,_)).Times(AnyNumber())
+ .WillRepeatedly(Throw(YarnIOException("", __FILE__, __LINE__, Yarn::Internal::PrintStack(1, STACK_DEPTH).c_str())));
+
+ EXPECT_CALL(stub, getApplicationClient()).Times(AnyNumber()).WillOnce(Return(appclient));
+ EXPECT_CALL(stub, getApplicationMaster()).Times(AnyNumber()).WillOnce(Return(amrmclient));
+ EXPECT_CALL(stub, getContainerManagement()).Times(AnyNumber()).WillOnce(Return(nmclient));
+ LibYarnClient client(amUser, rmHost, rmPort, schedHost, schedPort, amHost, amPort, am_tracking_url,heartbeatInterval,&stub);
+
+ string queue("test");
+ QueueInfo resultQueue;
+ int result = client.getQueueInfo(queue,true,true,true,resultQueue);
+ EXPECT_EQ(result,1);
+}
+
+TEST_F(TestLibYarnClient,TestGetClusterNodes){
+ MockApplicationClient *appclient = new MockApplicationClient(amUser,rmHost,rmHost);
+ MockApplicationMaster *amrmclient = new MockApplicationMaster(schedHost,schedPort,user,tokenService);
+ MockContainerManagement *nmclient = new MockContainerManagement();
+ MockLibYarnClientStub stub;
+
+ list<NodeReport> nodeReports;
+ int nodeSize = 3;
+ for (int i=0;i<nodeSize;i++){
+ NodeReport report;
+ nodeReports.push_back(report);
+ }
+ EXPECT_CALL((*appclient),getClusterNodes(_)).Times(AnyNumber())
+ .WillRepeatedly(Return(nodeReports));
+
+ EXPECT_CALL(stub, getApplicationClient()).Times(AnyNumber()).WillOnce(Return(appclient));
+ EXPECT_CALL(stub, getApplicationMaster()).Times(AnyNumber()).WillOnce(Return(amrmclient));
+ EXPECT_CALL(stub, getContainerManagement()).Times(AnyNumber()).WillOnce(Return(nmclient));
+ LibYarnClient client(amUser, rmHost, rmPort, schedHost, schedPort, amHost, amPort, am_tracking_url,heartbeatInterval,&stub);
+
+ list<NodeState> states;
+ list<NodeReport> nodeResult;
+ int result = client.getClusterNodes(states,nodeResult);
+ EXPECT_EQ(result,0);
+ EXPECT_EQ(int(nodeResult.size()),nodeSize);
+}
+
+TEST_F(TestLibYarnClient,TestGetClusterNodesException){
+ MockApplicationClient *appclient = new MockApplicationClient(amUser,rmHost,rmHost);
+ MockApplicationMaster *amrmclient = new MockApplicationMaster(schedHost,schedPort,user,tokenService);
+ MockContainerManagement *nmclient = new MockContainerManagement();
+ MockLibYarnClientStub stub;
+
+ EXPECT_CALL((*appclient),getClusterNodes(_)).Times(AnyNumber())
+ .WillRepeatedly(Throw(YarnIOException("", __FILE__, __LINE__, Yarn::Internal::PrintStack(1, STACK_DEPTH).c_str())));
+
+ EXPECT_CALL(stub, getApplicationClient()).Times(AnyNumber()).WillOnce(Return(appclient));
+ EXPECT_CALL(stub, getApplicationMaster()).Times(AnyNumber()).WillOnce(Return(amrmclient));
+ EXPECT_CALL(stub, getContainerManagement()).Times(AnyNumber()).WillOnce(Return(nmclient));
+ LibYarnClient client(amUser, rmHost, rmPort, schedHost, schedPort, amHost, amPort, am_tracking_url,heartbeatInterval,&stub);
+
+ list<NodeState> states;
+ list<NodeReport> nodeResult;
+ int result = client.getClusterNodes(states,nodeResult);
+ EXPECT_EQ(result,1);
+}
+
+TEST_F(TestLibYarnClient,TestGetErrorMessage){
+ LibYarnClient client(amUser, rmHost, rmPort, schedHost, schedPort, amHost, amPort, am_tracking_url,heartbeatInterval);
+ EXPECT_STREQ("",client.getErrorMessage().c_str());
+ client.setErrorMessage("error!");
+ EXPECT_STREQ("error!",client.getErrorMessage().c_str());
+}
+
+TEST_F(TestLibYarnClient,TestGetActiveFailContainerIds){
+ LibYarnClient client(amUser, rmHost, rmPort, schedHost, schedPort, amHost, amPort, am_tracking_url,heartbeatInterval);
+ set<int64_t> activeFailIds;
+ client.getActiveFailContainerIds(activeFailIds);
+ EXPECT_EQ(int(activeFailIds.size()),0);
+}
+
+TEST_F(TestLibYarnClient,TestLibYarn){
+ MockApplicationClient *appclient = new MockApplicationClient(amUser,rmHost,rmHost);
+ MockApplicationMaster *amrmclient = new MockApplicationMaster(schedHost,schedPort,user,tokenService);
+ MockContainerManagement *nmclient = new MockContainerManagement();
+ MockLibYarnClientStub stub;
+
+ EXPECT_CALL(*appclient, getNewApplication()).Times(AnyNumber()).WillOnce(Return(BuildApplicationId(1)));
+ EXPECT_CALL((*appclient),submitApplication(_)).Times(AnyNumber()).WillOnce(Return());
+ EXPECT_CALL((*appclient),getApplicationReport(_)).Times(AtLeast(3))
+ .WillOnce(Return(BuildApplicationReport("",YarnApplicationState::FAILED)))
+ .WillOnce(Return(BuildApplicationReport("",YarnApplicationState::ACCEPTED)))
+ .WillRepeatedly(Return(BuildApplicationReport("pass",YarnApplicationState::ACCEPTED)));
+ EXPECT_CALL((*appclient),getContainers(_)).Times(AnyNumber())
+ .WillRepeatedly(Return(BuildContainerReportList(0)));
+ EXPECT_CALL((*appclient), getMethod()).Times(AnyNumber()).WillRepeatedly(Return(SIMPLE));
+
+ EXPECT_CALL((*amrmclient),registerApplicationMaster(_,_,_)).Times(AnyNumber()).WillRepeatedly(Return(BuildRegisterResponse()));
+ EXPECT_CALL((*amrmclient),allocate(_,_,_,_,_)).Times(AnyNumber()).WillRepeatedly(Return(BuildAllocateResponse(5)));
+ EXPECT_CALL((*amrmclient),finishApplicationMaster(_,_,_)).Times(AnyNumber()).WillRepeatedly(Return(true));
+
+ EXPECT_CALL((*nmclient),startContainer(_,_,_)).Times(AnyNumber())
+ .WillOnce(Throw(std::invalid_argument("startContainer Exception")))
+ .WillRepeatedly(Return(BuildStartContainerResponse()));
+ EXPECT_CALL((*nmclient),getContainerStatus(_,_)).Times(AnyNumber())
+ .WillOnce(Return(BuildContainerStatus(2)))
+ .WillOnce(Return(BuildContainerStatus(3)))
+ .WillRepeatedly(Return(BuildContainerStatus(0)));
+ EXPECT_CALL((*nmclient),stopContainer(_,_)).Times(AnyNumber())
+ .WillRepeatedly(Return());
+
+ EXPECT_CALL(stub, getApplicationClient()).Times(AnyNumber()).WillOnce(Return(appclient));
+ EXPECT_CALL(stub, getApplicationMaster()).Times(AnyNumber()).WillOnce(Return(amrmclient));
+ EXPECT_CALL(stub, getContainerManagement()).Times(AnyNumber()).WillOnce(Return(nmclient));
+
+ LibYarnClient client(amUser,rmHost, rmPort, schedHost, schedPort, amHost, amPort, am_tracking_url,heartbeatInterval,&stub);
+ string jobName("libyarn");
+ string queue("default");
+ string jobId("");
+ int result = client.createJob(jobName,queue,jobId);
+ EXPECT_EQ(result,0);
+
+ list<string> blackListAdditions;
+ list<string> blackListRemovals;
+ ResourceRequest resRequest;
+ list<Container> allocatedResourcesArray;
+
+ resRequest = BuildRequest(3);
+ result = client.allocateResources(jobId, blackListAdditions, blackListRemovals,allocatedResourcesArray,5);
+ EXPECT_EQ(result,0);
+
+ int allocatedResourceArraySize = allocatedResourcesArray.size();
+ int64_t activeContainerIds[allocatedResourceArraySize];
+ int64_t releaseContainerIds[allocatedResourceArraySize];
+ int64_t statusContainerIds[allocatedResourceArraySize];
+ int i = 0;
+ for (list<Container>::iterator it = allocatedResourcesArray.begin();it != allocatedResourcesArray.end();it++){
+ activeContainerIds[i] = it->getId().getId();
+ if (i != 1){
+ releaseContainerIds[i] = it->getId().getId();
+ }
+ statusContainerIds[i] = it->getId().getId();
+ i++;
+ }
+ result = client.activeResources(jobId, activeContainerIds,allocatedResourceArraySize);
+ EXPECT_EQ(result,0);
+
+ set<int64_t> activeFailIds;
+ result = client.getActiveFailContainerIds(activeFailIds);
+ EXPECT_EQ(result,0);
+ EXPECT_EQ(int(activeFailIds.size()),1);
+
+ ApplicationReport report;
+ result = client.getApplicationReport(jobId,report);
+ EXPECT_EQ(result,0);
+
+ list<ContainerStatus> containerStatues;
+ result = client.getContainerStatuses(jobId,statusContainerIds,allocatedResourceArraySize,containerStatues);
+ EXPECT_EQ(result,0);
+ //EXPECT_EQ(int(containerStatues.size()),2);
+
+ result = client.releaseResources(jobId, releaseContainerIds,allocatedResourceArraySize);
+ EXPECT_EQ(result,0);
+
+
+ result = client.finishJob(jobId, FinalApplicationStatus::APP_SUCCEEDED);
+ EXPECT_EQ(result,0);
+}
+
http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/383818c2/depends/libyarn/test/unit/TestLibYarnClient/TestLibYarnClientC.cpp
----------------------------------------------------------------------
diff --git a/depends/libyarn/test/unit/TestLibYarnClient/TestLibYarnClientC.cpp b/depends/libyarn/test/unit/TestLibYarnClient/TestLibYarnClientC.cpp
new file mode 100644
index 0000000..88fb609
--- /dev/null
+++ b/depends/libyarn/test/unit/TestLibYarnClient/TestLibYarnClientC.cpp
@@ -0,0 +1,278 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+#include <string>
+
+#include "gtest/gtest.h"
+#include "gmock/gmock.h"
+
+#include "libyarnclient/LibYarnClientC.h"
+#include "MockLibYarnClient.h"
+
+using std::string;
+using namespace libyarn;
+using namespace testing;
+using namespace Mock;
+
+
+extern "C" LibYarnClient_t* getLibYarnClientT(LibYarnClient *libyarnClient);
+
+class TestLibYarnClientC: public ::testing::Test {
+public:
+ TestLibYarnClientC(){
+ string amUser("postgres");
+ string rmHost("localhost");
+ string rmPort("8032");
+ string schedHost("localhost");
+ string schedPort("8030");
+ string amHost("localhost");
+ int32_t amPort = 0;
+ string am_tracking_url("url");
+ int heartbeatInterval = 1000;
+ libyarnClient = new MockLibYarnClient(amUser, rmHost, rmPort, schedHost, schedPort, amHost, amPort, am_tracking_url,heartbeatInterval);
+ }
+ ~TestLibYarnClientC(){
+ delete libyarnClient;
+ }
+protected:
+ MockLibYarnClient *libyarnClient;
+};
+
+static char* StringToChar(string str){
+ char *cstr = new char[str.length()+1];
+ strcpy(cstr,str.c_str());
+ return cstr;
+}
+
+TEST_F(TestLibYarnClientC,TestNewLibYarnClient){
+ char *amUser = StringToChar("postgres");
+ char *rmHost = StringToChar("localhost");
+ char *rmPort = StringToChar("8032");
+ char *schedHost = StringToChar("localhost");
+ char *schedPort = StringToChar("8030");
+ char *amHost = StringToChar("localhost");
+ int32_t amPort = 8090;
+ char *am_tracking_url = StringToChar("url");
+ int heartbeatInterval = 1000;
+ LibYarnClient_t *client = NULL;
+ int result = newLibYarnClient(amUser, rmHost, rmPort, schedHost, schedPort,
+ amHost, amPort, am_tracking_url,&client,heartbeatInterval);
+ EXPECT_EQ(result,FUNCTION_SUCCEEDED);
+}
+
+TEST_F(TestLibYarnClientC,TestCreateJob){
+ EXPECT_CALL((*libyarnClient),createJob(_,_,_)).Times(AnyNumber())
+ .WillOnce(Return(FUNCTION_FAILED))
+ .WillOnce(Return(FUNCTION_SUCCEEDED));
+ LibYarnClient_t *client = getLibYarnClientT(libyarnClient);
+ char *jobName = StringToChar("libyarn");
+ char *queue = StringToChar("default");
+ char *jobId = NULL;
+ int result = createJob(client, jobName, queue,&jobId);
+ EXPECT_STREQ("",(const char *)(jobId));
+ EXPECT_EQ(result,FUNCTION_FAILED);
+
+ result = createJob(client, jobName, queue,&jobId);
+ EXPECT_STREQ("",(const char *)(jobId));
+ EXPECT_EQ(result,FUNCTION_SUCCEEDED);
+}
+
+TEST_F(TestLibYarnClientC,TestAllocateResources){
+ EXPECT_CALL((*libyarnClient),allocateResources(_,_,_,_,_)).Times(AnyNumber())
+ .WillOnce(Return(FUNCTION_FAILED))
+ .WillOnce(Return(FUNCTION_SUCCEEDED));
+ LibYarnClient_t *client = getLibYarnClientT(libyarnClient);
+ char *jobId = StringToChar("");
+ LibYarnResourceRequest_t resRequest;
+ resRequest.priority = 1;
+ resRequest.host = StringToChar("*");
+ resRequest.vCores = 1;
+ resRequest.memory = 1024;
+ resRequest.num_containers = 2;
+ resRequest.relax_locality = 1;
+
+ int blacklistAddsSize = 3;
+ char *blackListAdditions[blacklistAddsSize];
+ for (int i = 0;i<blacklistAddsSize;i++){
+ blackListAdditions[i] = StringToChar("");
+ }
+ int blackListRemovalsSize = 3;
+ char *blackListRemovals[blackListRemovalsSize];
+ for (int i = 0;i<blackListRemovalsSize;i++){
+ blackListRemovals[i] = StringToChar("");
+ }
+
+ LibYarnResource_t *allocatedResourcesArray;
+ int allocatedResourceArraySize;
+
+ int result = allocateResources(client, jobId, 1, 1, 1024, 2, blackListAdditions,
+ blacklistAddsSize, blackListRemovals, blackListRemovalsSize, NULL, 0, &allocatedResourcesArray, &allocatedResourceArraySize);
+ EXPECT_EQ(result,FUNCTION_FAILED);
+
+ result = allocateResources(client, jobId, 1, 1, 1024, 2, blackListAdditions,
+ blacklistAddsSize, blackListRemovals, blackListRemovalsSize, NULL, 0, &allocatedResourcesArray, &allocatedResourceArraySize);
+ EXPECT_EQ(result,FUNCTION_SUCCEEDED);
+ EXPECT_EQ(0,allocatedResourceArraySize);
+}
+
+TEST_F(TestLibYarnClientC,TestActiveResources){
+ EXPECT_CALL((*libyarnClient),activeResources(_,_,_)).Times(AnyNumber())
+ .WillOnce(Return(FUNCTION_FAILED))
+ .WillOnce(Return(FUNCTION_SUCCEEDED));
+ LibYarnClient_t *client = getLibYarnClientT(libyarnClient);
+
+ int activeContainerSize = 0;
+ int64_t activeContainerIds[activeContainerSize];
+ char *jobId = StringToChar("");
+ int result = activeResources(client, jobId, activeContainerIds,activeContainerSize);
+ EXPECT_EQ(result,FUNCTION_FAILED);
+ result = activeResources(client, jobId, activeContainerIds,activeContainerSize);
+ EXPECT_EQ(result,FUNCTION_SUCCEEDED);
+}
+
+TEST_F(TestLibYarnClientC,TestReleaseResources){
+ EXPECT_CALL((*libyarnClient),releaseResources(_,_,_)).Times(AnyNumber())
+ .WillOnce(Return(FUNCTION_FAILED))
+ .WillOnce(Return(FUNCTION_SUCCEEDED));
+ LibYarnClient_t *client = getLibYarnClientT(libyarnClient);
+
+ int releaseContainerSize = 0;
+ int64_t releaseContainerIds[releaseContainerSize];
+ char *jobId = StringToChar("");
+ int result = releaseResources(client, jobId, releaseContainerIds,releaseContainerSize);
+ EXPECT_EQ(result,FUNCTION_FAILED);
+ result = releaseResources(client, jobId, releaseContainerIds,releaseContainerSize);
+ EXPECT_EQ(result,FUNCTION_SUCCEEDED);
+}
+
+TEST_F(TestLibYarnClientC,TestFinishJob){
+ EXPECT_CALL((*libyarnClient),finishJob(_,_)).Times(AnyNumber())
+ .WillOnce(Return(FUNCTION_FAILED))
+ .WillOnce(Return(FUNCTION_SUCCEEDED));
+ LibYarnClient_t *client = getLibYarnClientT(libyarnClient);
+
+ char *jobId = StringToChar("");
+ int result = finishJob(client, jobId, APPLICATION_SUCCEEDED);
+ EXPECT_EQ(result,FUNCTION_FAILED);
+ result = finishJob(client, jobId, APPLICATION_SUCCEEDED);
+ EXPECT_EQ(result,FUNCTION_SUCCEEDED);
+}
+
+TEST_F(TestLibYarnClientC,TestGetActiveFailContainerIds){
+ EXPECT_CALL((*libyarnClient),getActiveFailContainerIds(_)).Times(AnyNumber())
+ .WillOnce(Return(FUNCTION_FAILED))
+ .WillOnce(Return(FUNCTION_SUCCEEDED));
+ LibYarnClient_t *client = getLibYarnClientT(libyarnClient);
+
+ int64_t *activeFailIds;
+ int activeFailSize;
+ int result = getActiveFailContainerIds(client,&activeFailIds,&activeFailSize);
+ EXPECT_EQ(result,FUNCTION_FAILED);
+
+ result = getActiveFailContainerIds(client,&activeFailIds,&activeFailSize);
+ EXPECT_EQ(result,FUNCTION_SUCCEEDED);
+ EXPECT_EQ(0,activeFailSize);
+}
+
+TEST_F(TestLibYarnClientC,TestGetApplicationReport){
+ EXPECT_CALL((*libyarnClient),getApplicationReport(_,_)).Times(AnyNumber())
+ .WillOnce(Return(FUNCTION_FAILED))
+ .WillOnce(Return(FUNCTION_SUCCEEDED));
+ LibYarnClient_t *client = getLibYarnClientT(libyarnClient);
+
+ LibYarnApplicationReport_t *applicationReport = NULL;
+ char *jobId = StringToChar("");
+ int result = getApplicationReport(client, jobId, &applicationReport);
+ EXPECT_EQ(result,FUNCTION_FAILED);
+ result = getApplicationReport(client, jobId, &applicationReport);
+ EXPECT_EQ(result,FUNCTION_SUCCEEDED);
+ EXPECT_EQ(0,applicationReport->appId);
+}
+
+TEST_F(TestLibYarnClientC,TestGetContainerReports){
+ EXPECT_CALL((*libyarnClient),getContainerReports(_,_)).Times(AnyNumber())
+ .WillOnce(Return(FUNCTION_FAILED))
+ .WillOnce(Return(FUNCTION_SUCCEEDED));
+ LibYarnClient_t *client = getLibYarnClientT(libyarnClient);
+
+ char *jobId = StringToChar("");
+ LibYarnContainerReport_t *containerReportArray;
+ int containerReportArraySize;
+ int result = getContainerReports(client, jobId, &containerReportArray,
+ &containerReportArraySize);
+ EXPECT_EQ(result,FUNCTION_FAILED);
+ result = getContainerReports(client, jobId, &containerReportArray,
+ &containerReportArraySize);
+ EXPECT_EQ(result,FUNCTION_SUCCEEDED);
+ EXPECT_EQ(0,containerReportArraySize);
+}
+
+TEST_F(TestLibYarnClientC,TestGetContainerStatuses){
+ EXPECT_CALL((*libyarnClient),getContainerStatuses(_,_,_,_)).Times(AnyNumber())
+ .WillOnce(Return(FUNCTION_FAILED))
+ .WillOnce(Return(FUNCTION_SUCCEEDED));
+ LibYarnClient_t *client = getLibYarnClientT(libyarnClient);
+
+ char *jobId = StringToChar("");
+
+ int statusContainerSize = 0;
+ int64_t statusContainerIds[statusContainerSize];
+ LibYarnContainerStatus_t *containerStatusArray;
+ int containerStatusArraySize;
+ int result = getContainerStatuses(client, jobId, statusContainerIds,
+ statusContainerSize, &containerStatusArray,&containerStatusArraySize);
+ EXPECT_EQ(result,FUNCTION_FAILED);
+ result = getContainerStatuses(client, jobId, statusContainerIds,
+ statusContainerSize, &containerStatusArray,&containerStatusArraySize);
+ EXPECT_EQ(result,FUNCTION_SUCCEEDED);
+ EXPECT_EQ(0,containerStatusArraySize);
+}
+
+TEST_F(TestLibYarnClientC,TestGetQueueInfo){
+ EXPECT_CALL((*libyarnClient),getQueueInfo(_,_,_,_,_)).Times(AnyNumber())
+ .WillOnce(Return(FUNCTION_FAILED))
+ .WillOnce(Return(FUNCTION_SUCCEEDED));
+ LibYarnClient_t *client = getLibYarnClientT(libyarnClient);
+
+ char *queue = StringToChar("queue");
+
+ LibYarnQueueInfo_t *queueInfo = NULL;
+ int result = getQueueInfo(client, queue, true, true, true, &queueInfo);
+
+ EXPECT_EQ(result,FUNCTION_FAILED);
+ result = getQueueInfo(client, queue, true, true, true, &queueInfo);
+ EXPECT_EQ(result,FUNCTION_SUCCEEDED);
+}
+
+TEST_F(TestLibYarnClientC,TestGetClusterNodes){
+ EXPECT_CALL((*libyarnClient),getClusterNodes(_,_)).Times(AnyNumber())
+ .WillOnce(Return(FUNCTION_FAILED))
+ .WillOnce(Return(FUNCTION_SUCCEEDED));
+ LibYarnClient_t *client = getLibYarnClientT(libyarnClient);
+
+ LibYarnNodeReport_t *nodeReportArray;
+ int nodeReportArraySize;
+ int result = getClusterNodes(client, NODE_STATE_RUNNING, &nodeReportArray, &nodeReportArraySize);
+ EXPECT_EQ(result,FUNCTION_FAILED);
+ result = getClusterNodes(client, NODE_STATE_RUNNING, &nodeReportArray, &nodeReportArraySize);
+ EXPECT_EQ(result,FUNCTION_SUCCEEDED);
+}
+
+
+
http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/383818c2/depends/libyarn/test/unit/TestLibYarnClientC.cpp
----------------------------------------------------------------------
diff --git a/depends/libyarn/test/unit/TestLibYarnClientC.cpp b/depends/libyarn/test/unit/TestLibYarnClientC.cpp
deleted file mode 100644
index 09dbe1c..0000000
--- a/depends/libyarn/test/unit/TestLibYarnClientC.cpp
+++ /dev/null
@@ -1,276 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-#include "gtest/gtest.h"
-#include "gmock/gmock.h"
-
-#include "libyarnclient/LibYarnClientC.h"
-#include "MockLibYarnClient.h"
-
-using std::string;
-using namespace libyarn;
-using namespace testing;
-using namespace Mock;
-
-
-extern "C" LibYarnClient_t* getLibYarnClientT(LibYarnClient *libyarnClient);
-
-class TestLibYarnClientC: public ::testing::Test {
-public:
- TestLibYarnClientC(){
- string amUser("postgres");
- string rmHost("localhost");
- string rmPort("8032");
- string schedHost("localhost");
- string schedPort("8030");
- string amHost("localhost");
- int32_t amPort = 0;
- string am_tracking_url("url");
- int heartbeatInterval = 1000;
- libyarnClient = new MockLibYarnClient(amUser, rmHost, rmPort, schedHost, schedPort, amHost, amPort, am_tracking_url,heartbeatInterval);
- }
- ~TestLibYarnClientC(){
- delete libyarnClient;
- }
-protected:
- MockLibYarnClient *libyarnClient;
-};
-
-static char* StringToChar(string str){
- char *cstr = new char[str.length()+1];
- strcpy(cstr,str.c_str());
- return cstr;
-}
-
-TEST_F(TestLibYarnClientC,TestNewLibYarnClient){
- char *amUser = StringToChar("postgres");
- char *rmHost = StringToChar("localhost");
- char *rmPort = StringToChar("8032");
- char *schedHost = StringToChar("localhost");
- char *schedPort = StringToChar("8030");
- char *amHost = StringToChar("localhost");
- int32_t amPort = 8090;
- char *am_tracking_url = StringToChar("url");
- int heartbeatInterval = 1000;
- LibYarnClient_t *client = NULL;
- int result = newLibYarnClient(amUser, rmHost, rmPort, schedHost, schedPort,
- amHost, amPort, am_tracking_url,&client,heartbeatInterval);
- EXPECT_EQ(result,FUNCTION_SUCCEEDED);
-}
-
-TEST_F(TestLibYarnClientC,TestCreateJob){
- EXPECT_CALL((*libyarnClient),createJob(_,_,_)).Times(AnyNumber())
- .WillOnce(Return(FUNCTION_FAILED))
- .WillOnce(Return(FUNCTION_SUCCEEDED));
- LibYarnClient_t *client = getLibYarnClientT(libyarnClient);
- char *jobName = StringToChar("libyarn");
- char *queue = StringToChar("default");
- char *jobId = NULL;
- int result = createJob(client, jobName, queue,&jobId);
- EXPECT_STREQ("",(const char *)(jobId));
- EXPECT_EQ(result,FUNCTION_FAILED);
-
- result = createJob(client, jobName, queue,&jobId);
- EXPECT_STREQ("",(const char *)(jobId));
- EXPECT_EQ(result,FUNCTION_SUCCEEDED);
-}
-
-TEST_F(TestLibYarnClientC,TestAllocateResources){
- EXPECT_CALL((*libyarnClient),allocateResources(_,_,_,_,_)).Times(AnyNumber())
- .WillOnce(Return(FUNCTION_FAILED))
- .WillOnce(Return(FUNCTION_SUCCEEDED));
- LibYarnClient_t *client = getLibYarnClientT(libyarnClient);
- char *jobId = StringToChar("");
- LibYarnResourceRequest_t resRequest;
- resRequest.priority = 1;
- resRequest.host = StringToChar("*");
- resRequest.vCores = 1;
- resRequest.memory = 1024;
- resRequest.num_containers = 2;
- resRequest.relax_locality = 1;
-
- int blacklistAddsSize = 3;
- char *blackListAdditions[blacklistAddsSize];
- for (int i = 0;i<blacklistAddsSize;i++){
- blackListAdditions[i] = StringToChar("");
- }
- int blackListRemovalsSize = 3;
- char *blackListRemovals[blackListRemovalsSize];
- for (int i = 0;i<blackListRemovalsSize;i++){
- blackListRemovals[i] = StringToChar("");
- }
-
- LibYarnResource_t *allocatedResourcesArray;
- int allocatedResourceArraySize;
-
- int result = allocateResources(client, jobId, 1, 1, 1024, 2, blackListAdditions,
- blacklistAddsSize, blackListRemovals, blackListRemovalsSize, NULL, 0, &allocatedResourcesArray, &allocatedResourceArraySize);
- EXPECT_EQ(result,FUNCTION_FAILED);
-
- result = allocateResources(client, jobId, 1, 1, 1024, 2, blackListAdditions,
- blacklistAddsSize, blackListRemovals, blackListRemovalsSize, NULL, 0, &allocatedResourcesArray, &allocatedResourceArraySize);
- EXPECT_EQ(result,FUNCTION_SUCCEEDED);
- EXPECT_EQ(0,allocatedResourceArraySize);
-}
-
-TEST_F(TestLibYarnClientC,TestActiveResources){
- EXPECT_CALL((*libyarnClient),activeResources(_,_,_)).Times(AnyNumber())
- .WillOnce(Return(FUNCTION_FAILED))
- .WillOnce(Return(FUNCTION_SUCCEEDED));
- LibYarnClient_t *client = getLibYarnClientT(libyarnClient);
-
- int activeContainerSize = 0;
- int64_t activeContainerIds[activeContainerSize];
- char *jobId = StringToChar("");
- int result = activeResources(client, jobId, activeContainerIds,activeContainerSize);
- EXPECT_EQ(result,FUNCTION_FAILED);
- result = activeResources(client, jobId, activeContainerIds,activeContainerSize);
- EXPECT_EQ(result,FUNCTION_SUCCEEDED);
-}
-
-TEST_F(TestLibYarnClientC,TestReleaseResources){
- EXPECT_CALL((*libyarnClient),releaseResources(_,_,_)).Times(AnyNumber())
- .WillOnce(Return(FUNCTION_FAILED))
- .WillOnce(Return(FUNCTION_SUCCEEDED));
- LibYarnClient_t *client = getLibYarnClientT(libyarnClient);
-
- int releaseContainerSize = 0;
- int64_t releaseContainerIds[releaseContainerSize];
- char *jobId = StringToChar("");
- int result = releaseResources(client, jobId, releaseContainerIds,releaseContainerSize);
- EXPECT_EQ(result,FUNCTION_FAILED);
- result = releaseResources(client, jobId, releaseContainerIds,releaseContainerSize);
- EXPECT_EQ(result,FUNCTION_SUCCEEDED);
-}
-
-TEST_F(TestLibYarnClientC,TestFinishJob){
- EXPECT_CALL((*libyarnClient),finishJob(_,_)).Times(AnyNumber())
- .WillOnce(Return(FUNCTION_FAILED))
- .WillOnce(Return(FUNCTION_SUCCEEDED));
- LibYarnClient_t *client = getLibYarnClientT(libyarnClient);
-
- char *jobId = StringToChar("");
- int result = finishJob(client, jobId, APPLICATION_SUCCEEDED);
- EXPECT_EQ(result,FUNCTION_FAILED);
- result = finishJob(client, jobId, APPLICATION_SUCCEEDED);
- EXPECT_EQ(result,FUNCTION_SUCCEEDED);
-}
-
-TEST_F(TestLibYarnClientC,TestGetActiveFailContainerIds){
- EXPECT_CALL((*libyarnClient),getActiveFailContainerIds(_)).Times(AnyNumber())
- .WillOnce(Return(FUNCTION_FAILED))
- .WillOnce(Return(FUNCTION_SUCCEEDED));
- LibYarnClient_t *client = getLibYarnClientT(libyarnClient);
-
- int64_t *activeFailIds;
- int activeFailSize;
- int result = getActiveFailContainerIds(client,&activeFailIds,&activeFailSize);
- EXPECT_EQ(result,FUNCTION_FAILED);
-
- result = getActiveFailContainerIds(client,&activeFailIds,&activeFailSize);
- EXPECT_EQ(result,FUNCTION_SUCCEEDED);
- EXPECT_EQ(0,activeFailSize);
-}
-
-TEST_F(TestLibYarnClientC,TestGetApplicationReport){
- EXPECT_CALL((*libyarnClient),getApplicationReport(_,_)).Times(AnyNumber())
- .WillOnce(Return(FUNCTION_FAILED))
- .WillOnce(Return(FUNCTION_SUCCEEDED));
- LibYarnClient_t *client = getLibYarnClientT(libyarnClient);
-
- LibYarnApplicationReport_t *applicationReport = NULL;
- char *jobId = StringToChar("");
- int result = getApplicationReport(client, jobId, &applicationReport);
- EXPECT_EQ(result,FUNCTION_FAILED);
- result = getApplicationReport(client, jobId, &applicationReport);
- EXPECT_EQ(result,FUNCTION_SUCCEEDED);
- EXPECT_EQ(0,applicationReport->appId);
-}
-
-TEST_F(TestLibYarnClientC,TestGetContainerReports){
- EXPECT_CALL((*libyarnClient),getContainerReports(_,_)).Times(AnyNumber())
- .WillOnce(Return(FUNCTION_FAILED))
- .WillOnce(Return(FUNCTION_SUCCEEDED));
- LibYarnClient_t *client = getLibYarnClientT(libyarnClient);
-
- char *jobId = StringToChar("");
- LibYarnContainerReport_t *containerReportArray;
- int containerReportArraySize;
- int result = getContainerReports(client, jobId, &containerReportArray,
- &containerReportArraySize);
- EXPECT_EQ(result,FUNCTION_FAILED);
- result = getContainerReports(client, jobId, &containerReportArray,
- &containerReportArraySize);
- EXPECT_EQ(result,FUNCTION_SUCCEEDED);
- EXPECT_EQ(0,containerReportArraySize);
-}
-
-TEST_F(TestLibYarnClientC,TestGetContainerStatuses){
- EXPECT_CALL((*libyarnClient),getContainerStatuses(_,_,_,_)).Times(AnyNumber())
- .WillOnce(Return(FUNCTION_FAILED))
- .WillOnce(Return(FUNCTION_SUCCEEDED));
- LibYarnClient_t *client = getLibYarnClientT(libyarnClient);
-
- char *jobId = StringToChar("");
-
- int statusContainerSize = 0;
- int64_t statusContainerIds[statusContainerSize];
- LibYarnContainerStatus_t *containerStatusArray;
- int containerStatusArraySize;
- int result = getContainerStatuses(client, jobId, statusContainerIds,
- statusContainerSize, &containerStatusArray,&containerStatusArraySize);
- EXPECT_EQ(result,FUNCTION_FAILED);
- result = getContainerStatuses(client, jobId, statusContainerIds,
- statusContainerSize, &containerStatusArray,&containerStatusArraySize);
- EXPECT_EQ(result,FUNCTION_SUCCEEDED);
- EXPECT_EQ(0,containerStatusArraySize);
-}
-
-TEST_F(TestLibYarnClientC,TestGetQueueInfo){
- EXPECT_CALL((*libyarnClient),getQueueInfo(_,_,_,_,_)).Times(AnyNumber())
- .WillOnce(Return(FUNCTION_FAILED))
- .WillOnce(Return(FUNCTION_SUCCEEDED));
- LibYarnClient_t *client = getLibYarnClientT(libyarnClient);
-
- char *queue = StringToChar("queue");
-
- LibYarnQueueInfo_t *queueInfo = NULL;
- int result = getQueueInfo(client, queue, true, true, true, &queueInfo);
-
- EXPECT_EQ(result,FUNCTION_FAILED);
- result = getQueueInfo(client, queue, true, true, true, &queueInfo);
- EXPECT_EQ(result,FUNCTION_SUCCEEDED);
-}
-
-TEST_F(TestLibYarnClientC,TestGetClusterNodes){
- EXPECT_CALL((*libyarnClient),getClusterNodes(_,_)).Times(AnyNumber())
- .WillOnce(Return(FUNCTION_FAILED))
- .WillOnce(Return(FUNCTION_SUCCEEDED));
- LibYarnClient_t *client = getLibYarnClientT(libyarnClient);
-
- LibYarnNodeReport_t *nodeReportArray;
- int nodeReportArraySize;
- int result = getClusterNodes(client, NODE_STATE_RUNNING, &nodeReportArray, &nodeReportArraySize);
- EXPECT_EQ(result,FUNCTION_FAILED);
- result = getClusterNodes(client, NODE_STATE_RUNNING, &nodeReportArray, &nodeReportArraySize);
- EXPECT_EQ(result,FUNCTION_SUCCEEDED);
-}
-
-
-
http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/383818c2/depends/libyarn/test/unit/TestLibYarnServer/TestApplicationClientProtocol.cpp
----------------------------------------------------------------------
diff --git a/depends/libyarn/test/unit/TestLibYarnServer/TestApplicationClientProtocol.cpp b/depends/libyarn/test/unit/TestLibYarnServer/TestApplicationClientProtocol.cpp
new file mode 100644
index 0000000..e6f4bf5
--- /dev/null
+++ b/depends/libyarn/test/unit/TestLibYarnServer/TestApplicationClientProtocol.cpp
@@ -0,0 +1,213 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+#include <string>
+
+#include "gtest/gtest.h"
+#include "gmock/gmock.h"
+
+#include "rpc/RpcAuth.h"
+#include "common/SessionConfig.h"
+#include "common/Exception.h"
+
+#include "protocolrecords/GetNewApplicationRequest.h"
+#include "protocolrecords/GetNewApplicationResponse.h"
+#include "protocolrecords/SubmitApplicationRequest.h"
+#include "protocolrecords/GetApplicationReportRequest.h"
+#include "protocolrecords/GetApplicationReportResponse.h"
+#include "protocolrecords/GetContainersRequest.h"
+#include "protocolrecords/GetContainersResponse.h"
+#include "protocolrecords/GetClusterNodesRequest.h"
+#include "protocolrecords/GetClusterNodesResponse.h"
+#include "protocolrecords/GetQueueInfoRequest.h"
+#include "protocolrecords/GetQueueInfoResponse.h"
+#include "protocolrecords/GetClusterMetricsRequest.h"
+#include "protocolrecords/GetClusterMetricsResponse.h"
+#include "protocolrecords/KillApplicationRequest.h"
+#include "protocolrecords/KillApplicationResponse.h"
+#include "protocolrecords/GetApplicationsRequest.h"
+#include "protocolrecords/GetApplicationsResponse.h"
+#include "protocolrecords/GetQueueUserAclsInfoRequest.h"
+#include "protocolrecords/GetQueueUserAclsInfoResponse.h"
+
+#include "libyarnserver/ApplicationClientProtocol.h"
+#include "MockApplicationClientProtocolInternal.h"
+
+using std::string;
+using Yarn::Internal::RpcAuth;
+using Yarn::Internal::SessionConfig;
+using Yarn::Config;
+using namespace libyarn;
+using namespace testing;
+using namespace Mock;
+using namespace Yarn;
+
+class TestApplicationClientProtocol: public ::testing::Test {
+public:
+ TestApplicationClientProtocol():
+ user("postgres"), rmHost("localhost"), rmPort("8032"), sc(conf){}
+ ~TestApplicationClientProtocol(){
+ }
+protected:
+ const string user;
+ const string rmHost;
+ const string rmPort;
+ const string tokenService;
+ const Config conf;
+ const SessionConfig sc;
+};
+
+TEST_F(TestApplicationClientProtocol, TestGetNewApplicationException){
+ MockApplicationClientProtocolInternal macp(user, rmHost, rmPort, tokenService, sc);
+ GetNewApplicationRequest gnareq;
+ GetNewApplicationResponse gnares;
+
+ EXPECT_CALL(macp, invoke(_)).Times(3).WillOnce(Throw(YarnFailoverException("", __FILE__, __LINE__, Yarn::Internal::PrintStack(1, STACK_DEPTH).c_str())))
+ .WillOnce(Throw(YarnRpcServerException("", __FILE__, __LINE__, Yarn::Internal::PrintStack(1, STACK_DEPTH).c_str())))
+ .WillOnce(Throw(YarnException("", __FILE__, __LINE__, Yarn::Internal::PrintStack(1, STACK_DEPTH).c_str())));
+
+ EXPECT_THROW(gnares = macp.getNewApplication(gnareq), YarnFailoverException);
+ EXPECT_THROW(gnares = macp.getNewApplication(gnareq), YarnIOException);
+ EXPECT_THROW(gnares = macp.getNewApplication(gnareq), YarnIOException);
+}
+
+TEST_F(TestApplicationClientProtocol, TestSubmitApplicationException){
+ MockApplicationClientProtocolInternal macp(user, rmHost, rmPort, tokenService, sc);
+ SubmitApplicationRequest sareq;
+
+ EXPECT_CALL(macp, invoke(_)).Times(3).WillOnce(Throw(YarnFailoverException("", __FILE__, __LINE__, Yarn::Internal::PrintStack(1, STACK_DEPTH).c_str())))
+ .WillOnce(Throw(YarnRpcServerException("", __FILE__, __LINE__, Yarn::Internal::PrintStack(1, STACK_DEPTH).c_str())))
+ .WillOnce(Throw(YarnException("", __FILE__, __LINE__, Yarn::Internal::PrintStack(1, STACK_DEPTH).c_str())));
+
+ EXPECT_THROW(macp.submitApplication(sareq), YarnFailoverException);
+ EXPECT_THROW(macp.submitApplication(sareq), YarnIOException);
+ EXPECT_THROW(macp.submitApplication(sareq), YarnIOException);
+}
+
+TEST_F(TestApplicationClientProtocol, TestGetApplicationReportException){
+ MockApplicationClientProtocolInternal macp(user, rmHost, rmPort, tokenService, sc);
+ GetApplicationReportRequest garreq;
+ GetApplicationReportResponse garres;
+
+ EXPECT_CALL(macp, invoke(_)).Times(3).WillOnce(Throw(YarnFailoverException("", __FILE__, __LINE__, Yarn::Internal::PrintStack(1, STACK_DEPTH).c_str())))
+ .WillOnce(Throw(YarnRpcServerException("", __FILE__, __LINE__, Yarn::Internal::PrintStack(1, STACK_DEPTH).c_str())))
+ .WillOnce(Throw(YarnException("", __FILE__, __LINE__, Yarn::Internal::PrintStack(1, STACK_DEPTH).c_str())));
+
+ EXPECT_THROW(macp.getApplicationReport(garreq), YarnFailoverException);
+ EXPECT_THROW(macp.getApplicationReport(garreq), YarnIOException);
+ EXPECT_THROW(macp.getApplicationReport(garreq), YarnIOException);
+}
+
+TEST_F(TestApplicationClientProtocol, TestGetContainersException){
+ MockApplicationClientProtocolInternal macp(user, rmHost, rmPort, tokenService, sc);
+ GetContainersRequest gcreq;
+ GetContainersResponse gcres;
+
+ EXPECT_CALL(macp, invoke(_)).Times(3).WillOnce(Throw(YarnFailoverException("", __FILE__, __LINE__, Yarn::Internal::PrintStack(1, STACK_DEPTH).c_str())))
+ .WillOnce(Throw(YarnRpcServerException("", __FILE__, __LINE__, Yarn::Internal::PrintStack(1, STACK_DEPTH).c_str())))
+ .WillOnce(Throw(YarnException("", __FILE__, __LINE__, Yarn::Internal::PrintStack(1, STACK_DEPTH).c_str())));
+
+ EXPECT_THROW(macp.getContainers(gcreq), YarnFailoverException);
+ EXPECT_THROW(macp.getContainers(gcreq), YarnIOException);
+ EXPECT_THROW(macp.getContainers(gcreq), YarnIOException);
+}
+
+TEST_F(TestApplicationClientProtocol, TestGetClusterNodesException){
+ MockApplicationClientProtocolInternal macp(user, rmHost, rmPort, tokenService, sc);
+ GetClusterNodesRequest gcnreq;
+ GetClusterNodesResponse gcnres;
+
+ EXPECT_CALL(macp, invoke(_)).Times(3).WillOnce(Throw(YarnFailoverException("", __FILE__, __LINE__, Yarn::Internal::PrintStack(1, STACK_DEPTH).c_str())))
+ .WillOnce(Throw(YarnRpcServerException("", __FILE__, __LINE__, Yarn::Internal::PrintStack(1, STACK_DEPTH).c_str())))
+ .WillOnce(Throw(YarnException("", __FILE__, __LINE__, Yarn::Internal::PrintStack(1, STACK_DEPTH).c_str())));
+
+ EXPECT_THROW(macp.getClusterNodes(gcnreq), YarnFailoverException);
+ EXPECT_THROW(macp.getClusterNodes(gcnreq), YarnIOException);
+ EXPECT_THROW(macp.getClusterNodes(gcnreq), YarnIOException);
+}
+
+TEST_F(TestApplicationClientProtocol, TestGetQueueInfoException){
+ MockApplicationClientProtocolInternal macp(user, rmHost, rmPort, tokenService, sc);
+ GetQueueInfoRequest gqireq;
+ GetQueueInfoResponse gqires;
+
+ EXPECT_CALL(macp, invoke(_)).Times(3).WillOnce(Throw(YarnFailoverException("", __FILE__, __LINE__, Yarn::Internal::PrintStack(1, STACK_DEPTH).c_str())))
+ .WillOnce(Throw(YarnRpcServerException("", __FILE__, __LINE__, Yarn::Internal::PrintStack(1, STACK_DEPTH).c_str())))
+ .WillOnce(Throw(YarnException("", __FILE__, __LINE__, Yarn::Internal::PrintStack(1, STACK_DEPTH).c_str())));
+
+ EXPECT_THROW(macp.getQueueInfo(gqireq), YarnFailoverException);
+ EXPECT_THROW(macp.getQueueInfo(gqireq), YarnIOException);
+ EXPECT_THROW(macp.getQueueInfo(gqireq), YarnIOException);
+}
+
+TEST_F(TestApplicationClientProtocol, TestGetClusterMetricsException){
+ MockApplicationClientProtocolInternal macp(user, rmHost, rmPort, tokenService, sc);
+ GetClusterMetricsRequest gcmreq;
+ GetClusterMetricsResponse gcmres;
+
+ EXPECT_CALL(macp, invoke(_)).Times(3).WillOnce(Throw(YarnFailoverException("", __FILE__, __LINE__, Yarn::Internal::PrintStack(1, STACK_DEPTH).c_str())))
+ .WillOnce(Throw(YarnRpcServerException("", __FILE__, __LINE__, Yarn::Internal::PrintStack(1, STACK_DEPTH).c_str())))
+ .WillOnce(Throw(YarnException("", __FILE__, __LINE__, Yarn::Internal::PrintStack(1, STACK_DEPTH).c_str())));
+
+ EXPECT_THROW(macp.getClusterMetrics(gcmreq), YarnFailoverException);
+ EXPECT_THROW(macp.getClusterMetrics(gcmreq), YarnIOException);
+ EXPECT_THROW(macp.getClusterMetrics(gcmreq), YarnIOException);
+}
+
+TEST_F(TestApplicationClientProtocol, TestForceKillApplicationException){
+ MockApplicationClientProtocolInternal macp(user, rmHost, rmPort, tokenService, sc);
+ KillApplicationRequest kareq;
+ KillApplicationResponse kares;
+
+ EXPECT_CALL(macp, invoke(_)).Times(3).WillOnce(Throw(YarnFailoverException("", __FILE__, __LINE__, Yarn::Internal::PrintStack(1, STACK_DEPTH).c_str())))
+ .WillOnce(Throw(YarnRpcServerException("", __FILE__, __LINE__, Yarn::Internal::PrintStack(1, STACK_DEPTH).c_str())))
+ .WillOnce(Throw(YarnException("", __FILE__, __LINE__, Yarn::Internal::PrintStack(1, STACK_DEPTH).c_str())));
+
+ EXPECT_THROW(macp.forceKillApplication(kareq), YarnFailoverException);
+ EXPECT_THROW(macp.forceKillApplication(kareq), YarnIOException);
+ EXPECT_THROW(macp.forceKillApplication(kareq), YarnIOException);
+}
+
+TEST_F(TestApplicationClientProtocol, TestGetApplicationsException){
+ MockApplicationClientProtocolInternal macp(user, rmHost, rmPort, tokenService, sc);
+ GetApplicationsRequest gareq;
+ GetApplicationsResponse gares;
+
+ EXPECT_CALL(macp, invoke(_)).Times(3).WillOnce(Throw(YarnFailoverException("", __FILE__, __LINE__, Yarn::Internal::PrintStack(1, STACK_DEPTH).c_str())))
+ .WillOnce(Throw(YarnRpcServerException("", __FILE__, __LINE__, Yarn::Internal::PrintStack(1, STACK_DEPTH).c_str())))
+ .WillOnce(Throw(YarnException("", __FILE__, __LINE__, Yarn::Internal::PrintStack(1, STACK_DEPTH).c_str())));
+
+ EXPECT_THROW(macp.getApplications(gareq), YarnFailoverException);
+ EXPECT_THROW(macp.getApplications(gareq), YarnIOException);
+ EXPECT_THROW(macp.getApplications(gareq), YarnIOException);
+}
+
+TEST_F(TestApplicationClientProtocol, TestGetQueueAclsInfoException){
+ MockApplicationClientProtocolInternal macp(user, rmHost, rmPort, tokenService, sc);
+ GetQueueUserAclsInfoRequest gquareq;
+ GetQueueUserAclsInfoResponse gquares;
+
+ EXPECT_CALL(macp, invoke(_)).Times(3).WillOnce(Throw(YarnFailoverException("", __FILE__, __LINE__, Yarn::Internal::PrintStack(1, STACK_DEPTH).c_str())))
+ .WillOnce(Throw(YarnRpcServerException("", __FILE__, __LINE__, Yarn::Internal::PrintStack(1, STACK_DEPTH).c_str())))
+ .WillOnce(Throw(YarnException("", __FILE__, __LINE__, Yarn::Internal::PrintStack(1, STACK_DEPTH).c_str())));
+
+ EXPECT_THROW(macp.getQueueAclsInfo(gquareq), YarnFailoverException);
+ EXPECT_THROW(macp.getQueueAclsInfo(gquareq), YarnIOException);
+ EXPECT_THROW(macp.getQueueAclsInfo(gquareq), YarnIOException);
+}
http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/383818c2/depends/libyarn/test/unit/TestLibYarnServer/TestApplicationMasterProtocol.cpp
----------------------------------------------------------------------
diff --git a/depends/libyarn/test/unit/TestLibYarnServer/TestApplicationMasterProtocol.cpp b/depends/libyarn/test/unit/TestLibYarnServer/TestApplicationMasterProtocol.cpp
new file mode 100644
index 0000000..85069cb
--- /dev/null
+++ b/depends/libyarn/test/unit/TestLibYarnServer/TestApplicationMasterProtocol.cpp
@@ -0,0 +1,96 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+#include <string>
+
+#include "gtest/gtest.h"
+#include "gmock/gmock.h"
+
+#include "rpc/RpcAuth.h"
+#include "common/SessionConfig.h"
+#include "common/Exception.h"
+
+#include "protocolrecords/RegisterApplicationMasterRequest.h"
+#include "protocolrecords/RegisterApplicationMasterResponse.h"
+#include "protocolrecords/AllocateRequest.h"
+#include "protocolrecords/AllocateResponse.h"
+#include "protocolrecords/FinishApplicationMasterRequest.h"
+#include "protocolrecords/FinishApplicationMasterResponse.h"
+
+#include "libyarnserver/ApplicationMasterProtocol.h"
+#include "MockApplicationMasterProtocolInternal.h"
+
+using std::string;
+using Yarn::Internal::RpcAuth;
+using Yarn::Internal::SessionConfig;
+using Yarn::Config;
+using namespace libyarn;
+using namespace testing;
+using namespace Mock;
+using namespace Yarn;
+
+class TestApplicationMasterProtocol: public ::testing::Test {
+public:
+ TestApplicationMasterProtocol():
+ schedHost("localhost"), schedPort("8030"), sc(conf){}
+ ~TestApplicationMasterProtocol(){
+ }
+protected:
+ const string schedHost;
+ const string schedPort;
+ const string tokenService;
+ const RpcAuth ra;
+ const Config conf;
+ const SessionConfig sc;
+};
+
+TEST_F(TestApplicationMasterProtocol, TestRegisterApplicationMasterException){
+ MockApplicationMasterProtocolInternal mamp(schedHost, schedPort, tokenService, sc, ra);
+ RegisterApplicationMasterRequest ramreq;
+ RegisterApplicationMasterResponse ramres;
+
+ EXPECT_CALL(mamp, invoke(_)).Times(1).WillOnce(Throw(YarnException("", __FILE__, __LINE__, Yarn::Internal::PrintStack(1, STACK_DEPTH).c_str())));
+
+ EXPECT_THROW(ramres = mamp.registerApplicationMaster(ramreq), YarnIOException);
+}
+
+TEST_F(TestApplicationMasterProtocol, TestAllocateException){
+ MockApplicationMasterProtocolInternal mamp(schedHost, schedPort, tokenService, sc, ra);
+ AllocateRequest areq;
+ AllocateResponse ares;
+
+ EXPECT_CALL(mamp, invoke(_)).Times(1).WillOnce(Throw(YarnException("", __FILE__, __LINE__, Yarn::Internal::PrintStack(1, STACK_DEPTH).c_str())));
+
+ EXPECT_THROW(ares = mamp.allocate(areq), YarnIOException);
+}
+
+TEST_F(TestApplicationMasterProtocol, TestFinishApplicationMasterException){
+ MockApplicationMasterProtocolInternal mamp(schedHost, schedPort, tokenService, sc, ra);
+ FinishApplicationMasterRequest famreq;
+ FinishApplicationMasterResponse famres;
+
+ EXPECT_CALL(mamp, invoke(_)).Times(3).WillOnce(Throw(YarnFailoverException("", __FILE__, __LINE__, Yarn::Internal::PrintStack(1, STACK_DEPTH).c_str())))
+ .WillOnce(Throw(YarnRpcServerException("", __FILE__, __LINE__, Yarn::Internal::PrintStack(1, STACK_DEPTH).c_str())))
+ .WillOnce(Throw(YarnException("", __FILE__, __LINE__, Yarn::Internal::PrintStack(1, STACK_DEPTH).c_str())));
+
+
+ EXPECT_THROW(famres = mamp.finishApplicationMaster(famreq), YarnFailoverException);
+ EXPECT_THROW(famres = mamp.finishApplicationMaster(famreq), YarnIOException);
+ EXPECT_THROW(famres = mamp.finishApplicationMaster(famreq), YarnIOException);
+}
[2/5] incubator-hawq git commit: HAWQ-891. Refine libyarn codes
Posted by wl...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/383818c2/depends/libyarn/test/unit/TestLibYarnServer/TestContainerManagementProtocol.cpp
----------------------------------------------------------------------
diff --git a/depends/libyarn/test/unit/TestLibYarnServer/TestContainerManagementProtocol.cpp b/depends/libyarn/test/unit/TestLibYarnServer/TestContainerManagementProtocol.cpp
new file mode 100644
index 0000000..7fa3b5a
--- /dev/null
+++ b/depends/libyarn/test/unit/TestLibYarnServer/TestContainerManagementProtocol.cpp
@@ -0,0 +1,101 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+#include <string>
+
+#include "gtest/gtest.h"
+#include "gmock/gmock.h"
+
+#include "rpc/RpcAuth.h"
+#include "common/SessionConfig.h"
+#include "common/Exception.h"
+
+
+#include "protocolrecords/StartContainersRequest.h"
+#include "protocolrecords/StartContainersResponse.h"
+#include "protocolrecords/StopContainersRequest.h"
+#include "protocolrecords/StopContainersResponse.h"
+#include "protocolrecords/GetContainerStatusesRequest.h"
+#include "protocolrecords/GetContainerStatusesResponse.h"
+
+#include "libyarnserver/ContainerManagementProtocol.h"
+#include "MockContainerManagementProtocolInternal.h"
+
+using std::string;
+
+using Yarn::Internal::RpcAuth;
+using Yarn::Internal::SessionConfig;
+using Yarn::Config;
+using namespace libyarn;
+using namespace testing;
+using namespace Mock;
+using namespace Yarn;
+
+class TestContainerManagementProtocol: public ::testing::Test {
+public:
+ TestContainerManagementProtocol():
+ nmHost("localhost"), nmPort("8032"), tokenService(""), sc(conf){}
+ ~TestContainerManagementProtocol(){
+ }
+protected:
+ string nmHost;
+ string nmPort;
+ const string tokenService;
+ const RpcAuth ra;
+ const Config conf;
+ const SessionConfig sc;
+};
+
+TEST_F(TestContainerManagementProtocol,TestStartContainersException){
+ MockContainerManagementProtocolInternal mcmp(nmHost, nmPort, tokenService, sc, ra);
+
+ StartContainersRequest screq;
+ StartContainersResponse scres;
+
+ EXPECT_CALL(mcmp, invoke(_)).Times(2).WillOnce(Throw(YarnRpcServerException("", __FILE__, __LINE__, Yarn::Internal::PrintStack(1, STACK_DEPTH).c_str())))
+ .WillOnce(Throw(YarnException("", __FILE__, __LINE__, Yarn::Internal::PrintStack(1, STACK_DEPTH).c_str())));
+
+ EXPECT_THROW(scres = mcmp.startContainers(screq), YarnIOException);
+ EXPECT_THROW(scres = mcmp.startContainers(screq), YarnIOException);
+}
+
+TEST_F(TestContainerManagementProtocol,TestStopContainersException){
+ MockContainerManagementProtocolInternal mcmp(nmHost, nmPort, tokenService, sc, ra);
+ StopContainersRequest screq;
+ StopContainersResponse scres;
+
+ EXPECT_CALL(mcmp, invoke(_)).Times(2).WillOnce(Throw(YarnRpcServerException("", __FILE__, __LINE__, Yarn::Internal::PrintStack(1, STACK_DEPTH).c_str())))
+ .WillOnce(Throw(YarnException("", __FILE__, __LINE__, Yarn::Internal::PrintStack(1, STACK_DEPTH).c_str())));
+
+ EXPECT_THROW(scres = mcmp.stopContainers(screq), YarnIOException);
+ EXPECT_THROW(scres = mcmp.stopContainers(screq), YarnIOException);
+}
+
+
+TEST_F(TestContainerManagementProtocol,getContainerStatusesException){
+ MockContainerManagementProtocolInternal mcmp(nmHost, nmPort, tokenService, sc, ra);
+ GetContainerStatusesRequest gcsreq;
+ GetContainerStatusesResponse gcsres;
+
+ EXPECT_CALL(mcmp, invoke(_)).Times(2).WillOnce(Throw(YarnRpcServerException("", __FILE__, __LINE__, Yarn::Internal::PrintStack(1, STACK_DEPTH).c_str())))
+ .WillOnce(Throw(YarnException("", __FILE__, __LINE__, Yarn::Internal::PrintStack(1, STACK_DEPTH).c_str())));
+
+ EXPECT_THROW(gcsres = mcmp.getContainerStatuses(gcsreq), YarnIOException);
+ EXPECT_THROW(gcsres = mcmp.getContainerStatuses(gcsreq), YarnIOException);
+}
http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/383818c2/depends/libyarn/test/unit/TestProtocolRecords/TestAllocateRequest.cpp
----------------------------------------------------------------------
diff --git a/depends/libyarn/test/unit/TestProtocolRecords/TestAllocateRequest.cpp b/depends/libyarn/test/unit/TestProtocolRecords/TestAllocateRequest.cpp
new file mode 100644
index 0000000..7be8cff
--- /dev/null
+++ b/depends/libyarn/test/unit/TestProtocolRecords/TestAllocateRequest.cpp
@@ -0,0 +1,104 @@
+/*
+ * Licensed to the Apache SoftwallocateRequeste Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regallocateRequestding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * softwallocateRequeste distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+#include <list>
+
+#include "gtest/gtest.h"
+#include "gmock/gmock.h"
+
+#include "protocolrecords/AllocateRequest.h"
+
+using std::list;
+using namespace libyarn;
+using namespace testing;
+
+class TestAllocateRequest: public ::testing::Test {
+protected:
+ AllocateRequest allocateRequest;
+};
+
+TEST_F(TestAllocateRequest, TestAddAsk)
+{
+ ResourceRequest ask;
+
+ allocateRequest.addAsk(ask);
+
+ SUCCEED();
+}
+
+TEST_F(TestAllocateRequest, TestGetAsks)
+{
+ ResourceRequest ask;
+ list<ResourceRequest> asks;
+
+ allocateRequest.addAsk(ask);
+ asks = allocateRequest.getAsks();
+
+ SUCCEED();
+}
+
+TEST_F(TestAllocateRequest, TestAddRelease)
+{
+ ContainerId release;
+
+ allocateRequest.addRelease(release);
+
+ SUCCEED();
+}
+
+TEST_F(TestAllocateRequest, TestGetRelease)
+{
+ ContainerId release;
+ list<ContainerId> releases;
+
+ allocateRequest.addRelease(release);
+ releases = allocateRequest.getReleases();
+
+ SUCCEED();
+}
+
+TEST_F(TestAllocateRequest, TestGetBlackListRequest)
+{
+ ResourceBlacklistRequest blacklistRequest;
+
+ blacklistRequest = allocateRequest.getBlacklistRequest();
+
+ SUCCEED();
+}
+
+TEST_F(TestAllocateRequest, TestGetResponseId)
+{
+ int32_t responseId = -1;
+ int32_t retResponseId;
+
+ allocateRequest.setResponseId(responseId);
+ retResponseId = allocateRequest.getResponseId();
+ EXPECT_EQ(responseId, retResponseId);
+
+}
+
+TEST_F(TestAllocateRequest, TestGetProgress)
+{
+ float progress = 0.0;
+ float retProgress;
+
+ allocateRequest.setProgress(progress);
+ retProgress = allocateRequest.getProgress();
+ EXPECT_EQ(progress, retProgress);
+}
http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/383818c2/depends/libyarn/test/unit/TestProtocolRecords/TestAllocateResponse.cpp
----------------------------------------------------------------------
diff --git a/depends/libyarn/test/unit/TestProtocolRecords/TestAllocateResponse.cpp b/depends/libyarn/test/unit/TestProtocolRecords/TestAllocateResponse.cpp
new file mode 100644
index 0000000..bf00289
--- /dev/null
+++ b/depends/libyarn/test/unit/TestProtocolRecords/TestAllocateResponse.cpp
@@ -0,0 +1,67 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+#include <list>
+
+#include "gtest/gtest.h"
+#include "gmock/gmock.h"
+
+#include "protocolrecords/AllocateResponse.h"
+
+using std::list;
+using namespace libyarn;
+using namespace testing;
+
+class TestAllocateResponse: public ::testing::Test {
+protected:
+ AllocateResponse allocateResponse;
+};
+
+TEST_F(TestAllocateResponse, TestGetProto)
+{
+ AllocateResponseProto responseProto;
+
+ responseProto = allocateResponse.getProto();
+
+ SUCCEED();
+}
+
+TEST_F(TestAllocateResponse, TestGetUpdaedNodes)
+{
+ list<NodeReport> updatedNodes;
+ NodeReport nodeReport;
+ list<NodeReport> retUpdatedNodes;
+
+ updatedNodes.push_back(nodeReport);
+
+ allocateResponse.setUpdatedNodes(updatedNodes);
+ retUpdatedNodes = allocateResponse.getUpdatedNodes();
+
+ SUCCEED();
+}
+
+TEST_F(TestAllocateResponse, TestGetPreemptionMessage)
+{
+ PreemptionMessage preempt;
+ PreemptionMessage retPreempt;
+
+ allocateResponse.setPreemptionMessage(preempt);
+ retPreempt = allocateResponse.getPreemptionMessage();
+
+ SUCCEED();
+}
http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/383818c2/depends/libyarn/test/unit/TestProtocolRecords/TestFinishApplicationMasterRequest.cpp
----------------------------------------------------------------------
diff --git a/depends/libyarn/test/unit/TestProtocolRecords/TestFinishApplicationMasterRequest.cpp b/depends/libyarn/test/unit/TestProtocolRecords/TestFinishApplicationMasterRequest.cpp
new file mode 100644
index 0000000..8fe2fd5
--- /dev/null
+++ b/depends/libyarn/test/unit/TestProtocolRecords/TestFinishApplicationMasterRequest.cpp
@@ -0,0 +1,70 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+#include <string>
+
+#include "gtest/gtest.h"
+#include "gmock/gmock.h"
+
+#include "protocolrecords/FinishApplicationMasterRequest.h"
+
+using std::string;
+using namespace libyarn;
+using namespace testing;
+
+class TestFinishApplicationMasterRequest: public ::testing::Test {
+protected:
+ FinishApplicationMasterRequest finishRequest;
+};
+
+TEST_F(TestFinishApplicationMasterRequest, TestFinishApplicationMasterRequest)
+{
+ FinishApplicationMasterRequestProto finishRequestProto;
+ finishRequest = FinishApplicationMasterRequest(finishRequestProto);
+
+ SUCCEED();
+}
+
+TEST_F(TestFinishApplicationMasterRequest, TestGetDiagnostics)
+{
+ string diagnostics("diagnostics");
+ string retDiagnostics;
+ finishRequest.setDiagnostics(diagnostics);
+ retDiagnostics = finishRequest.getDiagnostics();
+
+ EXPECT_EQ(diagnostics, retDiagnostics);
+}
+
+TEST_F(TestFinishApplicationMasterRequest, TestGetTrackingUrl)
+{
+ string trackingUrl("trackingUrl");
+ string retTrackingUrl;
+ finishRequest.setTrackingUrl(trackingUrl);
+ retTrackingUrl = finishRequest.getTrackingUrl();
+
+ EXPECT_EQ(trackingUrl, retTrackingUrl);
+}
+
+TEST_F(TestFinishApplicationMasterRequest, TestFinalApplicationStatus)
+{
+ FinalApplicationStatus finalStatus;
+ finalStatus = finishRequest.getFinalApplicationStatus();
+
+ SUCCEED();
+}
http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/383818c2/depends/libyarn/test/unit/TestProtocolRecords/TestFinishApplicationMasterResponse.cpp
----------------------------------------------------------------------
diff --git a/depends/libyarn/test/unit/TestProtocolRecords/TestFinishApplicationMasterResponse.cpp b/depends/libyarn/test/unit/TestProtocolRecords/TestFinishApplicationMasterResponse.cpp
new file mode 100644
index 0000000..97f2461
--- /dev/null
+++ b/depends/libyarn/test/unit/TestProtocolRecords/TestFinishApplicationMasterResponse.cpp
@@ -0,0 +1,39 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+#include "gtest/gtest.h"
+#include "gmock/gmock.h"
+
+#include "protocolrecords/FinishApplicationMasterResponse.h"
+
+using namespace libyarn;
+using namespace testing;
+
+class TestFinishApplicationMasterResponse: public ::testing::Test {
+protected:
+ FinishApplicationMasterResponse finishResponse;
+};
+
+TEST_F(TestFinishApplicationMasterResponse, TestGetProto)
+{
+ FinishApplicationMasterResponseProto finishResponseProto;
+ finishResponseProto = finishResponse.getProto();
+
+ SUCCEED();
+}
http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/383818c2/depends/libyarn/test/unit/TestProtocolRecords/TestGetApplicationReportRequest.cpp
----------------------------------------------------------------------
diff --git a/depends/libyarn/test/unit/TestProtocolRecords/TestGetApplicationReportRequest.cpp b/depends/libyarn/test/unit/TestProtocolRecords/TestGetApplicationReportRequest.cpp
new file mode 100644
index 0000000..e8c92db
--- /dev/null
+++ b/depends/libyarn/test/unit/TestProtocolRecords/TestGetApplicationReportRequest.cpp
@@ -0,0 +1,47 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+#include "gtest/gtest.h"
+#include "gmock/gmock.h"
+
+#include "protocolrecords/GetApplicationReportRequest.h"
+
+using namespace libyarn;
+using namespace testing;
+
+class TestGetApplicationReportRequest: public ::testing::Test {
+protected:
+ GetApplicationReportRequest getRequest;
+};
+
+TEST_F(TestGetApplicationReportRequest, TestGetApplicationReportRequest)
+{
+ GetApplicationReportRequestProto getRequestProto;
+ getRequest = GetApplicationReportRequestProto(getRequestProto);
+
+ SUCCEED();
+}
+
+TEST_F(TestGetApplicationReportRequest, TestGetApplicationId)
+{
+ ApplicationId applicationId;
+ applicationId = getRequest.getApplicationId();
+
+ SUCCEED();
+}
http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/383818c2/depends/libyarn/test/unit/TestProtocolRecords/TestGetApplicationReportResponse.cpp
----------------------------------------------------------------------
diff --git a/depends/libyarn/test/unit/TestProtocolRecords/TestGetApplicationReportResponse.cpp b/depends/libyarn/test/unit/TestProtocolRecords/TestGetApplicationReportResponse.cpp
new file mode 100644
index 0000000..c25a605
--- /dev/null
+++ b/depends/libyarn/test/unit/TestProtocolRecords/TestGetApplicationReportResponse.cpp
@@ -0,0 +1,39 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+#include "gtest/gtest.h"
+#include "gmock/gmock.h"
+
+#include "protocolrecords/GetApplicationReportResponse.h"
+
+using namespace libyarn;
+using namespace testing;
+
+class TestGetApplicationReportResponse: public ::testing::Test {
+protected:
+ GetApplicationReportResponse getResponse;
+};
+
+TEST_F(TestGetApplicationReportResponse, TestGetProto)
+{
+ GetApplicationReportResponseProto getResponseProto;
+ getResponseProto = getResponse.getProto();
+
+ SUCCEED();
+}
http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/383818c2/depends/libyarn/test/unit/TestProtocolRecords/TestGetApplicationsRequest.cpp
----------------------------------------------------------------------
diff --git a/depends/libyarn/test/unit/TestProtocolRecords/TestGetApplicationsRequest.cpp b/depends/libyarn/test/unit/TestProtocolRecords/TestGetApplicationsRequest.cpp
new file mode 100644
index 0000000..088afa0
--- /dev/null
+++ b/depends/libyarn/test/unit/TestProtocolRecords/TestGetApplicationsRequest.cpp
@@ -0,0 +1,70 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+#include <list>
+#include <string>
+
+#include "gtest/gtest.h"
+#include "gmock/gmock.h"
+
+#include "protocolrecords/GetApplicationsRequest.h"
+
+using std::list;
+using std::string;
+using namespace libyarn;
+using namespace testing;
+
+class TestGetApplicationsRequest: public ::testing::Test {
+protected:
+ GetApplicationsRequest getRequest;
+};
+
+TEST_F(TestGetApplicationsRequest, TestGetApplicationRequest)
+{
+ GetApplicationsRequestProto getRequestProto;
+ getRequest = GetApplicationsRequestProto(getRequestProto);
+
+ SUCCEED();
+}
+
+TEST_F(TestGetApplicationsRequest, TestGetApplicationTypes)
+{
+ list<string> applicationTypes;
+ list<string> retApplicationTypes;
+ string type("type");
+ applicationTypes.push_back(type);
+
+ getRequest.setApplicationTypes(applicationTypes);
+ retApplicationTypes = getRequest.getApplicationTypes();
+
+ EXPECT_TRUE(applicationTypes == retApplicationTypes);
+}
+
+TEST_F(TestGetApplicationsRequest, TestGetApplicationStatus)
+{
+ list<YarnApplicationState> applicationStates;
+ list<YarnApplicationState> retApplicationStates;
+ YarnApplicationState state;
+ applicationStates.push_back(state);
+
+ getRequest.setApplicationStates(applicationStates);
+ retApplicationStates = getRequest.getApplicationStates();
+
+ EXPECT_TRUE(applicationStates == retApplicationStates);
+}
http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/383818c2/depends/libyarn/test/unit/TestProtocolRecords/TestGetApplicationsResponse.cpp
----------------------------------------------------------------------
diff --git a/depends/libyarn/test/unit/TestProtocolRecords/TestGetApplicationsResponse.cpp b/depends/libyarn/test/unit/TestProtocolRecords/TestGetApplicationsResponse.cpp
new file mode 100644
index 0000000..f910cd2
--- /dev/null
+++ b/depends/libyarn/test/unit/TestProtocolRecords/TestGetApplicationsResponse.cpp
@@ -0,0 +1,47 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+#include "gtest/gtest.h"
+#include "gmock/gmock.h"
+
+#include "protocolrecords/GetApplicationsResponse.h"
+
+using namespace libyarn;
+using namespace testing;
+
+class TestGetApplicationsResponse: public ::testing::Test {
+protected:
+ GetApplicationsResponse getResponse;
+};
+
+TEST_F(TestGetApplicationsResponse, TestGetApplicationsResponse)
+{
+ GetApplicationsResponseProto getResponseProto;
+ getResponse = GetApplicationsResponse(getResponseProto);
+
+ SUCCEED();
+}
+
+TEST_F(TestGetApplicationsResponse, TestGetProto)
+{
+ GetApplicationsResponseProto getResponseProto;
+ getResponseProto = getResponse.getProto();
+
+ SUCCEED();
+}
http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/383818c2/depends/libyarn/test/unit/TestProtocolRecords/TestGetClusterMetricsRequest.cpp
----------------------------------------------------------------------
diff --git a/depends/libyarn/test/unit/TestProtocolRecords/TestGetClusterMetricsRequest.cpp b/depends/libyarn/test/unit/TestProtocolRecords/TestGetClusterMetricsRequest.cpp
new file mode 100644
index 0000000..9641d5f
--- /dev/null
+++ b/depends/libyarn/test/unit/TestProtocolRecords/TestGetClusterMetricsRequest.cpp
@@ -0,0 +1,39 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+#include "gtest/gtest.h"
+#include "gmock/gmock.h"
+
+#include "protocolrecords/GetClusterMetricsRequest.h"
+
+using namespace libyarn;
+using namespace testing;
+
+class TestGetClusterMetricsRequest: public ::testing::Test {
+protected:
+ GetClusterMetricsRequest getRequest;
+};
+
+TEST_F(TestGetClusterMetricsRequest, TestGetClusterMetricsRequest)
+{
+ GetClusterMetricsRequestProto getRequestProto;
+ getRequest = GetClusterMetricsRequest(getRequestProto);
+
+ SUCCEED();
+}
http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/383818c2/depends/libyarn/test/unit/TestProtocolRecords/TestGetClusterMetricsResponse.cpp
----------------------------------------------------------------------
diff --git a/depends/libyarn/test/unit/TestProtocolRecords/TestGetClusterMetricsResponse.cpp b/depends/libyarn/test/unit/TestProtocolRecords/TestGetClusterMetricsResponse.cpp
new file mode 100644
index 0000000..0031447
--- /dev/null
+++ b/depends/libyarn/test/unit/TestProtocolRecords/TestGetClusterMetricsResponse.cpp
@@ -0,0 +1,39 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+#include "gtest/gtest.h"
+#include "gmock/gmock.h"
+
+#include "protocolrecords/GetClusterMetricsResponse.h"
+
+using namespace libyarn;
+using namespace testing;
+
+class TestGetClusterMetricsResponse: public ::testing::Test {
+protected:
+ GetClusterMetricsResponse getResponse;
+};
+
+TEST_F(TestGetClusterMetricsResponse, TestGetClusterMetricsResponse)
+{
+ GetClusterMetricsResponseProto getResponseProto;
+ getResponse = GetClusterMetricsResponse(getResponseProto);
+
+ SUCCEED();
+}
http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/383818c2/depends/libyarn/test/unit/TestProtocolRecords/TestGetClusterNodesRequest.cpp
----------------------------------------------------------------------
diff --git a/depends/libyarn/test/unit/TestProtocolRecords/TestGetClusterNodesRequest.cpp b/depends/libyarn/test/unit/TestProtocolRecords/TestGetClusterNodesRequest.cpp
new file mode 100644
index 0000000..8e22fd2
--- /dev/null
+++ b/depends/libyarn/test/unit/TestProtocolRecords/TestGetClusterNodesRequest.cpp
@@ -0,0 +1,55 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+#include <list>
+
+#include "gtest/gtest.h"
+#include "gmock/gmock.h"
+
+#include "protocolrecords/GetClusterNodesRequest.h"
+
+using std::list;
+using namespace libyarn;
+using namespace testing;
+
+class TestGetClusterNodesRequest: public ::testing::Test {
+protected:
+ GetClusterNodesRequest getRequest;
+};
+
+TEST_F(TestGetClusterNodesRequest, TestGetClusterMetricsRequest)
+{
+ GetClusterNodesRequestProto getRequestProto;
+ getRequest = GetClusterNodesRequest(getRequestProto);
+
+ SUCCEED();
+}
+
+TEST_F(TestGetClusterNodesRequest, TestGetNodeStates)
+{
+ list<NodeState> states;
+ list<NodeState> retStates;
+ NodeState state;
+ states.push_back(state);
+
+ getRequest.setNodeStates(states);
+ retStates = getRequest.getNodeStates();
+
+ EXPECT_TRUE(states == retStates);
+}
http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/383818c2/depends/libyarn/test/unit/TestProtocolRecords/TestGetClusterNodesResponse.cpp
----------------------------------------------------------------------
diff --git a/depends/libyarn/test/unit/TestProtocolRecords/TestGetClusterNodesResponse.cpp b/depends/libyarn/test/unit/TestProtocolRecords/TestGetClusterNodesResponse.cpp
new file mode 100644
index 0000000..b96471a
--- /dev/null
+++ b/depends/libyarn/test/unit/TestProtocolRecords/TestGetClusterNodesResponse.cpp
@@ -0,0 +1,39 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+#include "gtest/gtest.h"
+#include "gmock/gmock.h"
+
+#include "protocolrecords/GetClusterNodesResponse.h"
+
+using namespace libyarn;
+using namespace testing;
+
+class TestGetClusterNodesResponse: public ::testing::Test {
+protected:
+ GetClusterNodesResponse getResponse;
+};
+
+TEST_F(TestGetClusterNodesResponse, TestGetProto)
+{
+ GetClusterNodesResponseProto getResponseProto;
+ getResponse = getResponse.getProto();
+
+ SUCCEED();
+}
http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/383818c2/depends/libyarn/test/unit/TestProtocolRecords/TestGetContainerStatusesRequest.cpp
----------------------------------------------------------------------
diff --git a/depends/libyarn/test/unit/TestProtocolRecords/TestGetContainerStatusesRequest.cpp b/depends/libyarn/test/unit/TestProtocolRecords/TestGetContainerStatusesRequest.cpp
new file mode 100644
index 0000000..0a1fd1e
--- /dev/null
+++ b/depends/libyarn/test/unit/TestProtocolRecords/TestGetContainerStatusesRequest.cpp
@@ -0,0 +1,56 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+#include <list>
+#include "gtest/gtest.h"
+#include "gmock/gmock.h"
+
+#include "protocolrecords/GetContainerStatusesRequest.h"
+
+using std::list;
+using namespace libyarn;
+using namespace testing;
+
+class TestGetContainerStatusesRequest: public ::testing::Test {
+protected:
+ GetContainerStatusesRequest getRequest;
+};
+
+TEST_F(TestGetContainerStatusesRequest, TestGetContainerStatusesRequest)
+{
+ GetContainerStatusesRequestProto getRequestProto;
+ getRequest = GetContainerStatusesRequest(getRequestProto);
+
+ SUCCEED();
+}
+
+TEST_F(TestGetContainerStatusesRequest, TestGetContainerIds)
+{
+ list<ContainerId> idList;
+ list<ContainerId> retIdList;
+ ContainerId containerId;
+ idList.push_back(containerId);
+
+ getRequest.setContainerIds(idList);
+ retIdList = getRequest.getContainerIds();
+
+ /* The operator '==' is not defined for class ContainerId,
+ so we can't compare idList and retIdList here. */
+ SUCCEED();
+}
http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/383818c2/depends/libyarn/test/unit/TestProtocolRecords/TestGetContainerStatusesResponse.cpp
----------------------------------------------------------------------
diff --git a/depends/libyarn/test/unit/TestProtocolRecords/TestGetContainerStatusesResponse.cpp b/depends/libyarn/test/unit/TestProtocolRecords/TestGetContainerStatusesResponse.cpp
new file mode 100644
index 0000000..20f7177
--- /dev/null
+++ b/depends/libyarn/test/unit/TestProtocolRecords/TestGetContainerStatusesResponse.cpp
@@ -0,0 +1,57 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+#include <list>
+
+#include "gtest/gtest.h"
+#include "gmock/gmock.h"
+
+#include "protocolrecords/GetContainerStatusesResponse.h"
+
+using std::list;
+using namespace libyarn;
+using namespace testing;
+
+class TestGetContainerStatusesResponse: public ::testing::Test {
+protected:
+ GetContainerStatusesResponse getResponse;
+};
+
+TEST_F(TestGetContainerStatusesResponse, TestGetProto)
+{
+ GetContainerStatusesResponseProto getResponseProto;
+ getResponseProto = getResponse.getProto();
+
+ SUCCEED();
+}
+
+TEST_F(TestGetContainerStatusesResponse, TestGetContainerIds)
+{
+ list<ContainerExceptionMap> mapList;
+ list<ContainerExceptionMap> retMapList;
+ ContainerExceptionMap map;
+ mapList.push_back(map);
+
+ getResponse.setFailedRequests(mapList);
+ retMapList = getResponse.getFailedRequests();
+
+ /* The operator '==' is not defined for class ContainerExceptionMap,
+ so we can't compare mapList and retMapList here. */
+ SUCCEED();
+}
http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/383818c2/depends/libyarn/test/unit/TestProtocolRecords/TestGetContainersRequest.cpp
----------------------------------------------------------------------
diff --git a/depends/libyarn/test/unit/TestProtocolRecords/TestGetContainersRequest.cpp b/depends/libyarn/test/unit/TestProtocolRecords/TestGetContainersRequest.cpp
new file mode 100644
index 0000000..82e8345
--- /dev/null
+++ b/depends/libyarn/test/unit/TestProtocolRecords/TestGetContainersRequest.cpp
@@ -0,0 +1,52 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+#include "gtest/gtest.h"
+#include "gmock/gmock.h"
+
+#include "protocolrecords/GetContainersRequest.h"
+
+using namespace libyarn;
+using namespace testing;
+
+class TestGetContainersRequest: public ::testing::Test {
+protected:
+ GetContainersRequest getRequest;
+};
+
+TEST_F(TestGetContainersRequest, TestGetContainersRequest)
+{
+ GetContainersRequestProto getRequestProto;
+ getRequest = GetContainersRequest(getRequestProto);
+
+ SUCCEED();
+}
+
+TEST_F(TestGetContainersRequest, TestGetContainerIds)
+{
+ ApplicationAttemptId id;
+ ApplicationAttemptId retId;
+
+ getRequest.setApplicationAttemptId(id);
+ retId = getRequest.getApplicationAttemptId();
+
+ /* The operator '==' is not defined for class ApplicationAttemptId,
+ so we can't compare id and retId here. */
+ SUCCEED();
+}
http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/383818c2/depends/libyarn/test/unit/TestProtocolRecords/TestGetContainersResponse.cpp
----------------------------------------------------------------------
diff --git a/depends/libyarn/test/unit/TestProtocolRecords/TestGetContainersResponse.cpp b/depends/libyarn/test/unit/TestProtocolRecords/TestGetContainersResponse.cpp
new file mode 100644
index 0000000..bfb4e54
--- /dev/null
+++ b/depends/libyarn/test/unit/TestProtocolRecords/TestGetContainersResponse.cpp
@@ -0,0 +1,39 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+#include "gtest/gtest.h"
+#include "gmock/gmock.h"
+
+#include "protocolrecords/GetContainersResponse.h"
+
+using namespace libyarn;
+using namespace testing;
+
+class TestGetContainersResponse: public ::testing::Test {
+protected:
+ GetContainersResponse getResponse;
+};
+
+TEST_F(TestGetContainersResponse, TestGetProto)
+{
+ GetContainersResponseProto getResponseProto;
+ getResponseProto = getResponse.getProto();
+
+ SUCCEED();
+}
http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/383818c2/depends/libyarn/test/unit/TestProtocolRecords/TestGetNewApplicationRequest.cpp
----------------------------------------------------------------------
diff --git a/depends/libyarn/test/unit/TestProtocolRecords/TestGetNewApplicationRequest.cpp b/depends/libyarn/test/unit/TestProtocolRecords/TestGetNewApplicationRequest.cpp
new file mode 100644
index 0000000..b083921
--- /dev/null
+++ b/depends/libyarn/test/unit/TestProtocolRecords/TestGetNewApplicationRequest.cpp
@@ -0,0 +1,39 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+#include "gtest/gtest.h"
+#include "gmock/gmock.h"
+
+#include "protocolrecords/GetNewApplicationRequest.h"
+
+using namespace libyarn;
+using namespace testing;
+
+class TestGetNewApplicationRequest: public ::testing::Test {
+protected:
+ GetNewApplicationRequest getRequest;
+};
+
+TEST_F(TestGetNewApplicationRequest, TestGetNewApplicationRequest)
+{
+ GetNewApplicationRequestProto getRequestProto;
+ getRequest = GetNewApplicationRequest(getRequestProto);
+
+ SUCCEED();
+}
http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/383818c2/depends/libyarn/test/unit/TestProtocolRecords/TestGetNewApplicationResponse.cpp
----------------------------------------------------------------------
diff --git a/depends/libyarn/test/unit/TestProtocolRecords/TestGetNewApplicationResponse.cpp b/depends/libyarn/test/unit/TestProtocolRecords/TestGetNewApplicationResponse.cpp
new file mode 100644
index 0000000..8ed61bb
--- /dev/null
+++ b/depends/libyarn/test/unit/TestProtocolRecords/TestGetNewApplicationResponse.cpp
@@ -0,0 +1,44 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+#include "gtest/gtest.h"
+#include "gmock/gmock.h"
+
+#include "protocolrecords/GetNewApplicationResponse.h"
+
+using namespace libyarn;
+using namespace testing;
+
+class TestGetNewApplicationResponse: public ::testing::Test {
+protected:
+ GetNewApplicationResponse getResponse;
+};
+
+TEST_F(TestGetNewApplicationResponse, TestGetNewApplicationResponse)
+{
+ Resource resource;
+ Resource retResource;
+
+ getResponse.setResource(resource);
+ retResource = getResponse.getResource();
+
+ /* The operator '==' is not defined for class Resource,
+ so we can't compare resource and retResource here. */
+ SUCCEED();
+}
http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/383818c2/depends/libyarn/test/unit/TestProtocolRecords/TestGetQueueInfoRequest.cpp
----------------------------------------------------------------------
diff --git a/depends/libyarn/test/unit/TestProtocolRecords/TestGetQueueInfoRequest.cpp b/depends/libyarn/test/unit/TestProtocolRecords/TestGetQueueInfoRequest.cpp
new file mode 100644
index 0000000..f58bb4c
--- /dev/null
+++ b/depends/libyarn/test/unit/TestProtocolRecords/TestGetQueueInfoRequest.cpp
@@ -0,0 +1,85 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+#include <string>
+#include "gtest/gtest.h"
+#include "gmock/gmock.h"
+
+#include "protocolrecords/GetQueueInfoRequest.h"
+
+using std::string;
+using namespace libyarn;
+using namespace testing;
+
+class TestGetQueueInfoRequest: public ::testing::Test {
+protected:
+ GetQueueInfoRequest getRequest;
+};
+
+TEST_F(TestGetQueueInfoRequest, TestGetQueueInfoRequest)
+{
+ GetQueueInfoRequestProto getRequestProto;
+ getRequest = GetQueueInfoRequest(getRequestProto);
+
+ SUCCEED();
+}
+
+TEST_F(TestGetQueueInfoRequest, TestGetQueueName)
+{
+ string queueName("queueName");
+ string retQueueName;
+
+ getRequest.setQueueName(queueName);
+ retQueueName = getRequest.getQueueName();
+
+ EXPECT_EQ(queueName, retQueueName);
+}
+
+TEST_F(TestGetQueueInfoRequest, TestGetIncludeApplications)
+{
+ bool includeApplications = true;
+ bool retIncludeApplications;
+
+ getRequest.setIncludeApplications(includeApplications);
+ retIncludeApplications = getRequest.getIncludeApplications();
+
+ EXPECT_EQ(includeApplications, retIncludeApplications);
+}
+
+TEST_F(TestGetQueueInfoRequest, TestGetIncludeChildQueues)
+{
+ bool includeChildQueues = true;
+ bool retIncludeChildQueues;
+
+ getRequest.setIncludeChildQueues(includeChildQueues);
+ retIncludeChildQueues = getRequest.getIncludeChildQueues();
+
+ EXPECT_EQ(includeChildQueues, retIncludeChildQueues);
+}
+
+TEST_F(TestGetQueueInfoRequest, TestGetRecursive)
+{
+ bool recursive = true;
+ bool retRecursive;
+
+ getRequest.setRecursive(recursive);
+ retRecursive = getRequest.getRecursive();
+
+ EXPECT_EQ(recursive, retRecursive);
+}
http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/383818c2/depends/libyarn/test/unit/TestProtocolRecords/TestGetQueueInfoResponse.cpp
----------------------------------------------------------------------
diff --git a/depends/libyarn/test/unit/TestProtocolRecords/TestGetQueueInfoResponse.cpp b/depends/libyarn/test/unit/TestProtocolRecords/TestGetQueueInfoResponse.cpp
new file mode 100644
index 0000000..ff3a946
--- /dev/null
+++ b/depends/libyarn/test/unit/TestProtocolRecords/TestGetQueueInfoResponse.cpp
@@ -0,0 +1,39 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+#include "gtest/gtest.h"
+#include "gmock/gmock.h"
+
+#include "protocolrecords/GetQueueInfoResponse.h"
+
+using namespace libyarn;
+using namespace testing;
+
+class TestGetQueueInfoResponse: public ::testing::Test {
+protected:
+ GetQueueInfoResponse getResponse;
+};
+
+TEST_F(TestGetQueueInfoResponse, TestGetProto)
+{
+ GetQueueInfoResponseProto getResponseProto;
+ getResponseProto = getResponse.getProto();
+
+ SUCCEED();
+}
http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/383818c2/depends/libyarn/test/unit/TestProtocolRecords/TestGetQueueUserAclsInfoRequest.cpp
----------------------------------------------------------------------
diff --git a/depends/libyarn/test/unit/TestProtocolRecords/TestGetQueueUserAclsInfoRequest.cpp b/depends/libyarn/test/unit/TestProtocolRecords/TestGetQueueUserAclsInfoRequest.cpp
new file mode 100644
index 0000000..a60e937
--- /dev/null
+++ b/depends/libyarn/test/unit/TestProtocolRecords/TestGetQueueUserAclsInfoRequest.cpp
@@ -0,0 +1,39 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+#include "gtest/gtest.h"
+#include "gmock/gmock.h"
+
+#include "protocolrecords/GetQueueUserAclsInfoRequest.h"
+
+using namespace libyarn;
+using namespace testing;
+
+class TestGetQueueUserAclsInfoRequest: public ::testing::Test {
+protected:
+ GetQueueUserAclsInfoRequest getRequest;
+};
+
+TEST_F(TestGetQueueUserAclsInfoRequest, TestGetQueueUserAclsInfoRequest)
+{
+ GetQueueUserAclsInfoRequestProto getRequestProto;
+ getRequest = GetQueueUserAclsInfoRequest(getRequestProto);
+
+ SUCCEED();
+}
http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/383818c2/depends/libyarn/test/unit/TestProtocolRecords/TestGetQueueUserAclsInfoResponse.cpp
----------------------------------------------------------------------
diff --git a/depends/libyarn/test/unit/TestProtocolRecords/TestGetQueueUserAclsInfoResponse.cpp b/depends/libyarn/test/unit/TestProtocolRecords/TestGetQueueUserAclsInfoResponse.cpp
new file mode 100644
index 0000000..f0d4e4c
--- /dev/null
+++ b/depends/libyarn/test/unit/TestProtocolRecords/TestGetQueueUserAclsInfoResponse.cpp
@@ -0,0 +1,47 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+#include "gtest/gtest.h"
+#include "gmock/gmock.h"
+
+#include "protocolrecords/GetQueueUserAclsInfoResponse.h"
+
+using namespace libyarn;
+using namespace testing;
+
+class TestGetQueueUserAclsInfoResponse: public ::testing::Test {
+protected:
+ GetQueueUserAclsInfoResponse getResponse;
+};
+
+TEST_F(TestGetQueueUserAclsInfoResponse, TestGetQueueUserAclsInfoResponse)
+{
+ GetQueueUserAclsInfoResponseProto getResponseProto;
+ getResponse = GetQueueUserAclsInfoResponse(getResponseProto);
+
+ SUCCEED();
+}
+
+TEST_F(TestGetQueueUserAclsInfoResponse, TestGetProto)
+{
+ GetQueueUserAclsInfoResponseProto getResponseProto;
+ getResponseProto = getResponse.getProto();
+
+ SUCCEED();
+}
http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/383818c2/depends/libyarn/test/unit/TestProtocolRecords/TestKillApplicationRequest.cpp
----------------------------------------------------------------------
diff --git a/depends/libyarn/test/unit/TestProtocolRecords/TestKillApplicationRequest.cpp b/depends/libyarn/test/unit/TestProtocolRecords/TestKillApplicationRequest.cpp
new file mode 100644
index 0000000..c547605
--- /dev/null
+++ b/depends/libyarn/test/unit/TestProtocolRecords/TestKillApplicationRequest.cpp
@@ -0,0 +1,39 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+#include "gtest/gtest.h"
+#include "gmock/gmock.h"
+
+#include "protocolrecords/KillApplicationRequest.h"
+
+using namespace libyarn;
+using namespace testing;
+
+class TestKillApplicationRequest: public ::testing::Test {
+protected:
+ KillApplicationRequest killRequest;
+};
+
+TEST_F(TestKillApplicationRequest, TestKillApplicationRequest)
+{
+ KillApplicationRequestProto killRequestProto;
+ killRequest = KillApplicationRequest(killRequestProto);
+
+ SUCCEED();
+}
http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/383818c2/depends/libyarn/test/unit/TestProtocolRecords/TestKillApplicationResponse.cpp
----------------------------------------------------------------------
diff --git a/depends/libyarn/test/unit/TestProtocolRecords/TestKillApplicationResponse.cpp b/depends/libyarn/test/unit/TestProtocolRecords/TestKillApplicationResponse.cpp
new file mode 100644
index 0000000..3d8fd35
--- /dev/null
+++ b/depends/libyarn/test/unit/TestProtocolRecords/TestKillApplicationResponse.cpp
@@ -0,0 +1,39 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+#include "gtest/gtest.h"
+#include "gmock/gmock.h"
+
+#include "protocolrecords/KillApplicationResponse.h"
+
+using namespace libyarn;
+using namespace testing;
+
+class TestKillApplicationResponse: public ::testing::Test {
+protected:
+ KillApplicationResponse killResponse;
+};
+
+TEST_F(TestKillApplicationResponse, TestKillApplicationResponse)
+{
+ KillApplicationResponseProto killResponseProto;
+ killResponseProto = killResponse.getProto();
+
+ SUCCEED();
+}
http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/383818c2/depends/libyarn/test/unit/TestProtocolRecords/TestRegisterApplicationMasterRequest.cpp
----------------------------------------------------------------------
diff --git a/depends/libyarn/test/unit/TestProtocolRecords/TestRegisterApplicationMasterRequest.cpp b/depends/libyarn/test/unit/TestProtocolRecords/TestRegisterApplicationMasterRequest.cpp
new file mode 100644
index 0000000..361817a
--- /dev/null
+++ b/depends/libyarn/test/unit/TestProtocolRecords/TestRegisterApplicationMasterRequest.cpp
@@ -0,0 +1,75 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+#include <string>
+
+#include "gtest/gtest.h"
+#include "gmock/gmock.h"
+
+#include "protocolrecords/RegisterApplicationMasterRequest.h"
+
+using std::string;
+using namespace libyarn;
+using namespace testing;
+
+class TestRegisterApplicationMasterRequest: public ::testing::Test {
+protected:
+ RegisterApplicationMasterRequest registerRequest;
+};
+
+TEST_F(TestRegisterApplicationMasterRequest, TestRegisterApplicationMasterRequest)
+{
+ RegisterApplicationMasterRequestProto registerRequestProto;
+ registerRequest = RegisterApplicationMasterRequest(registerRequestProto);
+
+ SUCCEED();
+}
+
+TEST_F(TestRegisterApplicationMasterRequest, TestGetHost)
+{
+ string host("host");
+ string retHost;
+
+ registerRequest.setHost(host);
+ retHost = registerRequest.getHost();
+
+ EXPECT_EQ(host, retHost);
+}
+
+TEST_F(TestRegisterApplicationMasterRequest, TestGetRpcPort)
+{
+ int32_t rpcPort = -1;
+ int32_t retRpcPort;
+
+ registerRequest.setRpcPort(rpcPort);
+ retRpcPort = registerRequest.getRpcPort();
+
+ EXPECT_EQ(rpcPort, retRpcPort);
+}
+
+TEST_F(TestRegisterApplicationMasterRequest, TestGetTrackingUrl)
+{
+ string trackingUrl("trackingUrl");
+ string retTrackingUrl;
+
+ registerRequest.setTrackingUrl(trackingUrl);
+ retTrackingUrl = registerRequest.getTrackingUrl();
+
+ EXPECT_EQ(trackingUrl, retTrackingUrl);
+}
http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/383818c2/depends/libyarn/test/unit/TestProtocolRecords/TestRegisterApplicationMasterResponse.cpp
----------------------------------------------------------------------
diff --git a/depends/libyarn/test/unit/TestProtocolRecords/TestRegisterApplicationMasterResponse.cpp b/depends/libyarn/test/unit/TestProtocolRecords/TestRegisterApplicationMasterResponse.cpp
new file mode 100644
index 0000000..251e492
--- /dev/null
+++ b/depends/libyarn/test/unit/TestProtocolRecords/TestRegisterApplicationMasterResponse.cpp
@@ -0,0 +1,39 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+#include "gtest/gtest.h"
+#include "gmock/gmock.h"
+
+#include "protocolrecords/RegisterApplicationMasterResponse.h"
+
+using namespace libyarn;
+using namespace testing;
+
+class TestRegisterApplicationMasterResponse: public ::testing::Test {
+protected:
+ RegisterApplicationMasterResponse registerResponse;
+};
+
+TEST_F(TestRegisterApplicationMasterResponse, TestGetProto)
+{
+ RegisterApplicationMasterResponseProto registerResponseProto;
+ registerResponseProto = registerResponse.getProto();
+
+ SUCCEED();
+}
http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/383818c2/depends/libyarn/test/unit/TestProtocolRecords/TestStartContainerRequest.cpp
----------------------------------------------------------------------
diff --git a/depends/libyarn/test/unit/TestProtocolRecords/TestStartContainerRequest.cpp b/depends/libyarn/test/unit/TestProtocolRecords/TestStartContainerRequest.cpp
new file mode 100644
index 0000000..af4ddb3
--- /dev/null
+++ b/depends/libyarn/test/unit/TestProtocolRecords/TestStartContainerRequest.cpp
@@ -0,0 +1,65 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+#include "gtest/gtest.h"
+#include "gmock/gmock.h"
+
+#include "protocolrecords/StartContainerRequest.h"
+
+using namespace libyarn;
+using namespace testing;
+
+class TestStartContainerRequest: public ::testing::Test {
+protected:
+ StartContainerRequest startRequest;
+};
+
+TEST_F(TestStartContainerRequest, TestStartContainerRequest)
+{
+ StartContainerRequestProto startRequestProto;
+ startRequest = StartContainerRequest(startRequestProto);
+
+ SUCCEED();
+}
+
+TEST_F(TestStartContainerRequest, TestGetContainerLaunchCtx)
+{
+ ContainerLaunchContext ctx;
+ ContainerLaunchContext retCtx;
+
+ startRequest.setContainerLaunchCtx(ctx);
+ retCtx = startRequest.getContainerLaunchCtx();
+
+ /* The operator '==' is not defined for class ContainerLaunchContext,
+ so we can't compare ctx and retCtx here. */
+ SUCCEED();
+}
+
+TEST_F(TestStartContainerRequest, TestGetContainerToken)
+{
+ Token token;
+ Token retToken;
+
+ startRequest.setContainerToken(token);
+ retToken = startRequest.getContainerToken();
+
+ /* The operator '==' is not defined for class Token,
+ so we can't compare token and retToken here. */
+ SUCCEED();
+}
http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/383818c2/depends/libyarn/test/unit/TestProtocolRecords/TestStartContainerResponse.cpp
----------------------------------------------------------------------
diff --git a/depends/libyarn/test/unit/TestProtocolRecords/TestStartContainerResponse.cpp b/depends/libyarn/test/unit/TestProtocolRecords/TestStartContainerResponse.cpp
new file mode 100644
index 0000000..d133c20
--- /dev/null
+++ b/depends/libyarn/test/unit/TestProtocolRecords/TestStartContainerResponse.cpp
@@ -0,0 +1,39 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+#include "gtest/gtest.h"
+#include "gmock/gmock.h"
+
+#include "protocolrecords/StartContainerResponse.h"
+
+using namespace libyarn;
+using namespace testing;
+
+class TestStartContainerResponse: public ::testing::Test {
+protected:
+ StartContainerResponse startResponse;
+};
+
+TEST_F(TestStartContainerResponse, TestGetProto)
+{
+ StartContainerResponseProto startResponseProto;
+ startResponseProto = startResponse.getProto();
+
+ SUCCEED();
+}
http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/383818c2/depends/libyarn/test/unit/TestProtocolRecords/TestStartContainersRequest.cpp
----------------------------------------------------------------------
diff --git a/depends/libyarn/test/unit/TestProtocolRecords/TestStartContainersRequest.cpp b/depends/libyarn/test/unit/TestProtocolRecords/TestStartContainersRequest.cpp
new file mode 100644
index 0000000..dddb449
--- /dev/null
+++ b/depends/libyarn/test/unit/TestProtocolRecords/TestStartContainersRequest.cpp
@@ -0,0 +1,57 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+#include <list>
+
+#include "gtest/gtest.h"
+#include "gmock/gmock.h"
+
+#include "protocolrecords/StartContainersRequest.h"
+
+using std::list;
+using namespace libyarn;
+using namespace testing;
+
+class TestStartContainersRequest: public ::testing::Test {
+protected:
+ StartContainersRequest startRequest;
+};
+
+TEST_F(TestStartContainersRequest, TestStartContainersRequest)
+{
+ StartContainersRequestProto startRequestProto;
+ startRequest = StartContainersRequest(startRequestProto);
+
+ SUCCEED();
+}
+
+TEST_F(TestStartContainersRequest, TestGetStartContainerRequests)
+{
+ list<StartContainerRequest> requests;
+ list<StartContainerRequest> retRequests;
+ StartContainerRequest request;
+ requests.push_back(request);
+
+ startRequest.setStartContainerRequests(requests);
+ retRequests = startRequest.getStartContainerRequests();
+
+ /* The operator '==' is not defined for class StartContainerRequest,
+ so we can't compare requests and retRequests here. */
+ SUCCEED();
+}
http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/383818c2/depends/libyarn/test/unit/TestProtocolRecords/TestStartContainersResponse.cpp
----------------------------------------------------------------------
diff --git a/depends/libyarn/test/unit/TestProtocolRecords/TestStartContainersResponse.cpp b/depends/libyarn/test/unit/TestProtocolRecords/TestStartContainersResponse.cpp
new file mode 100644
index 0000000..a5a2178
--- /dev/null
+++ b/depends/libyarn/test/unit/TestProtocolRecords/TestStartContainersResponse.cpp
@@ -0,0 +1,74 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+#include <list>
+
+#include "gtest/gtest.h"
+#include "gmock/gmock.h"
+
+#include "protocolrecords/StartContainersResponse.h"
+
+using std::list;
+using namespace libyarn;
+using namespace testing;
+
+class TestStartContainersResponse: public ::testing::Test {
+protected:
+ StartContainersResponse startResponse;
+};
+
+TEST_F(TestStartContainersResponse, TestStartContainersGetProto)
+{
+ StartContainersResponseProto startResponseProto;
+ startResponseProto = startResponse.getProto();
+
+ SUCCEED();
+}
+
+TEST_F(TestStartContainersResponse, TestGetSucceededRequests)
+{
+ list<ContainerId> requests;
+ list<ContainerId> retRequests;
+ ContainerId containerId;
+ requests.push_back(containerId);
+
+ startResponse.setSucceededRequests(requests);
+ retRequests = startResponse.getSucceededRequests();
+
+ /* The operator '==' is not defined for class ContainerId,
+ so we can't compare requests and retRequests here. */
+
+ SUCCEED();
+}
+
+TEST_F(TestStartContainersResponse, TestGetFailedRequests)
+{
+ list<ContainerExceptionMap> requests;
+ list<ContainerExceptionMap> retRequests;
+ ContainerExceptionMap map;
+ requests.push_back(map);
+
+ startResponse.setFailedRequests(requests);
+ retRequests = startResponse.getFailedRequests();
+
+ /* The operator '==' is not defined for class ContainerExceptionMap,
+ so we can't compare requests and retRequests here. */
+
+ SUCCEED();
+}
http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/383818c2/depends/libyarn/test/unit/TestProtocolRecords/TestStopContainersRequest.cpp
----------------------------------------------------------------------
diff --git a/depends/libyarn/test/unit/TestProtocolRecords/TestStopContainersRequest.cpp b/depends/libyarn/test/unit/TestProtocolRecords/TestStopContainersRequest.cpp
new file mode 100644
index 0000000..f30bd2a
--- /dev/null
+++ b/depends/libyarn/test/unit/TestProtocolRecords/TestStopContainersRequest.cpp
@@ -0,0 +1,57 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+#include <list>
+
+#include "gtest/gtest.h"
+#include "gmock/gmock.h"
+
+#include "protocolrecords/StopContainersRequest.h"
+
+using std::list;
+using namespace libyarn;
+using namespace testing;
+
+class TestStopContainersRequest: public ::testing::Test {
+protected:
+ StopContainersRequest stopRequest;
+};
+
+TEST_F(TestStopContainersRequest, TestStopContainersRequest)
+{
+ StopContainersRequestProto stopRequestProto;
+ stopRequest = StopContainersRequest(stopRequestProto);
+
+ SUCCEED();
+}
+
+TEST_F(TestStopContainersRequest, TestGetContainerIds)
+{
+ list<ContainerId> cids;
+ list<ContainerId> retCids;
+ ContainerId cid;
+ cids.push_back(cid);
+
+ stopRequest.setContainerIds(cids);
+ retCids = stopRequest.getContainerIds();
+
+ /* The operator '==' is not defined for class ContainerId,
+ so we can't compare cids and retCids here. */
+ SUCCEED();
+}
http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/383818c2/depends/libyarn/test/unit/TestProtocolRecords/TestStopContainersResponse.cpp
----------------------------------------------------------------------
diff --git a/depends/libyarn/test/unit/TestProtocolRecords/TestStopContainersResponse.cpp b/depends/libyarn/test/unit/TestProtocolRecords/TestStopContainersResponse.cpp
new file mode 100644
index 0000000..4e6f1ff
--- /dev/null
+++ b/depends/libyarn/test/unit/TestProtocolRecords/TestStopContainersResponse.cpp
@@ -0,0 +1,74 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+#include <list>
+
+#include "gtest/gtest.h"
+#include "gmock/gmock.h"
+
+#include "protocolrecords/StopContainersResponse.h"
+
+using std::list;
+using namespace libyarn;
+using namespace testing;
+
+class TestStopContainersResponse: public ::testing::Test {
+protected:
+ StopContainersResponse stopResponse;
+};
+
+TEST_F(TestStopContainersResponse, TestStopContainersGetProto)
+{
+ StopContainersResponseProto stopResponseProto;
+ stopResponseProto = stopResponse.getProto();
+
+ SUCCEED();
+}
+
+TEST_F(TestStopContainersResponse, TestGetSucceededRequests)
+{
+ list<ContainerId> requests;
+ list<ContainerId> retRequests;
+ ContainerId containerId;
+ requests.push_back(containerId);
+
+ stopResponse.setSucceededRequests(requests);
+ retRequests = stopResponse.getSucceededRequests();
+
+ /* The operator '==' is not defined for class ContainerId,
+ so we can't compare requests and retRequests here. */
+
+ SUCCEED();
+}
+
+TEST_F(TestStopContainersResponse, TestGetFailedRequests)
+{
+ list<ContainerExceptionMap> requests;
+ list<ContainerExceptionMap> retRequests;
+ ContainerExceptionMap map;
+ requests.push_back(map);
+
+ stopResponse.setFailedRequests(requests);
+ retRequests = stopResponse.getFailedRequests();
+
+ /* The operator '==' is not defined for class ContainerExceptionMap,
+ so we can't compare requests and retRequests here. */
+
+ SUCCEED();
+}
http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/383818c2/depends/libyarn/test/unit/TestProtocolRecords/TestSubmitApplicationRequest.cpp
----------------------------------------------------------------------
diff --git a/depends/libyarn/test/unit/TestProtocolRecords/TestSubmitApplicationRequest.cpp b/depends/libyarn/test/unit/TestProtocolRecords/TestSubmitApplicationRequest.cpp
new file mode 100644
index 0000000..b039d4f
--- /dev/null
+++ b/depends/libyarn/test/unit/TestProtocolRecords/TestSubmitApplicationRequest.cpp
@@ -0,0 +1,52 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+#include "gtest/gtest.h"
+#include "gmock/gmock.h"
+
+#include "protocolrecords/SubmitApplicationRequest.h"
+
+using namespace libyarn;
+using namespace testing;
+
+class TestSubmitApplicationRequest: public ::testing::Test {
+protected:
+ SubmitApplicationRequest submitRequest;
+};
+
+TEST_F(TestSubmitApplicationRequest, TestSubmitApplicationRequest)
+{
+ SubmitApplicationRequestProto submitRequestProto;
+ submitRequest = SubmitApplicationRequest(submitRequestProto);
+
+ SUCCEED();
+}
+
+TEST_F(TestSubmitApplicationRequest, TestGetContainerIds)
+{
+ ApplicationSubmissionContext appCtx;
+ ApplicationSubmissionContext retAppCtx;
+
+ submitRequest.setApplicationSubmissionContext(appCtx);
+ retAppCtx = submitRequest.getApplicationSubmissionContext();
+
+ /* The operator '==' is not defined for class ApplicationSubmissionContext,
+ so we can't compare appCtx and retAppCtx here. */
+ SUCCEED();
+}
http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/383818c2/depends/libyarn/test/unit/TestProtocolRecords/TestSubmitApplicationResponse.cpp
----------------------------------------------------------------------
diff --git a/depends/libyarn/test/unit/TestProtocolRecords/TestSubmitApplicationResponse.cpp b/depends/libyarn/test/unit/TestProtocolRecords/TestSubmitApplicationResponse.cpp
new file mode 100644
index 0000000..b7a20cb
--- /dev/null
+++ b/depends/libyarn/test/unit/TestProtocolRecords/TestSubmitApplicationResponse.cpp
@@ -0,0 +1,48 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+#include "gtest/gtest.h"
+#include "gmock/gmock.h"
+
+#include "protocolrecords/SubmitApplicationResponse.h"
+
+using namespace libyarn;
+using namespace testing;
+
+class TestSubmitApplicationResponse: public ::testing::Test {
+protected:
+ SubmitApplicationResponse submitResponse;
+};
+
+TEST_F(TestSubmitApplicationResponse, TestSubmitApplicationResponse)
+{
+ SubmitApplicationResponseProto submitResponseProto;
+ submitResponse = SubmitApplicationResponse();
+ submitResponse = SubmitApplicationResponse(submitResponseProto);
+
+ SUCCEED();
+}
+
+TEST_F(TestSubmitApplicationResponse, TestGetProto)
+{
+ SubmitApplicationResponseProto submitResponseProto;
+ submitResponseProto = submitResponse.getProto();
+
+ SUCCEED();
+}
http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/383818c2/depends/libyarn/test/unit/TestRecords/TestApplicationAttemptId.cpp
----------------------------------------------------------------------
diff --git a/depends/libyarn/test/unit/TestRecords/TestApplicationAttemptId.cpp b/depends/libyarn/test/unit/TestRecords/TestApplicationAttemptId.cpp
new file mode 100644
index 0000000..67f809a
--- /dev/null
+++ b/depends/libyarn/test/unit/TestRecords/TestApplicationAttemptId.cpp
@@ -0,0 +1,56 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+#include "gtest/gtest.h"
+#include "gmock/gmock.h"
+
+#include "records/ApplicationAttemptId.h"
+
+using namespace libyarn;
+using namespace testing;
+
+class TestApplicationAttemptId: public ::testing::Test {
+protected:
+ ApplicationAttemptId applicationId;
+};
+
+TEST_F(TestApplicationAttemptId, TestGetApplicationId)
+{
+ ApplicationId id;
+ ApplicationId retId;
+
+ applicationId.setApplicationId(id);
+ retId = applicationId.getApplicationId();
+
+ /* The operator '==' is not defined for class ApplicationId,
+ so we can't compare id and retId here. */
+
+ SUCCEED();
+}
+
+TEST_F(TestApplicationAttemptId, TestGetAttemptId)
+{
+ int32_t id = -1;
+ int32_t retId;
+
+ applicationId.setAttemptId(id);
+ retId = applicationId.getAttemptId();
+
+ EXPECT_EQ(id, retId);
+}
http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/383818c2/depends/libyarn/test/unit/TestRecords/TestApplicationReport.cpp
----------------------------------------------------------------------
diff --git a/depends/libyarn/test/unit/TestRecords/TestApplicationReport.cpp b/depends/libyarn/test/unit/TestRecords/TestApplicationReport.cpp
new file mode 100644
index 0000000..75d1c61
--- /dev/null
+++ b/depends/libyarn/test/unit/TestRecords/TestApplicationReport.cpp
@@ -0,0 +1,152 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+#include <string>
+
+#include "gtest/gtest.h"
+#include "gmock/gmock.h"
+
+#include "records/ApplicationReport.h"
+
+using std::string;
+using namespace libyarn;
+using namespace testing;
+
+class TestApplicationReport: public ::testing::Test {
+protected:
+ ApplicationReport applicationReport;
+};
+
+TEST_F(TestApplicationReport, TestGetClientToAMToken)
+{
+ Token token;
+ Token retToken;
+
+ applicationReport.setClientToAMToken(token);
+ retToken = applicationReport.getClientToAMToken();
+
+ /* The operator '==' is not defined for class Token,
+ so we can't compare token and retToken here. */
+
+ SUCCEED();
+}
+
+TEST_F(TestApplicationReport, TestGetTrackingUrl)
+{
+ string url("url");
+ string retUrl;
+
+ applicationReport.setTrackingUrl(url);
+ retUrl = applicationReport.getTrackingUrl();
+
+ EXPECT_EQ(url, retUrl);
+}
+
+TEST_F(TestApplicationReport, TestGetDiagnostics)
+{
+ string diagnostics("diagnostics");
+ string retDiagnostics;
+
+ applicationReport.setDiagnostics(diagnostics);
+ retDiagnostics = applicationReport.getDiagnostics();
+
+ EXPECT_EQ(diagnostics, retDiagnostics);
+}
+
+TEST_F(TestApplicationReport, TestGetStartTime)
+{
+ int64_t time = -1;
+ int64_t retTime;
+
+ applicationReport.setStartTime(time);
+ retTime = applicationReport.getStartTime();
+
+ EXPECT_EQ(time, retTime);
+}
+
+TEST_F(TestApplicationReport, TestGetFinishTime)
+{
+ int64_t time = -1;
+ int64_t retTime;
+
+ applicationReport.setFinishTime(time);
+ retTime = applicationReport.getFinishTime();
+
+ EXPECT_EQ(time, retTime);
+}
+
+TEST_F(TestApplicationReport, TestGetFinalApplicationStatus)
+{
+ FinalApplicationStatus status = FinalApplicationStatus::APP_SUCCEEDED;
+ FinalApplicationStatus retStatus;
+
+ applicationReport.setFinalApplicationStatus(status);
+ retStatus = applicationReport.getFinalApplicationStatus();
+
+ EXPECT_EQ(status, retStatus);
+}
+
+TEST_F(TestApplicationReport, TestGetApplicationResourceUsage)
+{
+ ApplicationResourceUsageReport usage;
+ ApplicationResourceUsageReport retUsage;
+
+ applicationReport.setAppResourceUsage(usage);
+ retUsage = applicationReport.getAppResourceUsage();
+
+ /* The operator '==' is not defined for class ApplicationResourceUsageReport,
+ so we can't compare usage and retUsage here. */
+
+ SUCCEED();
+}
+
+TEST_F(TestApplicationReport, TestGetOriginalTrackingUrl)
+{
+ string url("url");
+ string retUrl;
+
+ applicationReport.setOriginalTrackingUrl(url);
+ retUrl = applicationReport.getOriginalTrackingUrl();
+
+ EXPECT_EQ(url, retUrl);
+}
+
+TEST_F(TestApplicationReport, TestGetCurrentAppAttemptId)
+{
+ ApplicationAttemptId id;
+ ApplicationAttemptId retId;
+
+ applicationReport.setCurrentAppAttemptId(id);
+ retId = applicationReport.getCurrentAppAttemptId();
+
+ /* The operator '==' is not defined for class ApplicationAttemptId,
+ so we can't compare id and retId here. */
+
+ SUCCEED();
+}
+
+TEST_F(TestApplicationReport, TestGetApplicationType)
+{
+ string type("type");
+ string retType;
+
+ applicationReport.setApplicationType(type);
+ retType = applicationReport.getApplicationType();
+
+ EXPECT_EQ(type, retType);
+}
http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/383818c2/depends/libyarn/test/unit/TestRecords/TestApplicationResourceUsageReport.cpp
----------------------------------------------------------------------
diff --git a/depends/libyarn/test/unit/TestRecords/TestApplicationResourceUsageReport.cpp b/depends/libyarn/test/unit/TestRecords/TestApplicationResourceUsageReport.cpp
new file mode 100644
index 0000000..f172dec
--- /dev/null
+++ b/depends/libyarn/test/unit/TestRecords/TestApplicationResourceUsageReport.cpp
@@ -0,0 +1,98 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+#include "gtest/gtest.h"
+#include "gmock/gmock.h"
+
+#include "records/ApplicationResourceUsageReport.h"
+
+using namespace libyarn;
+using namespace testing;
+
+class TestApplicationResourceUsageReport: public ::testing::Test {
+protected:
+ ApplicationResourceUsageReport applicationReport;
+};
+
+TEST_F(TestApplicationResourceUsageReport, TestGetNumUsedContainers)
+{
+ int32_t num = -1;
+ int32_t retNum;
+
+ applicationReport.setNumUsedContainers(num);
+ retNum = applicationReport.getNumUsedContainers();
+
+ EXPECT_EQ(num, retNum);
+}
+
+TEST_F(TestApplicationResourceUsageReport, TestGetNumReservedContainers)
+{
+ int32_t num = -1;
+ int32_t retNum;
+
+ applicationReport.setNumReservedContainers(num);
+ retNum = applicationReport.getNumReservedContainers();
+
+ EXPECT_EQ(num, retNum);
+}
+
+TEST_F(TestApplicationResourceUsageReport, TestGetUsedResources)
+{
+ Resource resource;
+ Resource retResource;
+
+ applicationReport.setUsedResources(resource);
+ retResource = applicationReport.getUsedResources();
+
+
+ /* The operator '==' is not defined for class Resource,
+ so we can't compare resource and retResource here. */
+
+ SUCCEED();
+}
+
+TEST_F(TestApplicationResourceUsageReport, TestGetReservedResources)
+{
+ Resource resource;
+ Resource retResource;
+
+ applicationReport.setReservedResources(resource);
+ retResource = applicationReport.getReservedResources();
+
+
+ /* The operator '==' is not defined for class Resource,
+ so we can't compare resource and retResource here. */
+
+ SUCCEED();
+}
+
+TEST_F(TestApplicationResourceUsageReport, TestGetNeededResources)
+{
+ Resource resource;
+ Resource retResource;
+
+ applicationReport.setNeededResources(resource);
+ retResource = applicationReport.getNeededResources();
+
+
+ /* The operator '==' is not defined for class Resource,
+ so we can't compare resource and retResource here. */
+
+ SUCCEED();
+}
[5/5] incubator-hawq git commit: HAWQ-891. Refine libyarn codes
Posted by wl...@apache.org.
HAWQ-891. Refine libyarn codes
Project: http://git-wip-us.apache.org/repos/asf/incubator-hawq/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-hawq/commit/383818c2
Tree: http://git-wip-us.apache.org/repos/asf/incubator-hawq/tree/383818c2
Diff: http://git-wip-us.apache.org/repos/asf/incubator-hawq/diff/383818c2
Branch: refs/heads/master
Commit: 383818c280f3b4787c726920105585c09bd7630f
Parents: 8b79e10
Author: Wen Lin <wl...@pivotal.io>
Authored: Wed Jul 6 09:33:56 2016 +0800
Committer: Wen Lin <wl...@pivotal.io>
Committed: Wed Jul 6 09:33:56 2016 +0800
----------------------------------------------------------------------
depends/libyarn/mock/MockApplicationClient.h | 7 +-
.../MockApplicationClientProtocolInternal.h | 51 +
.../MockApplicationMasterProtocolInternal.h | 51 +
.../MockContainerManagementProtocolInternal.h | 52 +
depends/libyarn/src/CMakeLists.txt | 2 +-
depends/libyarn/src/common/Exception.cpp | 26 -
depends/libyarn/src/common/Exception.h | 159 ---
.../src/libyarnclient/ApplicationClient.cpp | 6 +-
.../src/libyarnclient/ApplicationClient.h | 10 +-
.../libyarn/src/libyarnclient/LibYarnClient.cpp | 12 +-
.../libyarn/src/libyarnclient/LibYarnClient.h | 6 +-
.../src/libyarnclient/LibYarnClientC.cpp | 4 +-
.../libyarnserver/ApplicationClientProtocol.h | 2 +-
.../libyarnserver/ApplicationMasterProtocol.h | 2 +-
.../libyarnserver/ContainerManagementProtocol.h | 2 +-
.../GetApplicationReportRequest.cpp | 6 +-
.../GetApplicationReportRequest.h | 6 +-
.../GetApplicationReportResponse.cpp | 2 +-
.../GetApplicationReportResponse.h | 2 +-
.../GetNewApplicationResponse.cpp | 6 +-
.../protocolrecords/GetNewApplicationResponse.h | 6 +-
.../protocolrecords/KillApplicationRequest.cpp | 2 +-
.../protocolrecords/KillApplicationRequest.h | 4 +-
.../src/records/ApplicationAttemptId.cpp | 6 +-
.../libyarn/src/records/ApplicationAttemptId.h | 6 +-
depends/libyarn/src/records/ApplicationID.cpp | 20 +-
depends/libyarn/src/records/ApplicationID.h | 56 -
depends/libyarn/src/records/ApplicationId.h | 56 +
.../libyarn/src/records/ApplicationReport.cpp | 8 +-
depends/libyarn/src/records/ApplicationReport.h | 8 +-
.../records/ApplicationSubmissionContext.cpp | 6 +-
.../src/records/ApplicationSubmissionContext.h | 6 +-
depends/libyarn/src/records/ContainerId.cpp | 6 +-
depends/libyarn/src/records/ContainerId.h | 6 +-
depends/libyarn/src/records/ContainerReport.cpp | 2 +-
depends/libyarn/src/records/ContainerReport.h | 2 +-
depends/libyarn/src/records/ContainerStatus.cpp | 2 +-
depends/libyarn/src/records/ContainerStatus.h | 2 +-
.../libyarn/test/function/TestLibYarnClient.cpp | 2 +
.../test/function/TestLibYarnClientC.cpp | 139 +++
.../TestMockApplicationClientProtocol.cpp | 2 +
.../TestMockApplicationMasterProtocol.cpp | 2 +
.../libyarn/test/unit/TestApplicationClient.cpp | 264 -----
.../libyarn/test/unit/TestApplicationMaster.cpp | 193 ----
.../test/unit/TestContainerManagement.cpp | 146 ---
depends/libyarn/test/unit/TestLibYarnClient.cpp | 651 -----------
.../TestLibYarnClient/TestApplicationClient.cpp | 277 +++++
.../TestLibYarnClient/TestApplicationMaster.cpp | 196 ++++
.../TestContainerManagement.cpp | 158 +++
.../TestLibYarnClient/TestLibYarnClient.cpp | 1085 ++++++++++++++++++
.../TestLibYarnClient/TestLibYarnClientC.cpp | 278 +++++
.../libyarn/test/unit/TestLibYarnClientC.cpp | 276 -----
.../TestApplicationClientProtocol.cpp | 213 ++++
.../TestApplicationMasterProtocol.cpp | 96 ++
.../TestContainerManagementProtocol.cpp | 101 ++
.../TestProtocolRecords/TestAllocateRequest.cpp | 104 ++
.../TestAllocateResponse.cpp | 67 ++
.../TestFinishApplicationMasterRequest.cpp | 70 ++
.../TestFinishApplicationMasterResponse.cpp | 39 +
.../TestGetApplicationReportRequest.cpp | 47 +
.../TestGetApplicationReportResponse.cpp | 39 +
.../TestGetApplicationsRequest.cpp | 70 ++
.../TestGetApplicationsResponse.cpp | 47 +
.../TestGetClusterMetricsRequest.cpp | 39 +
.../TestGetClusterMetricsResponse.cpp | 39 +
.../TestGetClusterNodesRequest.cpp | 55 +
.../TestGetClusterNodesResponse.cpp | 39 +
.../TestGetContainerStatusesRequest.cpp | 56 +
.../TestGetContainerStatusesResponse.cpp | 57 +
.../TestGetContainersRequest.cpp | 52 +
.../TestGetContainersResponse.cpp | 39 +
.../TestGetNewApplicationRequest.cpp | 39 +
.../TestGetNewApplicationResponse.cpp | 44 +
.../TestGetQueueInfoRequest.cpp | 85 ++
.../TestGetQueueInfoResponse.cpp | 39 +
.../TestGetQueueUserAclsInfoRequest.cpp | 39 +
.../TestGetQueueUserAclsInfoResponse.cpp | 47 +
.../TestKillApplicationRequest.cpp | 39 +
.../TestKillApplicationResponse.cpp | 39 +
.../TestRegisterApplicationMasterRequest.cpp | 75 ++
.../TestRegisterApplicationMasterResponse.cpp | 39 +
.../TestStartContainerRequest.cpp | 65 ++
.../TestStartContainerResponse.cpp | 39 +
.../TestStartContainersRequest.cpp | 57 +
.../TestStartContainersResponse.cpp | 74 ++
.../TestStopContainersRequest.cpp | 57 +
.../TestStopContainersResponse.cpp | 74 ++
.../TestSubmitApplicationRequest.cpp | 52 +
.../TestSubmitApplicationResponse.cpp | 48 +
.../TestRecords/TestApplicationAttemptId.cpp | 56 +
.../unit/TestRecords/TestApplicationReport.cpp | 152 +++
.../TestApplicationResourceUsageReport.cpp | 98 ++
.../TestApplicationSubmisionContext.cpp | 156 +++
.../TestRecords/TestContainerExceptionMap.cpp | 59 +
.../test/unit/TestRecords/TestContainerId.cpp | 59 +
.../TestRecords/TestContainerLaunchContext.cpp | 124 ++
.../unit/TestRecords/TestContainerReport.cpp | 114 ++
.../test/unit/TestRecords/TestLocalResource.cpp | 119 ++
.../test/unit/TestRecords/TestNodeReport.cpp | 81 ++
.../TestRecords/TestPreemptionContainer.cpp | 82 ++
.../unit/TestRecords/TestPreemptionContract.cpp | 84 ++
.../unit/TestRecords/TestPreemptionMessage.cpp | 75 ++
.../TestPreemptionResourceRequest.cpp | 45 +
.../TestResourceBlacklistRequest.cpp | 88 ++
.../TestRecords/TestSerializedException.cpp | 81 ++
.../TestStrictPreemptionContract.cpp | 50 +
.../unit/TestRecords/TestStringBytesMap.cpp | 56 +
.../TestRecords/TestStringLocalResourceMap.cpp | 59 +
.../unit/TestRecords/TestStringStringMap.cpp | 56 +
.../libyarn/test/unit/TestRecords/TestURL.cpp | 89 ++
110 files changed, 6436 insertions(+), 1854 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/383818c2/depends/libyarn/mock/MockApplicationClient.h
----------------------------------------------------------------------
diff --git a/depends/libyarn/mock/MockApplicationClient.h b/depends/libyarn/mock/MockApplicationClient.h
index 0c59a85..d5ba972 100644
--- a/depends/libyarn/mock/MockApplicationClient.h
+++ b/depends/libyarn/mock/MockApplicationClient.h
@@ -40,16 +40,17 @@ public:
}
~MockApplicationClient(){
}
- MOCK_METHOD0(getNewApplication, ApplicationID ());
+ MOCK_METHOD0(getNewApplication, ApplicationId ());
MOCK_METHOD1(submitApplication, void (ApplicationSubmissionContext &appContext));
- MOCK_METHOD1(getApplicationReport, ApplicationReport (ApplicationID &appId));
+ MOCK_METHOD1(getApplicationReport, ApplicationReport (ApplicationId &appId));
MOCK_METHOD1(getContainers, list<ContainerReport> (ApplicationAttemptId &appAttempId));
MOCK_METHOD1(getClusterNodes, list<NodeReport> (list<NodeState> &state));
MOCK_METHOD4(getQueueInfo, QueueInfo (string &queue, bool includeApps,bool includeChildQueues, bool recursive));
- MOCK_METHOD1(forceKillApplication, void (ApplicationID &appId));
+ MOCK_METHOD1(forceKillApplication, void (ApplicationId &appId));
MOCK_METHOD0(getClusterMetrics, YarnClusterMetrics ());
MOCK_METHOD2(getApplications, list<ApplicationReport> (list<string> &applicationTypes,list<YarnApplicationState> &applicationStates));
MOCK_METHOD0(getQueueAclsInfo, list<QueueUserACLInfo> ());
+ MOCK_METHOD0(getMethod, const AuthMethod ());
};
}
http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/383818c2/depends/libyarn/mock/MockApplicationClientProtocolInternal.h
----------------------------------------------------------------------
diff --git a/depends/libyarn/mock/MockApplicationClientProtocolInternal.h b/depends/libyarn/mock/MockApplicationClientProtocolInternal.h
new file mode 100644
index 0000000..4d84e1d
--- /dev/null
+++ b/depends/libyarn/mock/MockApplicationClientProtocolInternal.h
@@ -0,0 +1,51 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+/*
+ * MockApplicationClientProtocolInternal.h
+ *
+ * Created on: April 27, 2016
+ * Author: Yangcheng Luo
+ */
+
+#ifndef MOCKAPPLICATIONCLIENTPROTOCOLINTERNAL_H_
+#define MOCKAPPLICATIONCLIENTPROTOCOLINTERNAL_H_
+#include <string>
+
+#include "gmock/gmock.h"
+#include "libyarnserver/ApplicationClientProtocol.h"
+
+using namespace libyarn;
+using std::string;
+
+namespace Mock{
+class MockApplicationClientProtocolInternal : public ApplicationClientProtocol {
+public:
+ MockApplicationClientProtocolInternal(const string & user, const string & nmHost, const string & nmPort,
+ const string & tokenService, const SessionConfig & c):
+ ApplicationClientProtocol(user, nmHost, nmPort, tokenService, c){
+ }
+ ~MockApplicationClientProtocolInternal(){
+ }
+
+ MOCK_METHOD1(invoke, void(const RpcCall & call));
+
+};
+}
+#endif /* MOCKAPPLICATIONCLIENTPROTOCOLINTERNAL_H_ */
http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/383818c2/depends/libyarn/mock/MockApplicationMasterProtocolInternal.h
----------------------------------------------------------------------
diff --git a/depends/libyarn/mock/MockApplicationMasterProtocolInternal.h b/depends/libyarn/mock/MockApplicationMasterProtocolInternal.h
new file mode 100644
index 0000000..5fcaee3
--- /dev/null
+++ b/depends/libyarn/mock/MockApplicationMasterProtocolInternal.h
@@ -0,0 +1,51 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+/*
+ * MockApplicationMasterProtocolInternal.h
+ *
+ * Created on: May 4, 2016
+ * Author: Yangcheng Luo
+ */
+
+#ifndef MOCKAPPLICATIONMASTERPROTOCOLINTERNAL_H_
+#define MOCKAPPLICATIONMASTERPROTOCOLINTERNAL_H_
+#include <string>
+
+#include "gmock/gmock.h"
+#include "libyarnserver/ApplicationMasterProtocol.h"
+
+using namespace libyarn;
+using std::string;
+
+namespace Mock{
+class MockApplicationMasterProtocolInternal : public ApplicationMasterProtocol {
+public:
+ MockApplicationMasterProtocolInternal(const string & schedHost, const string & schedPort,
+ const string & tokenService, const SessionConfig & c, const RpcAuth & a):
+ ApplicationMasterProtocol(schedHost, schedPort, tokenService, c, a){
+ }
+ ~MockApplicationMasterProtocolInternal(){
+ }
+
+ MOCK_METHOD1(invoke, void(const RpcCall & call));
+
+};
+}
+#endif /* MOCKAPPLICATIONCLIENTPROTOCOLINTERNAL_H_ */
http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/383818c2/depends/libyarn/mock/MockContainerManagementProtocolInternal.h
----------------------------------------------------------------------
diff --git a/depends/libyarn/mock/MockContainerManagementProtocolInternal.h b/depends/libyarn/mock/MockContainerManagementProtocolInternal.h
new file mode 100644
index 0000000..aacf26c
--- /dev/null
+++ b/depends/libyarn/mock/MockContainerManagementProtocolInternal.h
@@ -0,0 +1,52 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+/*
+ * MockContainerManagementProtocolInternal.h
+ *
+ * Created on: April 22, 2016
+ * Author: Ruilong Huo
+ */
+
+#ifndef MOCKCONTAINERMANAGEMENTPROTOCOLINTERNAL_H_
+#define MOCKCONTAINERMANAGEMENTPROTOCOLINTERNAL_H_
+#include <string>
+
+#include "gmock/gmock.h"
+#include "libyarnserver/ContainerManagementProtocol.h"
+
+using namespace libyarn;
+using std::string; using std::list;
+
+namespace Mock{
+class MockContainerManagementProtocolInternal : public ContainerManagementProtocol {
+public:
+ MockContainerManagementProtocolInternal(string & nmHost, string & nmPort,
+ const string & tokenService, const SessionConfig & c,
+ const RpcAuth & a):
+ ContainerManagementProtocol(nmHost,nmPort,tokenService, c,a){
+ }
+ ~MockContainerManagementProtocolInternal(){
+ }
+
+ MOCK_METHOD1(invoke, void(const RpcCall & call));
+
+};
+}
+#endif /* MOCKCONTAINERMANAGEMENTPROTOCOLINTERNAL_H_ */
http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/383818c2/depends/libyarn/src/CMakeLists.txt
----------------------------------------------------------------------
diff --git a/depends/libyarn/src/CMakeLists.txt b/depends/libyarn/src/CMakeLists.txt
index cafe999..9fe2fcb 100644
--- a/depends/libyarn/src/CMakeLists.txt
+++ b/depends/libyarn/src/CMakeLists.txt
@@ -76,7 +76,7 @@ SET(HEADER
SET(RECORDS_HEADER
records/ApplicationAttemptId.h
- records/ApplicationID.h
+ records/ApplicationId.h
records/ApplicationReport.h
records/ApplicationResourceUsageReport.h
records/FinalApplicationStatus.h
http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/383818c2/depends/libyarn/src/common/Exception.cpp
----------------------------------------------------------------------
diff --git a/depends/libyarn/src/common/Exception.cpp b/depends/libyarn/src/common/Exception.cpp
index 09d1312..dffe1cc 100644
--- a/depends/libyarn/src/common/Exception.cpp
+++ b/depends/libyarn/src/common/Exception.cpp
@@ -26,47 +26,21 @@ namespace Yarn {
const char * YarnIOException::ReflexName = "java.io.IOException";
-const char * AlreadyBeingCreatedException::ReflexName =
- "org.apache.hadoop.hdfs.protocol.AlreadyBeingCreatedException";
-
const char * AccessControlException::ReflexName =
"org.apache.hadoop.security.AccessControlException";
-const char * FileAlreadyExistsException::ReflexName =
- "org.apache.hadoop.fs.FileAlreadyExistsException";
-
-const char * DSQuotaExceededException::ReflexName =
- "org.apache.hadoop.hdfs.protocol.DSQuotaExceededException";
-
-const char * NSQuotaExceededException::ReflexName =
- "org.apache.hadoop.hdfs.protocol.NSQuotaExceededException";
-
-const char * ParentNotDirectoryException::ReflexName =
- "org.apache.hadoop.fs.ParentNotDirectoryException";
-
const char * SafeModeException::ReflexName =
"org.apache.hadoop.hdfs.server.namenode.SafeModeException";
-const char * NotReplicatedYetException::ReflexName =
- "org.apache.hadoop.hdfs.server.namenode.NotReplicatedYetException";
-
-const char * FileNotFoundException::ReflexName = "java.io.FileNotFoundException";
-
const char * UnresolvedLinkException::ReflexName =
"org.apache.hadoop.fs.UnresolvedLinkException";
const char * UnsupportedOperationException::ReflexName =
"java.lang.UnsupportedOperationException";
-const char * ReplicaNotFoundException::ReflexName =
- "org.apache.hadoop.hdfs.server.datanode.ReplicaNotFoundException";
-
const char * ResourceManagerStandbyException::ReflexName =
"org.apache.hadoop.ipc.StandbyException";
-const char * YarnInvalidBlockToken::ReflexName =
- "org.apache.hadoop.security.token.SecretManager$InvalidToken";
-
const char * SaslException::ReflexName = "javax.security.sasl.SaslException";
const char * ApplicationMasterNotRegisteredException::ReflexName =
http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/383818c2/depends/libyarn/src/common/Exception.h
----------------------------------------------------------------------
diff --git a/depends/libyarn/src/common/Exception.h b/depends/libyarn/src/common/Exception.h
index 46af910..ea54e0d 100644
--- a/depends/libyarn/src/common/Exception.h
+++ b/depends/libyarn/src/common/Exception.h
@@ -102,73 +102,6 @@ public:
static const char * ReflexName;
};
-class AlreadyBeingCreatedException: public YarnException {
-public:
- AlreadyBeingCreatedException(const std::string & arg, const char * file,
- int line, const char * stack) :
- YarnException(arg, file, line, stack) {
- }
-
- ~AlreadyBeingCreatedException() throw () {
- }
-
-public:
- static const char * ReflexName;
-};
-
-class ChecksumException: public YarnException {
-public:
- ChecksumException(const std::string & arg, const char * file, int line,
- const char * stack) :
- YarnException(arg, file, line, stack) {
- }
-
- ~ChecksumException() throw () {
- }
-};
-
-class DSQuotaExceededException: public YarnException {
-public:
- DSQuotaExceededException(const std::string & arg, const char * file,
- int line, const char * stack) :
- YarnException(arg, file, line, stack) {
- }
-
- ~DSQuotaExceededException() throw () {
- }
-
-public:
- static const char * ReflexName;
-};
-
-class FileAlreadyExistsException: public YarnException {
-public:
- FileAlreadyExistsException(const std::string & arg, const char * file,
- int line, const char * stack) :
- YarnException(arg, file, line, stack) {
- }
-
- ~FileAlreadyExistsException() throw () {
- }
-
-public:
- static const char * ReflexName;
-};
-
-class FileNotFoundException: public YarnException {
-public:
- FileNotFoundException(const std::string & arg, const char * file, int line,
- const char * stack) :
- YarnException(arg, file, line, stack) {
- }
-
- ~FileNotFoundException() throw () {
- }
-
-public:
- static const char * ReflexName;
-};
-
class YarnBadBoolFormat: public YarnException {
public:
YarnBadBoolFormat(const std::string & arg, const char * file, int line,
@@ -213,17 +146,6 @@ public:
}
};
-class YarnFileSystemClosed: public YarnException {
-public:
- YarnFileSystemClosed(const std::string & arg, const char * file, int line,
- const char * stack) :
- YarnException(arg, file, line, stack) {
- }
-
- ~YarnFileSystemClosed() throw () {
- }
-};
-
class YarnConfigInvalid: public YarnException {
public:
YarnConfigInvalid(const std::string & arg, const char * file, int line,
@@ -257,20 +179,6 @@ public:
}
};
-class YarnInvalidBlockToken: public YarnException {
-public:
- YarnInvalidBlockToken(const std::string & arg, const char * file, int line,
- const char * stack) :
- YarnException(arg, file, line, stack) {
- }
-
- ~YarnInvalidBlockToken() throw () {
- }
-
-public:
- static const char * ReflexName;
-};
-
/**
* This will wrap YarnNetworkConnectionException and YarnTimeoutException.
* This exception will be caught and attempt will be performed to recover in HA case.
@@ -357,73 +265,6 @@ public:
}
};
-class InvalidPath: public YarnException {
-public:
- InvalidPath(const std::string & arg, const char * file, int line,
- const char * stack) :
- YarnException(arg, file, line, stack) {
- }
-
- ~InvalidPath() throw () {
- }
-};
-
-class NotReplicatedYetException: public YarnException {
-public:
- NotReplicatedYetException(const std::string & arg, const char * file,
- int line, const char * stack) :
- YarnException(arg, file, line, stack) {
- }
-
- ~NotReplicatedYetException() throw () {
- }
-
-public:
- static const char * ReflexName;
-};
-
-class NSQuotaExceededException: public YarnException {
-public:
- NSQuotaExceededException(const std::string & arg, const char * file,
- int line, const char * stack) :
- YarnException(arg, file, line, stack) {
- }
-
- ~NSQuotaExceededException() throw () {
- }
-
-public:
- static const char * ReflexName;
-};
-
-class ParentNotDirectoryException: public YarnException {
-public:
- ParentNotDirectoryException(const std::string & arg, const char * file,
- int line, const char * stack) :
- YarnException(arg, file, line, stack) {
- }
-
- ~ParentNotDirectoryException() throw () {
- }
-
-public:
- static const char * ReflexName;
-};
-
-class ReplicaNotFoundException: public YarnException {
-public:
- ReplicaNotFoundException(const std::string & arg, const char * file,
- int line, const char * stack) :
- YarnException(arg, file, line, stack) {
- }
-
- ~ReplicaNotFoundException() throw () {
- }
-
-public:
- static const char * ReflexName;
-};
-
class SafeModeException: public YarnException {
public:
SafeModeException(const std::string & arg, const char * file, int line,
http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/383818c2/depends/libyarn/src/libyarnclient/ApplicationClient.cpp
----------------------------------------------------------------------
diff --git a/depends/libyarn/src/libyarnclient/ApplicationClient.cpp b/depends/libyarn/src/libyarnclient/ApplicationClient.cpp
index ecbaf44..64acbe9 100644
--- a/depends/libyarn/src/libyarnclient/ApplicationClient.cpp
+++ b/depends/libyarn/src/libyarnclient/ApplicationClient.cpp
@@ -206,7 +206,7 @@ static void HandleYarnFailoverException(const Yarn::YarnFailoverException & e) {
optional ResourceProto maximumCapability = 2;
}
*/
-ApplicationID ApplicationClient::getNewApplication() {
+ApplicationId ApplicationClient::getNewApplication() {
GetNewApplicationRequest request;
GetNewApplicationResponse response;
@@ -250,7 +250,7 @@ void ApplicationClient::submitApplication(
*/
ApplicationReport ApplicationClient::getApplicationReport(
- ApplicationID &appId) {
+ ApplicationId &appId) {
GetApplicationReportRequest request;
GetApplicationReportResponse response;
@@ -302,7 +302,7 @@ QueueInfo ApplicationClient::getQueueInfo(string &queue, bool includeApps,
return response.getQueueInfo();
}
-void ApplicationClient::forceKillApplication(ApplicationID &appId) {
+void ApplicationClient::forceKillApplication(ApplicationId &appId) {
KillApplicationRequest request;
request.setApplicationId(appId);
http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/383818c2/depends/libyarn/src/libyarnclient/ApplicationClient.h
----------------------------------------------------------------------
diff --git a/depends/libyarn/src/libyarnclient/ApplicationClient.h b/depends/libyarn/src/libyarnclient/ApplicationClient.h
index 4dd1b51..f078fa3 100644
--- a/depends/libyarn/src/libyarnclient/ApplicationClient.h
+++ b/depends/libyarn/src/libyarnclient/ApplicationClient.h
@@ -23,7 +23,7 @@
#include <list>
#include "libyarnserver/ApplicationClientProtocol.h"
-#include "records/ApplicationID.h"
+#include "records/ApplicationId.h"
#include "records/ApplicationReport.h"
#include "records/ContainerReport.h"
#include "records/ApplicationSubmissionContext.h"
@@ -122,11 +122,11 @@ public:
virtual ~ApplicationClient();
- virtual ApplicationID getNewApplication();
+ virtual ApplicationId getNewApplication();
virtual void submitApplication(ApplicationSubmissionContext &appContext);
- virtual ApplicationReport getApplicationReport(ApplicationID &appId);
+ virtual ApplicationReport getApplicationReport(ApplicationId &appId);
virtual list<ContainerReport> getContainers(ApplicationAttemptId &appAttempId);
@@ -135,7 +135,7 @@ public:
virtual QueueInfo getQueueInfo(string &queue, bool includeApps,
bool includeChildQueues, bool recursive);
- virtual void forceKillApplication(ApplicationID &appId);
+ virtual void forceKillApplication(ApplicationId &appId);
virtual YarnClusterMetrics getClusterMetrics();
@@ -146,7 +146,7 @@ public:
const std::string & getUser(){uint32_t old=0; return getActiveAppClientProto(old)->getUser();};
- const AuthMethod getMethod(){uint32_t old=0; return getActiveAppClientProto(old)->getMethod();};
+ virtual const AuthMethod getMethod(){uint32_t old=0; return getActiveAppClientProto(old)->getMethod();};
const std::string getPrincipal(){uint32_t old=0; return getActiveAppClientProto(old)->getPrincipal();};
http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/383818c2/depends/libyarn/src/libyarnclient/LibYarnClient.cpp
----------------------------------------------------------------------
diff --git a/depends/libyarn/src/libyarnclient/LibYarnClient.cpp b/depends/libyarn/src/libyarnclient/LibYarnClient.cpp
index 0cf90fa..823d116 100644
--- a/depends/libyarn/src/libyarnclient/LibYarnClient.cpp
+++ b/depends/libyarn/src/libyarnclient/LibYarnClient.cpp
@@ -160,7 +160,7 @@ int LibYarnClient::createJob(string &jobName, string &queue,string &jobId) {
ApplicationClient *applicationClient = (ApplicationClient*)appClient;
//1. getNewApplication
- ApplicationID appId = applicationClient->getNewApplication();
+ ApplicationId appId = applicationClient->getNewApplication();
LOG(INFO, "LibYarnClient::createJob, getNewApplication finished, appId:[clusterTimeStamp:%lld,id:%d]",
appId.getClusterTimestamp(), appId.getId());
@@ -425,13 +425,13 @@ void LibYarnClient::addResourceRequest(Resource capability,
int LibYarnClient::addContainerRequests(string &jobId, Resource &capability, int32_t num_containers,
list<LibYarnNodeInfo> &preferred, int32_t priority, bool relax_locality)
{
- if (jobId != clientJobId) {
- throw std::invalid_argument("The jobId is wrong, check the jobId argument");
- }
+ try {
+ if (jobId != clientJobId) {
+ throw std::invalid_argument("The jobId is wrong, check the jobId argument");
+ }
- map<string, int32_t> inferredRacks;
+ map<string, int32_t> inferredRacks;
- try {
for (list<LibYarnNodeInfo>::iterator iter = preferred.begin();
iter != preferred.end(); iter++) {
LOG(INFO, "LibYarnClient::addContainerRequests, "
http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/383818c2/depends/libyarn/src/libyarnclient/LibYarnClient.h
----------------------------------------------------------------------
diff --git a/depends/libyarn/src/libyarnclient/LibYarnClient.h b/depends/libyarn/src/libyarnclient/LibYarnClient.h
index 2e3481c..f2c98ae 100644
--- a/depends/libyarn/src/libyarnclient/LibYarnClient.h
+++ b/depends/libyarn/src/libyarnclient/LibYarnClient.h
@@ -124,7 +124,7 @@ namespace libyarn {
//ContainerManagement
void *nmClient;
- ApplicationID clientAppId;
+ ApplicationId clientAppId;
ApplicationAttemptId clientAppAttempId;
// the user of running AM, default is postgres
@@ -161,9 +161,9 @@ namespace libyarn {
class LibYarnNodeInfo {
public:
- LibYarnNodeInfo(char *host, char* rack, int32_t cnt)
+ LibYarnNodeInfo(const string &host, const string &rack, int32_t cnt)
:hostname(host), num_containers(cnt)
- { if(rack == NULL) rackname = DEFAULT_RACK; else rackname = string(rack);}
+ { if(rack == "") rackname = DEFAULT_RACK; else rackname = rack;}
string getHost() { return hostname; }
string getRack() { return rackname; }
http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/383818c2/depends/libyarn/src/libyarnclient/LibYarnClientC.cpp
----------------------------------------------------------------------
diff --git a/depends/libyarn/src/libyarnclient/LibYarnClientC.cpp b/depends/libyarn/src/libyarnclient/LibYarnClientC.cpp
index cc7544d..a635cec 100644
--- a/depends/libyarn/src/libyarnclient/LibYarnClientC.cpp
+++ b/depends/libyarn/src/libyarnclient/LibYarnClientC.cpp
@@ -224,8 +224,8 @@ extern "C" {
list<LibYarnNodeInfo> preferredHostsList;
if (preferredHosts != NULL && preferredHostSize > 0) {
for (i = 0; i < preferredHostSize; i++) {
- LibYarnNodeInfo *info = new LibYarnNodeInfo(preferredHosts[i].hostname,
- preferredHosts[i].rackname,
+ LibYarnNodeInfo *info = new LibYarnNodeInfo(string(preferredHosts[i].hostname),
+ string(preferredHosts[i].rackname),
preferredHosts[i].num_containers);
preferredHostsList.push_back(*info);
totalPreferred += preferredHosts[i].num_containers;
http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/383818c2/depends/libyarn/src/libyarnserver/ApplicationClientProtocol.h
----------------------------------------------------------------------
diff --git a/depends/libyarn/src/libyarnserver/ApplicationClientProtocol.h b/depends/libyarn/src/libyarnserver/ApplicationClientProtocol.h
index 3a317c3..fb4497c 100644
--- a/depends/libyarn/src/libyarnserver/ApplicationClientProtocol.h
+++ b/depends/libyarn/src/libyarnserver/ApplicationClientProtocol.h
@@ -99,7 +99,7 @@ public:
const string getPrincipal() {return auth.getUser().getPrincipal();};
private:
- void invoke(const RpcCall & call);
+ virtual void invoke(const RpcCall & call);
private:
RpcAuth auth;
http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/383818c2/depends/libyarn/src/libyarnserver/ApplicationMasterProtocol.h
----------------------------------------------------------------------
diff --git a/depends/libyarn/src/libyarnserver/ApplicationMasterProtocol.h b/depends/libyarn/src/libyarnserver/ApplicationMasterProtocol.h
index 157563e..e589a8a 100644
--- a/depends/libyarn/src/libyarnserver/ApplicationMasterProtocol.h
+++ b/depends/libyarn/src/libyarnserver/ApplicationMasterProtocol.h
@@ -73,7 +73,7 @@ public:
FinishApplicationMasterRequest &request);
private:
- void invoke(const RpcCall & call);
+ virtual void invoke(const RpcCall & call);
private:
RpcAuth auth;
http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/383818c2/depends/libyarn/src/libyarnserver/ContainerManagementProtocol.h
----------------------------------------------------------------------
diff --git a/depends/libyarn/src/libyarnserver/ContainerManagementProtocol.h b/depends/libyarn/src/libyarnserver/ContainerManagementProtocol.h
index 6ed3b51..e7ff9c7 100644
--- a/depends/libyarn/src/libyarnserver/ContainerManagementProtocol.h
+++ b/depends/libyarn/src/libyarnserver/ContainerManagementProtocol.h
@@ -71,7 +71,7 @@ public:
virtual GetContainerStatusesResponse getContainerStatuses(GetContainerStatusesRequest &request);
private:
- void invoke(const RpcCall & call);
+ virtual void invoke(const RpcCall & call);
private:
RpcAuth auth;
http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/383818c2/depends/libyarn/src/protocolrecords/GetApplicationReportRequest.cpp
----------------------------------------------------------------------
diff --git a/depends/libyarn/src/protocolrecords/GetApplicationReportRequest.cpp b/depends/libyarn/src/protocolrecords/GetApplicationReportRequest.cpp
index 5b1c710..558c8c8 100644
--- a/depends/libyarn/src/protocolrecords/GetApplicationReportRequest.cpp
+++ b/depends/libyarn/src/protocolrecords/GetApplicationReportRequest.cpp
@@ -37,14 +37,14 @@ GetApplicationReportRequestProto& GetApplicationReportRequest::getProto() {
return requestProto;
}
-void GetApplicationReportRequest::setApplicationId(ApplicationID &appId) {
+void GetApplicationReportRequest::setApplicationId(ApplicationId &appId) {
ApplicationIdProto* proto = new ApplicationIdProto();
proto->CopyFrom(appId.getProto());
requestProto.set_allocated_application_id(proto);
}
-ApplicationID GetApplicationReportRequest::getApplicationId() {
- return ApplicationID(requestProto.application_id());
+ApplicationId GetApplicationReportRequest::getApplicationId() {
+ return ApplicationId(requestProto.application_id());
}
} /* namespace libyarn */
http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/383818c2/depends/libyarn/src/protocolrecords/GetApplicationReportRequest.h
----------------------------------------------------------------------
diff --git a/depends/libyarn/src/protocolrecords/GetApplicationReportRequest.h b/depends/libyarn/src/protocolrecords/GetApplicationReportRequest.h
index 3caa47e..abbc6d5 100644
--- a/depends/libyarn/src/protocolrecords/GetApplicationReportRequest.h
+++ b/depends/libyarn/src/protocolrecords/GetApplicationReportRequest.h
@@ -22,7 +22,7 @@
#include "YARN_yarn_service_protos.pb.h"
#include "YARN_yarn_protos.pb.h"
-#include "records/ApplicationID.h"
+#include "records/ApplicationId.h"
using namespace hadoop::yarn;
@@ -42,8 +42,8 @@ public:
GetApplicationReportRequestProto& getProto();
- void setApplicationId(ApplicationID &appId);
- ApplicationID getApplicationId();
+ void setApplicationId(ApplicationId &appId);
+ ApplicationId getApplicationId();
private:
GetApplicationReportRequestProto requestProto;
http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/383818c2/depends/libyarn/src/protocolrecords/GetApplicationReportResponse.cpp
----------------------------------------------------------------------
diff --git a/depends/libyarn/src/protocolrecords/GetApplicationReportResponse.cpp b/depends/libyarn/src/protocolrecords/GetApplicationReportResponse.cpp
index 8c0f5c6..a07e0f5 100644
--- a/depends/libyarn/src/protocolrecords/GetApplicationReportResponse.cpp
+++ b/depends/libyarn/src/protocolrecords/GetApplicationReportResponse.cpp
@@ -33,7 +33,7 @@ GetApplicationReportResponse::GetApplicationReportResponse(
GetApplicationReportResponse::~GetApplicationReportResponse() {
}
-GetApplicationReportResponseProto& GetApplicationReportResponse::proto() {
+GetApplicationReportResponseProto& GetApplicationReportResponse::getProto() {
return responseProto;
}
http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/383818c2/depends/libyarn/src/protocolrecords/GetApplicationReportResponse.h
----------------------------------------------------------------------
diff --git a/depends/libyarn/src/protocolrecords/GetApplicationReportResponse.h b/depends/libyarn/src/protocolrecords/GetApplicationReportResponse.h
index 237fe8a..bfbbaaa 100644
--- a/depends/libyarn/src/protocolrecords/GetApplicationReportResponse.h
+++ b/depends/libyarn/src/protocolrecords/GetApplicationReportResponse.h
@@ -39,7 +39,7 @@ public:
GetApplicationReportResponse(const GetApplicationReportResponseProto &proto);
virtual ~GetApplicationReportResponse();
- GetApplicationReportResponseProto& proto();
+ GetApplicationReportResponseProto& getProto();
void setApplicationReport(ApplicationReport &appReport);
ApplicationReport getApplicationReport();
http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/383818c2/depends/libyarn/src/protocolrecords/GetNewApplicationResponse.cpp
----------------------------------------------------------------------
diff --git a/depends/libyarn/src/protocolrecords/GetNewApplicationResponse.cpp b/depends/libyarn/src/protocolrecords/GetNewApplicationResponse.cpp
index 04e04ad..114f153 100644
--- a/depends/libyarn/src/protocolrecords/GetNewApplicationResponse.cpp
+++ b/depends/libyarn/src/protocolrecords/GetNewApplicationResponse.cpp
@@ -33,14 +33,14 @@ GetNewApplicationResponse::GetNewApplicationResponse(
GetNewApplicationResponse::~GetNewApplicationResponse() {
}
-void GetNewApplicationResponse::setApplicationId(ApplicationID &appId) {
+void GetNewApplicationResponse::setApplicationId(ApplicationId &appId) {
ApplicationIdProto *proto = new ApplicationIdProto();
proto->CopyFrom(appId.getProto());
responseProto.set_allocated_application_id(proto);
}
-ApplicationID GetNewApplicationResponse::getApplicationId() {
- return ApplicationID(responseProto.application_id());
+ApplicationId GetNewApplicationResponse::getApplicationId() {
+ return ApplicationId(responseProto.application_id());
}
void GetNewApplicationResponse::setResource(Resource &resource) {
http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/383818c2/depends/libyarn/src/protocolrecords/GetNewApplicationResponse.h
----------------------------------------------------------------------
diff --git a/depends/libyarn/src/protocolrecords/GetNewApplicationResponse.h b/depends/libyarn/src/protocolrecords/GetNewApplicationResponse.h
index 41335d6..12a7bd7 100644
--- a/depends/libyarn/src/protocolrecords/GetNewApplicationResponse.h
+++ b/depends/libyarn/src/protocolrecords/GetNewApplicationResponse.h
@@ -22,7 +22,7 @@
#include "YARN_yarn_protos.pb.h"
#include "YARN_yarn_service_protos.pb.h"
-#include "records/ApplicationID.h"
+#include "records/ApplicationId.h"
#include "records/Resource.h"
using namespace hadoop::yarn;
@@ -40,8 +40,8 @@ public:
GetNewApplicationResponse(const GetNewApplicationResponseProto &proto);
virtual ~GetNewApplicationResponse();
- void setApplicationId(ApplicationID &appId);
- ApplicationID getApplicationId();
+ void setApplicationId(ApplicationId &appId);
+ ApplicationId getApplicationId();
void setResource(Resource &resource);
Resource getResource();
http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/383818c2/depends/libyarn/src/protocolrecords/KillApplicationRequest.cpp
----------------------------------------------------------------------
diff --git a/depends/libyarn/src/protocolrecords/KillApplicationRequest.cpp b/depends/libyarn/src/protocolrecords/KillApplicationRequest.cpp
index 63ce33a..7702619 100644
--- a/depends/libyarn/src/protocolrecords/KillApplicationRequest.cpp
+++ b/depends/libyarn/src/protocolrecords/KillApplicationRequest.cpp
@@ -37,7 +37,7 @@ KillApplicationRequestProto& KillApplicationRequest::getProto() {
return requestProto;
}
-void KillApplicationRequest::setApplicationId(ApplicationID &applicationId) {
+void KillApplicationRequest::setApplicationId(ApplicationId &applicationId) {
ApplicationIdProto* appId = new ApplicationIdProto();
appId->CopyFrom(applicationId.getProto());
requestProto.set_allocated_application_id(appId);
http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/383818c2/depends/libyarn/src/protocolrecords/KillApplicationRequest.h
----------------------------------------------------------------------
diff --git a/depends/libyarn/src/protocolrecords/KillApplicationRequest.h b/depends/libyarn/src/protocolrecords/KillApplicationRequest.h
index 6b9702b..3abd609 100644
--- a/depends/libyarn/src/protocolrecords/KillApplicationRequest.h
+++ b/depends/libyarn/src/protocolrecords/KillApplicationRequest.h
@@ -22,7 +22,7 @@
#include "YARN_yarn_service_protos.pb.h"
#include "YARN_yarn_protos.pb.h"
-#include "records/ApplicationID.h"
+#include "records/ApplicationId.h"
using namespace hadoop::yarn;
@@ -39,7 +39,7 @@ public:
virtual ~KillApplicationRequest();
KillApplicationRequestProto& getProto();
- void setApplicationId(ApplicationID &applicationId);
+ void setApplicationId(ApplicationId &applicationId);
private:
KillApplicationRequestProto requestProto;
http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/383818c2/depends/libyarn/src/records/ApplicationAttemptId.cpp
----------------------------------------------------------------------
diff --git a/depends/libyarn/src/records/ApplicationAttemptId.cpp b/depends/libyarn/src/records/ApplicationAttemptId.cpp
index 1b47c07..8aab26e 100644
--- a/depends/libyarn/src/records/ApplicationAttemptId.cpp
+++ b/depends/libyarn/src/records/ApplicationAttemptId.cpp
@@ -36,14 +36,14 @@ ApplicationAttemptIdProto& ApplicationAttemptId::getProto(){
return attemptIdProto;
}
-void ApplicationAttemptId::setApplicationId(ApplicationID &appId) {
+void ApplicationAttemptId::setApplicationId(ApplicationId &appId) {
ApplicationIdProto *proto = new ApplicationIdProto();
proto->CopyFrom(appId.getProto());
attemptIdProto.set_allocated_application_id(proto);
}
-ApplicationID ApplicationAttemptId::getApplicationId() {
- return ApplicationID(attemptIdProto.application_id());
+ApplicationId ApplicationAttemptId::getApplicationId() {
+ return ApplicationId(attemptIdProto.application_id());
}
void ApplicationAttemptId::setAttemptId(int32_t attemptId) {
http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/383818c2/depends/libyarn/src/records/ApplicationAttemptId.h
----------------------------------------------------------------------
diff --git a/depends/libyarn/src/records/ApplicationAttemptId.h b/depends/libyarn/src/records/ApplicationAttemptId.h
index e9b70f9..9e4dafc 100644
--- a/depends/libyarn/src/records/ApplicationAttemptId.h
+++ b/depends/libyarn/src/records/ApplicationAttemptId.h
@@ -22,7 +22,7 @@
#define APPLICATIONATTEMPTID_H_
#include "YARN_yarn_protos.pb.h"
-#include "ApplicationID.h"
+#include "ApplicationId.h"
using namespace hadoop::yarn;
@@ -41,8 +41,8 @@ public:
ApplicationAttemptIdProto& getProto();
- void setApplicationId(ApplicationID &appId);
- ApplicationID getApplicationId();
+ void setApplicationId(ApplicationId &appId);
+ ApplicationId getApplicationId();
void setAttemptId(int32_t attemptId);
int32_t getAttemptId();
http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/383818c2/depends/libyarn/src/records/ApplicationID.cpp
----------------------------------------------------------------------
diff --git a/depends/libyarn/src/records/ApplicationID.cpp b/depends/libyarn/src/records/ApplicationID.cpp
index c17aa04..4fcff64 100644
--- a/depends/libyarn/src/records/ApplicationID.cpp
+++ b/depends/libyarn/src/records/ApplicationID.cpp
@@ -17,41 +17,41 @@
* under the License.
*/
-#include "ApplicationID.h"
+#include "ApplicationId.h"
namespace libyarn {
-ApplicationID::ApplicationID() {
+ApplicationId::ApplicationId() {
appIdProto = ApplicationIdProto::default_instance();
}
-ApplicationID::ApplicationID(const ApplicationIdProto &proto) : appIdProto(proto) {
+ApplicationId::ApplicationId(const ApplicationIdProto &proto) : appIdProto(proto) {
}
-ApplicationID::ApplicationID(const ApplicationID &applicationId){
+ApplicationId::ApplicationId(const ApplicationId &applicationId){
appIdProto = applicationId.appIdProto;
}
-ApplicationID::~ApplicationID() {
+ApplicationId::~ApplicationId() {
}
-ApplicationIdProto& ApplicationID::getProto() {
+ApplicationIdProto& ApplicationId::getProto() {
return appIdProto;
}
-void ApplicationID::setId(int32_t id) {
+void ApplicationId::setId(int32_t id) {
appIdProto.set_id(id);
}
-int ApplicationID::getId() {
+int ApplicationId::getId() {
return appIdProto.id();
}
-void ApplicationID::setClusterTimestamp(int64_t timestamp) {
+void ApplicationId::setClusterTimestamp(int64_t timestamp) {
appIdProto.set_cluster_timestamp(timestamp);
}
-int64_t ApplicationID::getClusterTimestamp() {
+int64_t ApplicationId::getClusterTimestamp() {
return appIdProto.cluster_timestamp();
}
http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/383818c2/depends/libyarn/src/records/ApplicationID.h
----------------------------------------------------------------------
diff --git a/depends/libyarn/src/records/ApplicationID.h b/depends/libyarn/src/records/ApplicationID.h
deleted file mode 100644
index 6eda5b3..0000000
--- a/depends/libyarn/src/records/ApplicationID.h
+++ /dev/null
@@ -1,56 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-#ifndef APPLICATIONIDS_H_
-#define APPLICATIONIDS_H_
-
-#include "YARN_yarn_protos.pb.h"
-
-using namespace hadoop::yarn;
-
-namespace libyarn {
-
-/*
-message ApplicationIdProto {
- optional int32 id = 1;
- optional int64 cluster_timestamp = 2;
-}
- */
-
-class ApplicationID {
-public:
- ApplicationID();
- ApplicationID(const ApplicationIdProto &proto);
- ApplicationID(const ApplicationID &applicationId);
- virtual ~ApplicationID();
-
- ApplicationIdProto& getProto();
-
- void setId(int32_t id);
- int32_t getId();
-
- void setClusterTimestamp(int64_t timestamp);
- int64_t getClusterTimestamp();
-
-private:
- ApplicationIdProto appIdProto;
-};
-
-} /* namespace libyarn */
-#endif /* APPLICATIONIDS_H_ */
http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/383818c2/depends/libyarn/src/records/ApplicationId.h
----------------------------------------------------------------------
diff --git a/depends/libyarn/src/records/ApplicationId.h b/depends/libyarn/src/records/ApplicationId.h
new file mode 100644
index 0000000..72014df
--- /dev/null
+++ b/depends/libyarn/src/records/ApplicationId.h
@@ -0,0 +1,56 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+#ifndef APPLICATIONIdS_H_
+#define APPLICATIONIdS_H_
+
+#include "YARN_yarn_protos.pb.h"
+
+using namespace hadoop::yarn;
+
+namespace libyarn {
+
+/*
+message ApplicationIdProto {
+ optional int32 id = 1;
+ optional int64 cluster_timestamp = 2;
+}
+ */
+
+class ApplicationId {
+public:
+ ApplicationId();
+ ApplicationId(const ApplicationIdProto &proto);
+ ApplicationId(const ApplicationId &applicationId);
+ virtual ~ApplicationId();
+
+ ApplicationIdProto& getProto();
+
+ void setId(int32_t id);
+ int32_t getId();
+
+ void setClusterTimestamp(int64_t timestamp);
+ int64_t getClusterTimestamp();
+
+private:
+ ApplicationIdProto appIdProto;
+};
+
+} /* namespace libyarn */
+#endif /* APPLICATIONIdS_H_ */
http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/383818c2/depends/libyarn/src/records/ApplicationReport.cpp
----------------------------------------------------------------------
diff --git a/depends/libyarn/src/records/ApplicationReport.cpp b/depends/libyarn/src/records/ApplicationReport.cpp
index 2ac14ef..93726e7 100644
--- a/depends/libyarn/src/records/ApplicationReport.cpp
+++ b/depends/libyarn/src/records/ApplicationReport.cpp
@@ -36,14 +36,14 @@ ApplicationReportProto& ApplicationReport::getProto() {
return reportProto;
}
-void ApplicationReport::setApplicationId(ApplicationID &appId) {
+void ApplicationReport::setApplicationId(ApplicationId &appId) {
ApplicationIdProto *proto = new ApplicationIdProto();
proto->CopyFrom(appId.getProto());
reportProto.set_allocated_applicationid(proto);
}
-ApplicationID ApplicationReport::getApplicationId() {
- return ApplicationID(reportProto.applicationid());
+ApplicationId ApplicationReport::getApplicationId() {
+ return ApplicationId(reportProto.applicationid());
}
void ApplicationReport::setUser(string &user) {
@@ -136,7 +136,7 @@ int64_t ApplicationReport::getFinishTime() {
return reportProto.finishtime();
}
-void ApplicationReport::setFinalAppStatus(FinalApplicationStatus status) {
+void ApplicationReport::setFinalApplicationStatus(FinalApplicationStatus status) {
reportProto.set_final_application_status((FinalApplicationStatusProto)status);
}
http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/383818c2/depends/libyarn/src/records/ApplicationReport.h
----------------------------------------------------------------------
diff --git a/depends/libyarn/src/records/ApplicationReport.h b/depends/libyarn/src/records/ApplicationReport.h
index 8aeb885..4106ac8 100644
--- a/depends/libyarn/src/records/ApplicationReport.h
+++ b/depends/libyarn/src/records/ApplicationReport.h
@@ -27,7 +27,7 @@
#include "Token.h"
#include "YarnApplicationState.h"
-#include "ApplicationID.h"
+#include "ApplicationId.h"
#include "YarnApplicationState.h"
#include "FinalApplicationStatus.h"
#include "ApplicationResourceUsageReport.h"
@@ -69,8 +69,8 @@ public:
ApplicationReportProto& getProto();
- void setApplicationId(ApplicationID &appId);
- ApplicationID getApplicationId();
+ void setApplicationId(ApplicationId &appId);
+ ApplicationId getApplicationId();
void setUser(string &user);
string getUser();
@@ -105,7 +105,7 @@ public:
void setFinishTime(int64_t time);
int64_t getFinishTime();
- void setFinalAppStatus(FinalApplicationStatus status);
+ void setFinalApplicationStatus(FinalApplicationStatus status);
FinalApplicationStatus getFinalApplicationStatus();
void setAppResourceUsage(ApplicationResourceUsageReport &usage);
http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/383818c2/depends/libyarn/src/records/ApplicationSubmissionContext.cpp
----------------------------------------------------------------------
diff --git a/depends/libyarn/src/records/ApplicationSubmissionContext.cpp b/depends/libyarn/src/records/ApplicationSubmissionContext.cpp
index da9e9b4..46284bd 100644
--- a/depends/libyarn/src/records/ApplicationSubmissionContext.cpp
+++ b/depends/libyarn/src/records/ApplicationSubmissionContext.cpp
@@ -37,14 +37,14 @@ ApplicationSubmissionContextProto& ApplicationSubmissionContext::getProto() {
return submitCtxProto;
}
-void ApplicationSubmissionContext::setApplicationId(ApplicationID &appId) {
+void ApplicationSubmissionContext::setApplicationId(ApplicationId &appId) {
ApplicationIdProto *proto = new ApplicationIdProto();
proto->CopyFrom(appId.getProto());
submitCtxProto.set_allocated_application_id(proto);
}
-ApplicationID ApplicationSubmissionContext::getApplicationId() {
- return ApplicationID(submitCtxProto.application_id());
+ApplicationId ApplicationSubmissionContext::getApplicationId() {
+ return ApplicationId(submitCtxProto.application_id());
}
void ApplicationSubmissionContext::setApplicationName(string &applicationName) {
http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/383818c2/depends/libyarn/src/records/ApplicationSubmissionContext.h
----------------------------------------------------------------------
diff --git a/depends/libyarn/src/records/ApplicationSubmissionContext.h b/depends/libyarn/src/records/ApplicationSubmissionContext.h
index f371a9f..28516a7 100644
--- a/depends/libyarn/src/records/ApplicationSubmissionContext.h
+++ b/depends/libyarn/src/records/ApplicationSubmissionContext.h
@@ -23,7 +23,7 @@
#include <iostream>
#include "ContainerLaunchContext.h"
#include "YARN_yarn_protos.pb.h"
-#include "ApplicationID.h"
+#include "ApplicationId.h"
#include "Priority.h"
#include "Resource.h"
@@ -53,8 +53,8 @@ public:
ApplicationSubmissionContextProto& getProto();
- void setApplicationId(ApplicationID &appId);
- ApplicationID getApplicationId();
+ void setApplicationId(ApplicationId &appId);
+ ApplicationId getApplicationId();
void setApplicationName(string &applicationName);
string getApplicationName();
http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/383818c2/depends/libyarn/src/records/ContainerId.cpp
----------------------------------------------------------------------
diff --git a/depends/libyarn/src/records/ContainerId.cpp b/depends/libyarn/src/records/ContainerId.cpp
index 6fabddc..d934b24 100644
--- a/depends/libyarn/src/records/ContainerId.cpp
+++ b/depends/libyarn/src/records/ContainerId.cpp
@@ -35,14 +35,14 @@ ContainerIdProto& ContainerId::getProto(){
return containerIdProto;
}
-void ContainerId::setApplicationId(ApplicationID &appId) {
+void ContainerId::setApplicationId(ApplicationId &appId) {
ApplicationIdProto *proto = new ApplicationIdProto();
proto->CopyFrom(appId.getProto());
containerIdProto.set_allocated_app_id(proto);
}
-ApplicationID ContainerId::getApplicationId() {
- return ApplicationID(containerIdProto.app_id());
+ApplicationId ContainerId::getApplicationId() {
+ return ApplicationId(containerIdProto.app_id());
}
void ContainerId::setApplicationAttemptId(ApplicationAttemptId &appAttemptId) {
http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/383818c2/depends/libyarn/src/records/ContainerId.h
----------------------------------------------------------------------
diff --git a/depends/libyarn/src/records/ContainerId.h b/depends/libyarn/src/records/ContainerId.h
index ee89d2a..9f5b8f7 100644
--- a/depends/libyarn/src/records/ContainerId.h
+++ b/depends/libyarn/src/records/ContainerId.h
@@ -22,7 +22,7 @@
#include "YARN_yarn_protos.pb.h"
-#include "ApplicationID.h"
+#include "ApplicationId.h"
#include "ApplicationAttemptId.h"
using namespace hadoop::yarn;
@@ -45,8 +45,8 @@ public:
ContainerIdProto& getProto();
- void setApplicationId(ApplicationID &appId);
- ApplicationID getApplicationId();
+ void setApplicationId(ApplicationId &appId);
+ ApplicationId getApplicationId();
void setApplicationAttemptId(ApplicationAttemptId &appAttemptId);
ApplicationAttemptId getApplicationAttemptId();
http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/383818c2/depends/libyarn/src/records/ContainerReport.cpp
----------------------------------------------------------------------
diff --git a/depends/libyarn/src/records/ContainerReport.cpp b/depends/libyarn/src/records/ContainerReport.cpp
index 9b4d7d2..1bded5e 100644
--- a/depends/libyarn/src/records/ContainerReport.cpp
+++ b/depends/libyarn/src/records/ContainerReport.cpp
@@ -97,7 +97,7 @@ ContainerExitStatus ContainerReport::getContainerExitStatus(){
return (ContainerExitStatus)reportProto.container_exit_status();
}
-void ContainerReport::setContaierState(ContainerState state){
+void ContainerReport::setContainerState(ContainerState state){
reportProto.set_container_state((ContainerStateProto)state);
}
http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/383818c2/depends/libyarn/src/records/ContainerReport.h
----------------------------------------------------------------------
diff --git a/depends/libyarn/src/records/ContainerReport.h b/depends/libyarn/src/records/ContainerReport.h
index 2e034f0..0bf4ed5 100644
--- a/depends/libyarn/src/records/ContainerReport.h
+++ b/depends/libyarn/src/records/ContainerReport.h
@@ -79,7 +79,7 @@ public:
void setContainerExitStatus(ContainerExitStatus container_exit_status);
ContainerExitStatus getContainerExitStatus();
- void setContaierState(ContainerState state);
+ void setContainerState(ContainerState state);
ContainerState getContainerState();
void setDiagnostics(string &diagnostics);
http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/383818c2/depends/libyarn/src/records/ContainerStatus.cpp
----------------------------------------------------------------------
diff --git a/depends/libyarn/src/records/ContainerStatus.cpp b/depends/libyarn/src/records/ContainerStatus.cpp
index ac9dab9..4048c55 100644
--- a/depends/libyarn/src/records/ContainerStatus.cpp
+++ b/depends/libyarn/src/records/ContainerStatus.cpp
@@ -45,7 +45,7 @@ ContainerId ContainerStatus::getContainerId() {
return ContainerId(statusProto.container_id());
}
-void ContainerStatus::setContaierState(ContainerState state) {
+void ContainerStatus::setContainerState(ContainerState state) {
statusProto.set_state((ContainerStateProto)state);
}
http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/383818c2/depends/libyarn/src/records/ContainerStatus.h
----------------------------------------------------------------------
diff --git a/depends/libyarn/src/records/ContainerStatus.h b/depends/libyarn/src/records/ContainerStatus.h
index f099985..59b3084 100644
--- a/depends/libyarn/src/records/ContainerStatus.h
+++ b/depends/libyarn/src/records/ContainerStatus.h
@@ -46,7 +46,7 @@ public:
void setContainerId(ContainerId &containerId);
ContainerId getContainerId();
- void setContaierState(ContainerState state);
+ void setContainerState(ContainerState state);
ContainerState getContainerState();
void setDiagnostics(string &diagnostics);
http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/383818c2/depends/libyarn/test/function/TestLibYarnClient.cpp
----------------------------------------------------------------------
diff --git a/depends/libyarn/test/function/TestLibYarnClient.cpp b/depends/libyarn/test/function/TestLibYarnClient.cpp
index 5260775..620c7d0 100644
--- a/depends/libyarn/test/function/TestLibYarnClient.cpp
+++ b/depends/libyarn/test/function/TestLibYarnClient.cpp
@@ -17,6 +17,8 @@
* under the License.
*/
+#include <string>
+
#include "gtest/gtest.h"
#include "libyarnclient/LibYarnClient.h"
#include "records/FinalApplicationStatus.h"
http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/383818c2/depends/libyarn/test/function/TestLibYarnClientC.cpp
----------------------------------------------------------------------
diff --git a/depends/libyarn/test/function/TestLibYarnClientC.cpp b/depends/libyarn/test/function/TestLibYarnClientC.cpp
new file mode 100644
index 0000000..2ec9743
--- /dev/null
+++ b/depends/libyarn/test/function/TestLibYarnClientC.cpp
@@ -0,0 +1,139 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+#include "gtest/gtest.h"
+#include "libyarn/LibYarnClientC.h"
+
+extern "C" {
+
+class TestLibYarnClientC: public ::testing::Test {
+public:
+ TestLibYarnClientC(){
+ char *user = "postgres";
+ char *rmHost = "localhost";
+ char *rmPort = "8032";
+ char *schedHost = "localhost";
+ char *schedPort = "8030";
+ char *amHost = "localhost";
+ int32_t amPort = 0;
+ char *am_tracking_url = "url";
+ int heartbeatInterval = 1000;
+ client = NULL;
+ result = newLibYarnClient(user, rmHost, rmPort, schedHost, schedPort, amHost, amPort, am_tracking_url, &client, heartbeatInterval);
+ }
+ ~TestLibYarnClientC(){
+ }
+protected:
+ LibYarnClient_t *client;
+ int result;
+ int i;
+};
+
+TEST_F(TestLibYarnClientC,TestLibYarn){
+ EXPECT_EQ(result, FUNCTION_SUCCEEDED);
+
+ char *jobName = "libyarn";
+ char *queue = "default";
+ char *jobId = NULL;
+ result = createJob(client, jobName, queue, &jobId);
+ EXPECT_EQ(result, FUNCTION_SUCCEEDED);
+
+ LibYarnNodeReport_t *nodeReportArray;
+ int nodeReportArraySize;
+ result = getClusterNodes(client, NODE_STATE_RUNNING, &nodeReportArray, &nodeReportArraySize);
+ EXPECT_EQ(result, FUNCTION_SUCCEEDED);
+ EXPECT_GT(nodeReportArraySize, 0);
+
+ char *localhost = strdup(nodeReportArray[0].host);
+
+ freeMemNodeReportArray(nodeReportArray, nodeReportArraySize);
+
+ char *blackListAdditions[0];
+ char *blackListRemovals[0];
+ LibYarnNodeInfo_t preferredHosts[1];
+ preferredHosts[0].hostname = localhost;
+ preferredHosts[0].rackname = "/default-rack";
+ preferredHosts[0].num_containers = 2;
+ int preferredHostSize = 1;
+ LibYarnResource_t *allocatedResourcesArray;
+ int allocatedResourcesArraySize;
+ result = allocateResources(client, jobId, 1, 1, 1024, 5,
+ blackListAdditions, 0, blackListRemovals, 0, preferredHosts, preferredHostSize,
+ &allocatedResourcesArray, &allocatedResourcesArraySize);
+ EXPECT_EQ(result, FUNCTION_SUCCEEDED);
+
+ int64_t activeContainerIds[allocatedResourcesArraySize];
+ int64_t releaseContainerIds[allocatedResourcesArraySize];
+ int64_t statusContainerIds[allocatedResourcesArraySize];
+ for (i = 0 ; i < allocatedResourcesArraySize; i++) {
+ activeContainerIds[i] = allocatedResourcesArray[i].containerId;
+ releaseContainerIds[i] = allocatedResourcesArray[i].containerId;
+ statusContainerIds[i] = allocatedResourcesArray[i].containerId;
+ }
+
+ result = activeResources(client, jobId, activeContainerIds, allocatedResourcesArraySize);
+ EXPECT_EQ(result, FUNCTION_SUCCEEDED);
+
+ freeMemAllocatedResourcesArray(allocatedResourcesArray, allocatedResourcesArraySize);
+
+ sleep(10);
+
+ int64_t *activeFailIds;
+ int activeFailSize;
+ result = getActiveFailContainerIds(client,&activeFailIds,&activeFailSize);
+ EXPECT_EQ(result, FUNCTION_SUCCEEDED);
+ EXPECT_EQ(activeFailSize, 0);
+
+ LibYarnApplicationReport_t *applicationReport;
+ result = getApplicationReport(client, jobId, &applicationReport);
+ EXPECT_EQ(result, FUNCTION_SUCCEEDED);
+
+ freeApplicationReport(applicationReport);
+
+ LibYarnContainerReport_t *containerReportArray;
+ int containerReportArraySize;
+ result = getContainerReports(client, jobId, &containerReportArray, &containerReportArraySize);
+ EXPECT_EQ(result, FUNCTION_SUCCEEDED);
+ EXPECT_EQ(containerReportArraySize, 5);
+
+ freeContainerReportArray(containerReportArray, containerReportArraySize);
+
+ LibYarnContainerStatus_t *containerStatusArray;
+ int containerStatusArraySize;
+ result = getContainerStatuses(client, jobId, statusContainerIds,
+ allocatedResourcesArraySize, &containerStatusArray,
+ &containerStatusArraySize);
+ EXPECT_EQ(result, FUNCTION_SUCCEEDED);
+ EXPECT_EQ(containerReportArraySize, 5);
+
+ freeContainerStatusArray(containerStatusArray, containerStatusArraySize);
+
+ result = releaseResources(client, jobId, releaseContainerIds, allocatedResourcesArraySize);
+ EXPECT_EQ(result, FUNCTION_SUCCEEDED);
+
+ LibYarnQueueInfo_t *queueInfo = NULL;
+ result = getQueueInfo(client, queue, true, true, true, &queueInfo);
+ EXPECT_EQ(result, FUNCTION_SUCCEEDED);
+
+ freeMemQueueInfo(queueInfo);
+
+ result = finishJob(client, jobId, APPLICATION_SUCCEEDED);
+ EXPECT_EQ(result, FUNCTION_SUCCEEDED);
+}
+}
http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/383818c2/depends/libyarn/test/function/TestMockApplicationClientProtocol.cpp
----------------------------------------------------------------------
diff --git a/depends/libyarn/test/function/TestMockApplicationClientProtocol.cpp b/depends/libyarn/test/function/TestMockApplicationClientProtocol.cpp
index 24a110a..fa59c38 100644
--- a/depends/libyarn/test/function/TestMockApplicationClientProtocol.cpp
+++ b/depends/libyarn/test/function/TestMockApplicationClientProtocol.cpp
@@ -17,6 +17,8 @@
* under the License.
*/
+#include <string>
+
#include "gtest/gtest.h"
#include "gmock/gmock.h"
http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/383818c2/depends/libyarn/test/function/TestMockApplicationMasterProtocol.cpp
----------------------------------------------------------------------
diff --git a/depends/libyarn/test/function/TestMockApplicationMasterProtocol.cpp b/depends/libyarn/test/function/TestMockApplicationMasterProtocol.cpp
index 4236ccb..b48287b 100644
--- a/depends/libyarn/test/function/TestMockApplicationMasterProtocol.cpp
+++ b/depends/libyarn/test/function/TestMockApplicationMasterProtocol.cpp
@@ -17,6 +17,8 @@
* under the License.
*/
+#include <string>
+
#include "gtest/gtest.h"
#include "gmock/gmock.h"
http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/383818c2/depends/libyarn/test/unit/TestApplicationClient.cpp
----------------------------------------------------------------------
diff --git a/depends/libyarn/test/unit/TestApplicationClient.cpp b/depends/libyarn/test/unit/TestApplicationClient.cpp
deleted file mode 100644
index d81ac0a..0000000
--- a/depends/libyarn/test/unit/TestApplicationClient.cpp
+++ /dev/null
@@ -1,264 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-#include "gtest/gtest.h"
-#include "gmock/gmock.h"
-
-#include "libyarnclient/ApplicationClient.h"
-#include "MockApplicationClientProtocol.h"
-
-using std::string;
-using std::list;
-using namespace libyarn;
-using namespace testing;
-using namespace Mock;
-
-class TestApplicationClient: public ::testing::Test {
-public:
- TestApplicationClient(){
- string user("postgres");
- string rmHost("localhost");
- string rmPort("8032");
- string tokenService = "";
- Yarn::Config config;
- Yarn::Internal::SessionConfig sessionConfig(config);
- MockApplicationClientProtocol *protocol = new MockApplicationClientProtocol(user,rmHost,rmPort,tokenService, sessionConfig);
-
- ApplicationID appId;
- appId.setId(100);
- appId.setClusterTimestamp(1454307175682);
- GetNewApplicationResponse getNewApplicationResponse;
- getNewApplicationResponse.setApplicationId(appId);
- EXPECT_CALL((*protocol),getNewApplication(_)).Times(AnyNumber()).WillOnce(Return(getNewApplicationResponse));
- EXPECT_CALL((*protocol),submitApplication(_)).Times(AnyNumber()).WillOnce(Return());
-
- ApplicationReport appReport;
- appReport.setApplicationId(appId);
- appReport.setUser(user);
- string queue("default");
- string appName("hawq");
- string hostname("master");
- appReport.setQueue(queue);
- appReport.setName(appName);
- appReport.setHost(hostname);
- appReport.setRpcPort(8090);
- appReport.setProgress(0.5);
- GetApplicationReportResponse appReportResponse;
- appReportResponse.setApplicationReport(appReport);
- EXPECT_CALL((*protocol),getApplicationReport(_)).Times(AnyNumber()).WillOnce(Return(appReportResponse));
-
- ContainerId containerId;
- containerId.setId(501);
- containerId.setApplicationId(appId);
- Resource resource;
- resource.setMemory(1024);
- resource.setVirtualCores(1);
- Priority priority;
- priority.setPriority(1);
- ContainerReport report;
- report.setId(containerId);
- report.setResource(resource);
- report.setPriority(priority);
- list<ContainerReport> reportList;
- reportList.push_back(report);
- GetContainersResponse getContainersResponse;
- getContainersResponse.setContainersReportList(reportList);
- EXPECT_CALL((*protocol),getContainers(_)).Times(AnyNumber()).WillOnce(Return(getContainersResponse));
-
- NodeId nodeId;
- string nodeHost("node1");
- nodeId.setHost(nodeHost);
- nodeId.setPort(9983);
- NodeReport nodeReport;
- nodeReport.setNodeId(nodeId);
- string rackName("default-rack");
- nodeReport.setRackName(rackName);
- nodeReport.setNumContainers(8);
- Resource nodeResource;
- nodeResource.setMemory(2048*8);
- nodeResource.setVirtualCores(8);
- nodeReport.setResourceCapablity(nodeResource);
- nodeReport.setNodeState(NodeState::NS_RUNNING);
- list<NodeReport> nodeReportList;
- nodeReportList.push_back(nodeReport);
- GetClusterNodesResponse getClusterNodesResponse;
- getClusterNodesResponse.setNodeReports(nodeReportList);
- EXPECT_CALL((*protocol),getClusterNodes(_)).Times(AnyNumber()).WillOnce(Return(getClusterNodesResponse));
-
- QueueInfo queueInfo;
- queueInfo.setQueueName(queue);
- queueInfo.setCapacity(0.67);
- queueInfo.setMaximumCapacity(0.95);
- queueInfo.setCurrentCapacity(0.5);
- queueInfo.setQueueState(QueueState::Q_RUNNING);
- QueueInfo childQueue;
- string childQueueName("hawq-queue");
- childQueue.setQueueName(childQueueName);
- childQueue.setCapacity(0.33);
- childQueue.setMaximumCapacity(0.5);
- childQueue.setCurrentCapacity(0.25);
- list<QueueInfo> childQueueList;
- childQueueList.push_back(childQueue);
- queueInfo.setChildQueues(childQueueList);
- list<ApplicationReport> appReportList;
- appReportList.push_back(appReport);
- queueInfo.setApplicationReports(appReportList);
- GetQueueInfoResponse getQueueInfoResponse;
- getQueueInfoResponse.setQueueInfo(queueInfo);
- EXPECT_CALL((*protocol),getQueueInfo(_)).Times(AnyNumber()).WillOnce(Return(getQueueInfoResponse));
-
- KillApplicationResponseProto killApplicationResponseProto;
- EXPECT_CALL((*protocol),forceKillApplication(_)).Times(AnyNumber()).WillOnce(Return(KillApplicationResponse(killApplicationResponseProto)));
-
- YarnClusterMetrics metrics;
- metrics.setNumNodeManagers(10);
- GetClusterMetricsResponse clusterMetricsResponse;
- clusterMetricsResponse.setClusterMetrics(metrics);
- EXPECT_CALL((*protocol),getClusterMetrics(_)).Times(AnyNumber()).WillOnce(Return(clusterMetricsResponse));
-
- GetApplicationsResponse applicationsResponse;
- applicationsResponse.setApplicationList(appReportList);
- EXPECT_CALL((*protocol),getApplications(_)).Times(AnyNumber()).WillOnce(Return(applicationsResponse));
-
- QueueUserACLInfo aclInfo;
- aclInfo.setQueueName(queue);
- list<QueueACL> queueACLList;
- QueueACL acl1 = QueueACL::QACL_ADMINISTER_QUEUE;
- QueueACL acl2 = QueueACL::QACL_SUBMIT_APPLICATIONS;
- queueACLList.push_back(acl1);
- queueACLList.push_back(acl2);
- aclInfo.setUserAcls(queueACLList);
- list<QueueUserACLInfo> aclInfoList;
- aclInfoList.push_back(aclInfo);
- GetQueueUserAclsInfoResponse queueUserAclsInfoResponse;
- queueUserAclsInfoResponse.setUserAclsInfoList(aclInfoList);
- EXPECT_CALL((*protocol),getQueueAclsInfo(_)).Times(AnyNumber()).WillOnce(Return(queueUserAclsInfoResponse));
-
- client = new ApplicationClient(protocol);
- }
-
- ~TestApplicationClient(){
- delete client;
- }
-
-protected:
- ApplicationClient *client;
-};
-
-TEST_F(TestApplicationClient, TestGetNewApplication){
- ApplicationID response = client->getNewApplication();
- EXPECT_EQ(response.getId(), 100);
- EXPECT_EQ(response.getClusterTimestamp(), 1454307175682);
-}
-
-TEST_F(TestApplicationClient,TestSubmitApplication){
- ApplicationSubmissionContext appContext;
- client->submitApplication(appContext);
-}
-
-TEST_F(TestApplicationClient,TestGetApplicationReport){
- ApplicationID appId;
- ApplicationReport report = client->getApplicationReport(appId);
- EXPECT_EQ(report.getUser(), "postgres");
- EXPECT_EQ(report.getQueue(), "default");
- EXPECT_EQ(report.getName(), "hawq");
- EXPECT_EQ(report.getHost(), "master");
- EXPECT_EQ(report.getRpcPort(), 8090);
- EXPECT_FLOAT_EQ(report.getProgress(), 0.5);
-}
-
-TEST_F(TestApplicationClient,TestGetContainers){
- ApplicationAttemptId appAttempId;
- list<ContainerReport> reports = client->getContainers(appAttempId);
- EXPECT_EQ(reports.size(), 1);
- list<ContainerReport>::iterator it = reports.begin();
- EXPECT_EQ(it->getId().getId(), 501);
- EXPECT_EQ(it->getPriority().getPriority(), 1);
- EXPECT_EQ(it->getResource().getMemory(), 1024);
- EXPECT_EQ(it->getResource().getVirtualCores(), 1);
-}
-
-TEST_F(TestApplicationClient,TestGetClusterNodes){
- list<NodeState> states;
- list<NodeReport> reports = client->getClusterNodes(states);
- EXPECT_EQ(reports.size(), 1);
- list<NodeReport>::iterator it = reports.begin();
- EXPECT_EQ(it->getNodeId().getHost(), "node1");
- EXPECT_EQ(it->getNodeId().getPort(), 9983);
- EXPECT_EQ(it->getRackName(), "default-rack");
- EXPECT_EQ(it->getResourceCapability().getMemory(), 2048*8);
- EXPECT_EQ(it->getResourceCapability().getVirtualCores(), 8);
- EXPECT_EQ(it->getNodeState(), NodeState::NS_RUNNING);
- EXPECT_EQ(it->getNumContainers(), 8);
-}
-
-TEST_F(TestApplicationClient,TestGetQueueInfo){
- string queue = "";
- QueueInfo queueInfo = client->getQueueInfo(queue,true,true,true);
- EXPECT_EQ(queueInfo.getQueueName(), "default");
- EXPECT_FLOAT_EQ(queueInfo.getCapacity(), 0.67);
- EXPECT_FLOAT_EQ(queueInfo.getMaximumCapacity(), 0.95);
- EXPECT_FLOAT_EQ(queueInfo.getCurrentCapacity(), 0.5);
- EXPECT_EQ(queueInfo.getQueueState(), QueueState::Q_RUNNING);
- list<QueueInfo> child = queueInfo.getChildQueues();
- EXPECT_EQ(child.size(), 1);
- list<QueueInfo>::iterator it = child.begin();
- EXPECT_EQ(it->getQueueName(), "hawq-queue");
- EXPECT_FLOAT_EQ(it->getCapacity(), 0.33);
- EXPECT_FLOAT_EQ(it->getMaximumCapacity(), 0.5);
- EXPECT_FLOAT_EQ(it->getCurrentCapacity(), 0.25);
- list<ApplicationReport> appReportList = queueInfo.getApplicationReports();
- list<ApplicationReport>::iterator itAppReport = appReportList.begin();
- EXPECT_EQ(itAppReport->getApplicationId().getId(), 100);
- EXPECT_EQ(itAppReport->getUser(), "postgres");
-}
-
-TEST_F(TestApplicationClient,TestForceKillApplication){
- ApplicationID appId;
- client->forceKillApplication(appId);
-}
-
-TEST_F(TestApplicationClient,TestGetClusterMetrics){
- YarnClusterMetrics response = client->getClusterMetrics();
- EXPECT_EQ(response.getNumNodeManagers(), 10);
-}
-
-TEST_F(TestApplicationClient,TestGetApplications){
- list<string> applicationTypes;
- list<YarnApplicationState> applicationStates;
- list<ApplicationReport> reports = client->getApplications(applicationTypes,applicationStates);
- EXPECT_EQ(reports.size(), 1);
- list<ApplicationReport>::iterator it = reports.begin();
- EXPECT_EQ(it->getApplicationId().getId(), 100);
- EXPECT_EQ(it->getUser(), "postgres");
-}
-
-TEST_F(TestApplicationClient,TestGetQueueAclsInfo){
- list<QueueUserACLInfo> response = client->getQueueAclsInfo();
- EXPECT_EQ(response.size(), 1);
- list<QueueUserACLInfo>::iterator it = response.begin();
- EXPECT_EQ(it->getQueueName(), "default");
- list<QueueACL> queueACLs = it->getUserAcls();
- EXPECT_EQ(queueACLs.size(), 2);
- list<QueueACL>::iterator queueACL = queueACLs.begin();
- EXPECT_EQ(*queueACL, QueueACL::QACL_ADMINISTER_QUEUE);
- *queueACL++;
- EXPECT_EQ(*queueACL, QueueACL::QACL_SUBMIT_APPLICATIONS);
-}
-
http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/383818c2/depends/libyarn/test/unit/TestApplicationMaster.cpp
----------------------------------------------------------------------
diff --git a/depends/libyarn/test/unit/TestApplicationMaster.cpp b/depends/libyarn/test/unit/TestApplicationMaster.cpp
deleted file mode 100644
index ad2f7d4..0000000
--- a/depends/libyarn/test/unit/TestApplicationMaster.cpp
+++ /dev/null
@@ -1,193 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-#include "gtest/gtest.h"
-#include "gmock/gmock.h"
-
-#include "libyarnclient/ApplicationMaster.h"
-#include "MockApplicationMasterProtocol.h"
-
-using std::string;
-using std::list;
-using namespace libyarn;
-using namespace testing;
-using namespace Mock;
-
-class TestApplicationMaster: public ::testing::Test {
-public:
- TestApplicationMaster(){
- string schedHost("localhost");
- string schedPort("8032");
- string tokenService = "";
- Yarn::Config config;
- Yarn::Internal::SessionConfig sessionConfig(config);
- Yarn::Internal::UserInfo user = Yarn::Internal::UserInfo::LocalUser();
- Yarn::Internal::RpcAuth rpcAuth(user, Yarn::Internal::AuthMethod::SIMPLE);
- protocol = new MockApplicationMasterProtocol(schedHost,schedPort,tokenService, sessionConfig,rpcAuth);
- client = new ApplicationMaster(protocol);
- }
- ~TestApplicationMaster(){
- delete client;
- }
-
-protected:
- MockApplicationMasterProtocol *protocol;
- ApplicationMaster *client;
-};
-
-TEST_F(TestApplicationMaster,TestRegisterApplicationMaster){
- Resource resource;
- resource.setMemory(1024*8*10);
- resource.setVirtualCores(1*8*10);
- string key("tokenkey");
- ApplicationACLMap aclMap;
- aclMap.setAccessType(ApplicationAccessType::APPACCESS_VIEW_APP);
- string acl("acl");
- aclMap.setAcl(acl);
- list<ApplicationACLMap> aclMapList;
- aclMapList.push_back(aclMap);
- RegisterApplicationMasterResponse response;
- response.setMaximumResourceCapability(resource);
- response.setClientToAMTokenMasterKey(key);
- response.setApplicationACLs(aclMapList);
- EXPECT_CALL((*protocol),registerApplicationMaster(_)).Times(AnyNumber()).WillOnce(Return(response));
-
- string amHost("localhost");
- int amPort = 8032;
- string am_tracking_url = "";
- RegisterApplicationMasterResponse retResponse = client->registerApplicationMaster(amHost,amPort,am_tracking_url);
- EXPECT_EQ(retResponse.getClientToAMTokenMasterKey(), "tokenkey");
- Resource retResource = retResponse.getMaximumResourceCapability();
- EXPECT_EQ(retResource.getMemory(), 1024*8*10);
- EXPECT_EQ(retResource.getVirtualCores(), 1*8*10);
- list<ApplicationACLMap> retAclMapList = retResponse.getApplicationACLs();
- EXPECT_EQ(retAclMapList.size(), 1);
- list<ApplicationACLMap>::iterator it = retAclMapList.begin();
- EXPECT_EQ(it->getAccessType(), ApplicationAccessType::APPACCESS_VIEW_APP);
- EXPECT_EQ(it->getAcl(), "acl");
-}
-
-TEST_F(TestApplicationMaster,TestAllocate){
- Resource resource;
- resource.setMemory(1024*8*10);
- resource.setVirtualCores(1*8*10);
- AllocateResponse allocateResponse;
- allocateResponse.setAMCommand(AMCommand::AM_RESYNC);
- allocateResponse.setResponseId(100);
- list<Container> containers;
- Container container;
- ContainerId containerId;
- containerId.setId(501);
- container.setId(containerId);
- NodeId nodeId;
- string nodeHost("node1");
- nodeId.setHost(nodeHost);
- nodeId.setPort(9983);
- container.setNodeId(nodeId);
- string address("http://address");
- container.setNodeHttpAddress(address);
- container.setResource(resource);
- Priority priority;
- priority.setPriority(1);
- container.setPriority(priority);
- libyarn::Token token;
- string identifier("identifier");
- token.setIdentifier(identifier);
- string password("password");
- token.setPassword(password);
- string kind("kind");
- token.setKind(kind);
- string service("service");
- token.setService(service);
- container.setContainerToken(token);
- containers.push_back(container);
- allocateResponse.setAllocatedContainers(containers);
- ContainerStatus containerStatus;
- containerStatus.setContainerId(containerId);
- containerStatus.setContaierState(ContainerState::C_RUNNING);
- string diagnostics("diagnostics");
- containerStatus.setDiagnostics(diagnostics);
- containerStatus.setExitStatus(-1000);
- list<ContainerStatus> statuses;
- statuses.push_back(containerStatus);
- allocateResponse.setCompletedContainerStatuses(statuses);
- allocateResponse.setResourceLimit(resource);
- NodeReport nodeReport;
- nodeReport.setNodeId(nodeId);
- string rackName("default-rack");
- nodeReport.setRackName(rackName);
- nodeReport.setNumContainers(8);
- list<NodeReport> nodeReports;
- nodeReports.push_back(nodeReport);
- allocateResponse.setUpdatedNodes(nodeReports);
- allocateResponse.setNumClusterNodes(12);
- NMToken nmToken;
- nmToken.setNodeId(nodeId);
- nmToken.setToken(token);
- list<NMToken> nmTokens;
- nmTokens.push_back(nmToken);
- allocateResponse.setNMTokens(nmTokens);
- EXPECT_CALL((*protocol),allocate(_)).Times(AnyNumber()).WillOnce(Return(allocateResponse));
-
- list<ResourceRequest> asks;
- list<ContainerId> releases;
- ResourceBlacklistRequest blacklistRequest;
- int32_t responseId;
- float progress = 5;
- AllocateResponse retResponse = client->allocate(asks,releases,blacklistRequest,responseId,progress);
- EXPECT_EQ(retResponse.getAMCommand(), AMCommand::AM_RESYNC);
- EXPECT_EQ(retResponse.getResponseId(), 100);
- list<Container> retContainers = retResponse.getAllocatedContainers();
- list<Container>::iterator it = retContainers.begin();
- EXPECT_EQ(it->getId().getId(), 501);
- EXPECT_EQ(it->getNodeId().getHost(), "node1");
- EXPECT_EQ(it->getNodeId().getPort(), 9983);
- EXPECT_EQ(it->getNodeHttpAddress(), "http://address");
- EXPECT_EQ(it->getPriority().getPriority(), 1);
- EXPECT_EQ(it->getResource().getMemory(), 1024*8*10);
- EXPECT_EQ(it->getResource().getVirtualCores(), 1*8*10);
- EXPECT_EQ(it->getContainerToken().getIdentifier(), "identifier");
- EXPECT_EQ(it->getContainerToken().getPassword(), "password");
- EXPECT_EQ(it->getContainerToken().getKind(), "kind");
- EXPECT_EQ(it->getContainerToken().getService(), "service");
- list<ContainerStatus>::iterator retStatus = retResponse.getCompletedContainersStatuses().begin();
- EXPECT_EQ(retStatus->getContainerId().getId(), 501);
- EXPECT_EQ(retStatus->getContainerState(), ContainerState::C_RUNNING);
- //EXPECT_EQ(retStatus->getDiagnostics(), "diagnostics");
- EXPECT_EQ(retStatus->getExitStatus(), -1000);
- EXPECT_EQ(retResponse.getResourceLimit().getMemory(), 1024*8*10);
- //list<NodeReport>::iterator report = response.getUpdatedNodes().begin();
- //EXPECT_EQ(report->getNodeId().getHost(), "node1");
- //list<NMToken>::iterator nmToken = response.getNMTokens().begin();
- //EXPECT_EQ(nmToken->getNodeId().getHost(), "node1");
- //EXPECT_EQ(nmToken->getToken().getIdentifier(), "identifier");
- EXPECT_EQ(retResponse.getNumClusterNodes(), 12);
-}
-
-TEST_F(TestApplicationMaster,TestFinishApplicationMaster){
- FinishApplicationMasterResponse finishApplicationMasterResponse;
- finishApplicationMasterResponse.setIsUnregistered(true);
- EXPECT_CALL((*protocol),finishApplicationMaster(_)).Times(AnyNumber()).WillOnce(Return(finishApplicationMasterResponse));
- string diagnostics("");
- string trackingUrl("");
- FinalApplicationStatus finalstatus;
- bool response = client->finishApplicationMaster(diagnostics,trackingUrl,finalstatus);
- EXPECT_EQ(response,true);
-}
-
[4/5] incubator-hawq git commit: HAWQ-891. Refine libyarn codes
Posted by wl...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/383818c2/depends/libyarn/test/unit/TestContainerManagement.cpp
----------------------------------------------------------------------
diff --git a/depends/libyarn/test/unit/TestContainerManagement.cpp b/depends/libyarn/test/unit/TestContainerManagement.cpp
deleted file mode 100644
index ffc3219..0000000
--- a/depends/libyarn/test/unit/TestContainerManagement.cpp
+++ /dev/null
@@ -1,146 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-#include "gtest/gtest.h"
-#include "gmock/gmock.h"
-
-#include "libyarnclient/ContainerManagement.h"
-#include "MockContainerManagementProtocol.h"
-#include "TestContainerManagementStub.h"
-
-using std::map;
-using std::string;
-using std::list;
-using namespace libyarn;
-using namespace testing;
-using namespace Mock;
-
-class MockContainerManagementStub: public TestContainerManagementStub {
-public:
- MOCK_METHOD0(getContainerManagementProtocol, ContainerManagementProtocol * ());
-};
-
-TEST(TestContainerManagement,TestStartContainer){
- ContainerManagement client;
- MockContainerManagementStub stub;
- string nmHost("localhost");
- string nmPort("8032");
- string tokenService = "";
- Yarn::Config config;
- Yarn::Internal::SessionConfig sessionConfig(config);
- Yarn::Internal::UserInfo user = Yarn::Internal::UserInfo::LocalUser();
- Yarn::Internal::RpcAuth rpcAuth(user, Yarn::Internal::AuthMethod::SIMPLE);
- MockContainerManagementProtocol *protocol =new MockContainerManagementProtocol(nmHost,nmPort,tokenService,sessionConfig,rpcAuth);
-
- StringBytesMap map;
- string key("key");
- string value("value");
- map.setKey(key);
- map.setValue(value);
- list<StringBytesMap> maps;
- maps.push_back(map);
- ContainerId containerId;
- containerId.setId(501);
- list<ContainerId> containerIds;
- containerIds.push_back(containerId);
- ContainerExceptionMap exceptionMap;
- exceptionMap.setContainerId(containerId);
- SerializedException exception;
- string message("message");
- string trace("trace");
- string className("className");
- exception.setMessage(message);
- exception.setTrace(trace);
- exception.setClassName(className);
- SerializedException cause;
- string message2("message2");
- cause.setMessage(message2);
- exception.setCause(cause);
- exceptionMap.setSerializedException(exception);
- list<ContainerExceptionMap> exceptionMaps;
- exceptionMaps.push_back(exceptionMap);
- StartContainersResponse response;
- response.setServicesMetaData(maps);
- response.setSucceededRequests(containerIds);
- response.setFailedRequests(exceptionMaps);
- EXPECT_CALL(*protocol, startContainers(_)).Times(AnyNumber()).WillOnce(Return(response));
- client.stub = &stub;
- EXPECT_CALL(stub, getContainerManagementProtocol()).Times(AnyNumber()).WillOnce(Return(protocol));
-
- Container container;
- StartContainerRequest request;
- libyarn::Token nmToken;
- StartContainerResponse ret = client.startContainer(container,request,nmToken);
- list<StringBytesMap>::iterator itMap = ret.getServicesMetaData().begin();
- //EXPECT_EQ(itMap->getKey(), "key");
- //EXPECT_EQ(itMap->getValue(), "value");
-}
-
-TEST(TestContainerManagement,TestStopContainer){
- ContainerManagement client;
- MockContainerManagementStub stub;
- string nmHost("localhost");
- string nmPort("8032");
- string tokenService = "";
- Yarn::Config config;
- Yarn::Internal::SessionConfig sessionConfig(config);
- Yarn::Internal::UserInfo user = Yarn::Internal::UserInfo::LocalUser();
- Yarn::Internal::RpcAuth rpcAuth(user, Yarn::Internal::AuthMethod::SIMPLE);
- MockContainerManagementProtocol *protocol =new MockContainerManagementProtocol(nmHost,nmPort,tokenService,sessionConfig,rpcAuth);
-
- StopContainersResponseProto stopResponseProto;
- EXPECT_CALL(*protocol, stopContainers(_)).Times(AnyNumber()).WillOnce(Return(StopContainersResponse(stopResponseProto)));
- client.stub = &stub;
- EXPECT_CALL(stub, getContainerManagementProtocol()).Times(AnyNumber()).WillOnce(Return(protocol));
-
- Container container;
- libyarn::Token nmToken;
- client.stopContainer(container,nmToken);
-}
-
-TEST(TestContainerManagement,TestGetContainerStatus){
- ContainerManagement client;
- MockContainerManagementStub stub;
- string nmHost("localhost");
- string nmPort("8032");
- string tokenService = "";
- Yarn::Config config;
- Yarn::Internal::SessionConfig sessionConfig(config);
- Yarn::Internal::UserInfo user = Yarn::Internal::UserInfo::LocalUser();
- Yarn::Internal::RpcAuth rpcAuth(user, Yarn::Internal::AuthMethod::SIMPLE);
- MockContainerManagementProtocol *protocol =new MockContainerManagementProtocol(nmHost,nmPort,tokenService,sessionConfig,rpcAuth);
-
- GetContainerStatusesResponse getResponse;
- ContainerId containerId;
- containerId.setId(501);
- ContainerStatus status;
- status.setContainerId(containerId);
- list<ContainerStatus> statuses;
- statuses.push_back(status);
- getResponse.setContainerStatuses(statuses);
- EXPECT_CALL(*protocol, getContainerStatuses(_)).Times(AnyNumber()).WillOnce(Return(getResponse));
- client.stub = &stub;
- EXPECT_CALL(stub, getContainerManagementProtocol()).Times(AnyNumber()).WillOnce(Return(protocol));
-
- Container container;
- libyarn::Token nmToken;
- ContainerStatus retStatus = client.getContainerStatus(container,nmToken);
- EXPECT_EQ(status.getContainerId().getId(), 501);
-}
-
http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/383818c2/depends/libyarn/test/unit/TestLibYarnClient.cpp
----------------------------------------------------------------------
diff --git a/depends/libyarn/test/unit/TestLibYarnClient.cpp b/depends/libyarn/test/unit/TestLibYarnClient.cpp
deleted file mode 100644
index f922b5b..0000000
--- a/depends/libyarn/test/unit/TestLibYarnClient.cpp
+++ /dev/null
@@ -1,651 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-#include "gtest/gtest.h"
-#include "gmock/gmock.h"
-//#include "Thread.h"
-
-#include "libyarnclient/LibYarnClient.h"
-#include "MockApplicationMaster.h"
-#include "MockApplicationClient.h"
-#include "MockContainerManagement.h"
-#include "TestLibYarnClientStub.h"
-
-using std::string;
-using std::list;
-using std::set;
-using namespace libyarn;
-using namespace testing;
-using namespace Mock;
-
-class MockLibYarnClientStub: public TestLibYarnClientStub {
-public:
- ~MockLibYarnClientStub(){
- }
- MOCK_METHOD0(getApplicationClient, ApplicationClient* ());
- MOCK_METHOD0(getApplicationMaster, ApplicationMaster* ());
- MOCK_METHOD0(getContainerManagement, ContainerManagement* ());
-};
-
-class TestLibYarnClient: public ::testing::Test {
-public:
- TestLibYarnClient(){
- amUser = "postgres";
- rmHost = "localhost";
- rmPort = "8032";
- schedHost = "localhost";
- schedPort = "8030";
- amHost = "localhost";
- amPort = 0;
- am_tracking_url = "url";
- heartbeatInterval = 1000;
- tokenService = "";
- user = Yarn::Internal::UserInfo::LocalUser();
- }
- ~TestLibYarnClient(){
- }
-protected:
- string amUser;
- string rmHost;
- string rmPort;
- string schedHost;
- string schedPort;
- string amHost;
- int32_t amPort;
- string am_tracking_url;
- int heartbeatInterval;
- string tokenService;
- Yarn::Internal::UserInfo user;
-};
-
-static ResourceRequest BuildRequest(int requestContainer) {
- ResourceRequest resRequest;
- string host("*");
- resRequest.setResourceName(host);
- Resource capability;
- capability.setVirtualCores(1);
- capability.setMemory(1024);
- resRequest.setCapability(capability);
- resRequest.setNumContainers(requestContainer);
- resRequest.setRelaxLocality(true);
- Priority priority;
- priority.setPriority(1);
- resRequest.setPriority(priority);
- return resRequest;
-}
-
-static list<ContainerReport> BuildContainerReportList(int containerSize){
- list<ContainerReport> containerReports;
- for (int i = 0; i < containerSize; i++) {
- ContainerReport report;
- containerReports.push_back(report);
- }
- return containerReports;
-}
-static AllocateResponse BuildAllocateResponse(int containerNumber){
- AllocateResponse allocateResponse;
- allocateResponse.setResponseId(10);
- list<Container> containers;
- for (int i=0;i<containerNumber;i++){
- Container container;
- ContainerId containerId;
- containerId.setId(i+1);
- container.setId(containerId);
- containers.push_back(container);
- }
- list<NMToken> nmTokens;
- for (int i=0;i<containerNumber;i++){
- NMToken token;
- nmTokens.push_back(token);
- }
- allocateResponse.setAllocatedContainers(containers);
- allocateResponse.setNMTokens(nmTokens);
- return allocateResponse;
-}
-
-static ApplicationReport BuildApplicationReport(string passwordStr,YarnApplicationState state){
- ApplicationReport applicationReport;
- libyarn::Token token;
- string password(passwordStr);
- token.setPassword(password);
- applicationReport.setAMRMToken(token);
- applicationReport.setYarnApplicationState(state);
- return applicationReport;
-}
-
-static ApplicationID BuildApplicationID(int id){
- ApplicationID appId;
- appId.setId(id);
- return appId;
-}
-
-static RegisterApplicationMasterResponse BuildRegisterResponse(){
- RegisterApplicationMasterResponseProto responseProto;
- return RegisterApplicationMasterResponse(responseProto);
-}
-
-static StartContainerResponse BuildStartContainerResponse(){
- StartContainerResponseProto responseProto;
- return StartContainerResponse(responseProto);
-}
-
-static ContainerStatus BuildContainerStatus(int id){
- ContainerId containerId;
- containerId.setId(id);
- ContainerStatus containerStatus;
- containerStatus.setContainerId(containerId);
- return containerStatus;
-}
-
-static QueueInfo BuildQueueinfo(string queue,float capcity,int childNum){
- QueueInfo queueInfo;
- queueInfo.setQueueName(queue);
- queueInfo.setCurrentCapacity(capcity);
-
- list<QueueInfo> childQueues;
- for (int i=0;i<childNum;i++){
- QueueInfo childQueue;
- string childName("child");
- childQueue.setQueueName(childName);
- childQueue.setCurrentCapacity(capcity);
- childQueues.push_back(childQueue);
- }
- queueInfo.setChildQueues(childQueues);
- return queueInfo;
-
-}
-
-TEST_F(TestLibYarnClient,TestCreateJob){
- MockApplicationClient *appclient = new MockApplicationClient(amUser,rmHost,rmHost);
- MockApplicationMaster *amrmclient = new MockApplicationMaster(schedHost,schedPort,user,tokenService);
- MockContainerManagement *nmclient = new MockContainerManagement();
- MockLibYarnClientStub stub;
-
- EXPECT_CALL(*appclient, getNewApplication()).Times(AnyNumber()).WillOnce(Return(BuildApplicationID(1)));
- EXPECT_CALL((*appclient),submitApplication(_)).Times(AnyNumber()).WillOnce(Return());
- EXPECT_CALL((*appclient),getApplicationReport(_)).Times(AtLeast(3))
- .WillOnce(Return(BuildApplicationReport("",YarnApplicationState::FAILED)))
- .WillOnce(Return(BuildApplicationReport("",YarnApplicationState::ACCEPTED)))
- .WillRepeatedly(Return(BuildApplicationReport("pass",YarnApplicationState::ACCEPTED)));
-
- EXPECT_CALL((*amrmclient),registerApplicationMaster(_,_,_)).Times(AnyNumber()).WillRepeatedly(Return(BuildRegisterResponse()));
- EXPECT_CALL((*amrmclient),allocate(_,_,_,_,_)).Times(AnyNumber()).WillRepeatedly(Return(BuildAllocateResponse(0)));
-
- EXPECT_CALL(stub, getApplicationClient()).Times(AnyNumber()).WillOnce(Return(appclient));
- EXPECT_CALL(stub, getApplicationMaster()).Times(AnyNumber()).WillOnce(Return(amrmclient));
- EXPECT_CALL(stub, getContainerManagement()).Times(AnyNumber()).WillOnce(Return(nmclient));
-
- LibYarnClient client(amUser, rmHost, rmPort, schedHost, schedPort, amHost, amPort, am_tracking_url,heartbeatInterval, &stub);
- string jobName("libyarn");
- string queue("default");
- string jobId("");
- int result = client.createJob(jobName,queue,jobId);
- EXPECT_EQ(result, 0);
-}
-
-TEST_F(TestLibYarnClient,TestCreateJobException){
- MockApplicationClient *appclient = new MockApplicationClient(amUser, rmHost,rmHost);
- MockApplicationMaster *amrmclient = new MockApplicationMaster(schedHost,schedPort,user,tokenService);
- MockContainerManagement *nmclient = new MockContainerManagement();
- MockLibYarnClientStub stub;
-
- EXPECT_CALL(*appclient, getNewApplication()).Times(AnyNumber()).WillOnce(Return(BuildApplicationID(1)));
- EXPECT_CALL((*appclient),submitApplication(_)).Times(AnyNumber())
- .WillOnce(Throw(std::invalid_argument("Exist an application for the client")));
-
- EXPECT_CALL(stub, getApplicationClient()).Times(AnyNumber()).WillOnce(Return(appclient));
- EXPECT_CALL(stub, getApplicationMaster()).Times(AnyNumber()).WillOnce(Return(amrmclient));
- EXPECT_CALL(stub, getContainerManagement()).Times(AnyNumber()).WillOnce(Return(nmclient));
-
- LibYarnClient client(amUser, rmHost, rmPort, schedHost, schedPort, amHost, amPort, am_tracking_url,heartbeatInterval,&stub);
- string jobName("libyarn");
- string queue("default");
- string jobId("");
- int result = client.createJob(jobName,queue,jobId);
- EXPECT_EQ(result, 1);
-}
-
-TEST_F(TestLibYarnClient,TestCreateJobInvalidId){
- MockApplicationClient *appclient = new MockApplicationClient(amUser,rmHost,rmHost);
- MockApplicationMaster *amrmclient = new MockApplicationMaster(schedHost,schedPort,user,tokenService);
- MockContainerManagement *nmclient = new MockContainerManagement();
- MockLibYarnClientStub stub;
-
- EXPECT_CALL(stub, getApplicationClient()).Times(AnyNumber()).WillOnce(Return(appclient));
- EXPECT_CALL(stub, getApplicationMaster()).Times(AnyNumber()).WillOnce(Return(amrmclient));
- EXPECT_CALL(stub, getContainerManagement()).Times(AnyNumber()).WillOnce(Return(nmclient));
-
- LibYarnClient client(amUser, rmHost, rmPort, schedHost, schedPort, amHost, amPort, am_tracking_url,heartbeatInterval,&stub);
- string jobName("libyarn");
- string queue("default");
- string jobId("test");
- int result = client.createJob(jobName,queue,jobId);
- EXPECT_EQ(result,1);
-}
-
-TEST_F(TestLibYarnClient,TestAddResourceRequest){
- MockLibYarnClientStub stub;
- LibYarnClient client(amUser, rmHost, rmPort, schedHost, schedPort, amHost,
- amPort, am_tracking_url, heartbeatInterval, &stub);
-
- Resource resource;
- resource.setMemory(1024);
- resource.setVirtualCores(1);
- string host("master");
- client.addResourceRequest(resource, 10, host, 1, true);
- list<ResourceRequest> request = client.getAskRequests();
- EXPECT_EQ(request.size(), 1);
- list<ResourceRequest>::iterator it = request.begin();
- EXPECT_EQ(it->getPriority().getPriority(), 1);
- EXPECT_EQ(it->getNumContainers(), 10);
- EXPECT_EQ(it->getRelaxLocality(), true);
- EXPECT_EQ(it->getResourceName(), host);
-}
-
-TEST_F(TestLibYarnClient,TestaddContainerRequests) {
- MockLibYarnClientStub stub;
- LibYarnClient client(amUser, rmHost, rmPort, schedHost, schedPort, amHost,
- amPort, am_tracking_url, heartbeatInterval, &stub);
- string jobId("");
- Resource resource;
- resource.setMemory(1024);
- resource.setVirtualCores(1);
- list<struct LibYarnNodeInfo> preferred;
- int ret = client.addContainerRequests(jobId, resource, 8, preferred, 1, true);
- EXPECT_EQ(ret, 0);
- list<ResourceRequest> request = client.getAskRequests();
- list<ResourceRequest>::iterator it = request.begin();
- EXPECT_EQ(it->getPriority().getPriority(), 1);
- EXPECT_EQ(it->getNumContainers(), 8);
- EXPECT_EQ(it->getRelaxLocality(), true);
- EXPECT_EQ(it->getResourceName(), "*");
- client.clearAskRequests();
- EXPECT_EQ(client.getAskRequests().size(), 0);
-
- /* test preferred hosts */
- LibYarnNodeInfo info1("node1", NULL, 3);
- LibYarnNodeInfo info2("node2", NULL, 2);
- preferred.push_back(info1);
- preferred.push_back(info2);
- ret = client.addContainerRequests(jobId, resource, 8, preferred, 1, false);
- request = client.getAskRequests();
- for (it = request.begin(); it != request.end(); ++it) {
- if (it->getResourceName() == info1.getHost()) {
- EXPECT_EQ(it->getNumContainers(), 3);
- EXPECT_EQ(it->getRelaxLocality(), true);
- } else if (it->getResourceName() == info2.getHost()) {
- EXPECT_EQ(it->getNumContainers(), 2);
- EXPECT_EQ(it->getRelaxLocality(), true);
- } else if (it->getResourceName() == string("/default-rack")) {
- EXPECT_EQ(it->getNumContainers(), 5);
- EXPECT_EQ(it->getRelaxLocality(), false);
- } else if (it->getResourceName() == string("*")) {
- EXPECT_EQ(it->getNumContainers(), 8);
- EXPECT_EQ(it->getRelaxLocality(), false);
- } else {
- ASSERT_TRUE(false);
- }
- EXPECT_EQ(it->getCapability().getMemory(), 1024);
- EXPECT_EQ(it->getCapability().getVirtualCores(), 1);
- }
-}
-
-TEST_F(TestLibYarnClient,TestAllocateResources){
- MockApplicationClient *appclient = new MockApplicationClient(amUser,rmHost,rmHost);
- MockApplicationMaster *amrmclient = new MockApplicationMaster(schedHost,schedPort,user,tokenService);
- MockContainerManagement *nmclient = new MockContainerManagement();
- MockLibYarnClientStub stub;
-
- EXPECT_CALL((*amrmclient),allocate(_,_,_,_,_)).Times(AnyNumber()).WillRepeatedly(Return(BuildAllocateResponse(5)));
- EXPECT_CALL((*appclient),getContainers(_)).Times(AnyNumber())
- .WillRepeatedly(Return(BuildContainerReportList(0)));
-
- EXPECT_CALL(stub, getApplicationClient()).Times(AnyNumber()).WillOnce(Return(appclient));
- EXPECT_CALL(stub, getApplicationMaster()).Times(AnyNumber()).WillOnce(Return(amrmclient));
- EXPECT_CALL(stub, getContainerManagement()).Times(AnyNumber()).WillOnce(Return(nmclient));
-
- LibYarnClient client(amUser, rmHost, rmPort, schedHost, schedPort, amHost, amPort, am_tracking_url,heartbeatInterval,&stub);
-
- string jobId("");
- list<string> blackListAdditions;
- list<string> blackListRemovals;
- ResourceRequest resRequest;
- list<Container> allocatedResourcesArray;
- int result;
-
- result = client.allocateResources(jobId, blackListAdditions, blackListRemovals,allocatedResourcesArray,5);
- EXPECT_EQ(allocatedResourcesArray.size(), 5);
- EXPECT_EQ(result,0);
-}
-
-TEST_F(TestLibYarnClient,TestAllocateResourcesRetry){
- MockApplicationClient *appclient = new MockApplicationClient(amUser, rmHost,rmHost);
- MockApplicationMaster *amrmclient = new MockApplicationMaster(schedHost,schedPort,user,tokenService);
- MockContainerManagement *nmclient = new MockContainerManagement();
- MockLibYarnClientStub stub;
-
- EXPECT_CALL((*appclient),getContainers(_)).Times(AnyNumber())
- .WillRepeatedly(Return(BuildContainerReportList(0)));
- EXPECT_CALL((*amrmclient),allocate(_,_,_,_,_)).Times(AnyNumber())
- .WillOnce(Return(BuildAllocateResponse(5)))
- .WillOnce(Return(BuildAllocateResponse(5)))
- .WillRepeatedly(Return(BuildAllocateResponse(0)));
-
- EXPECT_CALL(stub, getApplicationClient()).Times(AnyNumber()).WillOnce(Return(appclient));
- EXPECT_CALL(stub, getApplicationMaster()).Times(AnyNumber()).WillOnce(Return(amrmclient));
- EXPECT_CALL(stub, getContainerManagement()).Times(AnyNumber()).WillOnce(Return(nmclient));
-
- LibYarnClient client(amUser,rmHost, rmPort, schedHost, schedPort, amHost, amPort, am_tracking_url,heartbeatInterval,&stub);
-
- string jobId("");
- list<string> blackListAdditions;
- list<string> blackListRemovals;
- ResourceRequest resRequest;
- list<Container> allocatedResourcesArray;
- int result;
- resRequest = BuildRequest(11);
- result = client.allocateResources(jobId, blackListAdditions, blackListRemovals, allocatedResourcesArray, 2);
- EXPECT_EQ(result,0);
-}
-
-TEST_F(TestLibYarnClient,TestActiveResources){
- MockApplicationClient *appclient = new MockApplicationClient(amUser,rmHost,rmHost);
- MockApplicationMaster *amrmclient = new MockApplicationMaster(schedHost,schedPort,user,tokenService);
- MockContainerManagement *nmclient = new MockContainerManagement();
- MockLibYarnClientStub stub;
-
- EXPECT_CALL(stub, getApplicationClient()).Times(AnyNumber()).WillOnce(Return(appclient));
- EXPECT_CALL(stub, getApplicationMaster()).Times(AnyNumber()).WillOnce(Return(amrmclient));
- EXPECT_CALL(stub, getContainerManagement()).Times(AnyNumber()).WillOnce(Return(nmclient));
-
- LibYarnClient client(amUser,rmHost, rmPort, schedHost, schedPort, amHost, amPort, am_tracking_url,heartbeatInterval,&stub);
-
- string jobId("");
- int activeContainerSize = 3;
- int64_t activeContainerIds[activeContainerSize];
- for (int i = 0;i < activeContainerSize;i++){
- activeContainerIds[i] = i;
- }
- int result = client.activeResources(jobId,activeContainerIds,activeContainerSize);
- EXPECT_EQ(result,0);
-}
-
-
-TEST_F(TestLibYarnClient,TestReleaseResources){
- MockApplicationClient *appclient = new MockApplicationClient(amUser,rmHost,rmHost);
- MockApplicationMaster *amrmclient = new MockApplicationMaster(schedHost,schedPort,user,tokenService);
- MockContainerManagement *nmclient = new MockContainerManagement();
- MockLibYarnClientStub stub;
-
- EXPECT_CALL((*amrmclient),allocate(_,_,_,_,_)).Times(AnyNumber()).WillRepeatedly(Return(BuildAllocateResponse(5)));
-
- EXPECT_CALL(stub, getApplicationClient()).Times(AnyNumber()).WillOnce(Return(appclient));
- EXPECT_CALL(stub, getApplicationMaster()).Times(AnyNumber()).WillOnce(Return(amrmclient));
- EXPECT_CALL(stub, getContainerManagement()).Times(AnyNumber()).WillOnce(Return(nmclient));
-
- LibYarnClient client(amUser, rmHost, rmPort, schedHost, schedPort, amHost, amPort, am_tracking_url,heartbeatInterval,&stub);
-
- string jobId("");
- int releaseContainerSize = 3;
- int64_t releaseContainerIds[releaseContainerSize];
- for (int i = 0;i < releaseContainerSize;i++){
- releaseContainerIds[i] = i;
- }
- int result = client.releaseResources(jobId,releaseContainerIds,releaseContainerSize);
- EXPECT_EQ(result,0);
-}
-
-TEST_F(TestLibYarnClient,TestFinishJob){
- MockApplicationClient *appclient = new MockApplicationClient(amUser,rmHost,rmHost);
- MockApplicationMaster *amrmclient = new MockApplicationMaster(schedHost,schedPort,user,tokenService);
- MockContainerManagement *nmclient = new MockContainerManagement();
- MockLibYarnClientStub stub;
-
- EXPECT_CALL((*amrmclient),finishApplicationMaster(_,_,_)).Times(AnyNumber()).WillRepeatedly(Return(true));
-
- EXPECT_CALL(stub, getApplicationClient()).Times(AnyNumber()).WillOnce(Return(appclient));
- EXPECT_CALL(stub, getApplicationMaster()).Times(AnyNumber()).WillOnce(Return(amrmclient));
- EXPECT_CALL(stub, getContainerManagement()).Times(AnyNumber()).WillOnce(Return(nmclient));
- LibYarnClient client(amUser, rmHost, rmPort, schedHost, schedPort, amHost, amPort, am_tracking_url,heartbeatInterval,&stub);
-
- string jobId("");
- int result = client.finishJob(jobId,FinalApplicationStatus::APP_SUCCEEDED);
- EXPECT_EQ(result,0);
-}
-
-TEST_F(TestLibYarnClient,TestGetApplicationReport){
- MockApplicationClient *appclient = new MockApplicationClient(amUser,rmHost,rmHost);
- MockApplicationMaster *amrmclient = new MockApplicationMaster(schedHost,schedPort,user,tokenService);
- MockContainerManagement *nmclient = new MockContainerManagement();
- MockLibYarnClientStub stub;
-
- EXPECT_CALL((*appclient),getApplicationReport(_)).Times(AnyNumber())
- .WillRepeatedly(Return(BuildApplicationReport("pass",YarnApplicationState::ACCEPTED)));
-
- EXPECT_CALL(stub, getApplicationClient()).Times(AnyNumber()).WillOnce(Return(appclient));
- EXPECT_CALL(stub, getApplicationMaster()).Times(AnyNumber()).WillOnce(Return(amrmclient));
- EXPECT_CALL(stub, getContainerManagement()).Times(AnyNumber()).WillOnce(Return(nmclient));
- LibYarnClient client(amUser, rmHost, rmPort, schedHost, schedPort, amHost, amPort, am_tracking_url,heartbeatInterval,&stub);
-
- string jobId("");
- ApplicationReport applicationReport;
- int result = client.getApplicationReport(jobId,applicationReport);
- EXPECT_EQ(result,0);
-}
-
-TEST_F(TestLibYarnClient,TestGetContainerReports){
- MockApplicationClient *appclient = new MockApplicationClient(amUser,rmHost,rmHost);
- MockApplicationMaster *amrmclient = new MockApplicationMaster(schedHost,schedPort,user,tokenService);
- MockContainerManagement *nmclient = new MockContainerManagement();
- MockLibYarnClientStub stub;
-
- int containerSize = 3;
- EXPECT_CALL((*appclient),getContainers(_)).Times(AnyNumber())
- .WillRepeatedly(Return(BuildContainerReportList(containerSize)));
-
- EXPECT_CALL(stub, getApplicationClient()).Times(AnyNumber()).WillOnce(Return(appclient));
- EXPECT_CALL(stub, getApplicationMaster()).Times(AnyNumber()).WillOnce(Return(amrmclient));
- EXPECT_CALL(stub, getContainerManagement()).Times(AnyNumber()).WillOnce(Return(nmclient));
- LibYarnClient client(amUser, rmHost, rmPort, schedHost, schedPort, amHost, amPort, am_tracking_url,heartbeatInterval,&stub);
-
- string jobId("");
- list<ContainerReport> reports;
- int result = client.getContainerReports(jobId,reports);
- EXPECT_EQ(result,0);
- EXPECT_EQ(int(reports.size()),containerSize);
-}
-
-TEST_F(TestLibYarnClient,TestGetContainerStatuses){
- MockApplicationClient *appclient = new MockApplicationClient(amUser,rmHost,rmHost);
- MockApplicationMaster *amrmclient = new MockApplicationMaster(schedHost,schedPort,user,tokenService);
- MockContainerManagement *nmclient = new MockContainerManagement();
- MockLibYarnClientStub stub;
-
- EXPECT_CALL(stub, getApplicationClient()).Times(AnyNumber()).WillOnce(Return(appclient));
- EXPECT_CALL(stub, getApplicationMaster()).Times(AnyNumber()).WillOnce(Return(amrmclient));
- EXPECT_CALL(stub, getContainerManagement()).Times(AnyNumber()).WillOnce(Return(nmclient));
- LibYarnClient client(amUser, rmHost, rmPort, schedHost, schedPort, amHost, amPort, am_tracking_url,heartbeatInterval,&stub);
-
- string jobId("");
- list<ContainerStatus> containerStatues;
- int containerSize = 3;
- int64_t containerIds[containerSize];
- for (int i = 0;i < containerSize;i++){
- containerIds[i] = i;
- }
- int result = client.getContainerStatuses(jobId,containerIds,containerSize,containerStatues);
- EXPECT_EQ(result,0);
- EXPECT_EQ(int(containerStatues.size()),0);
-}
-
-TEST_F(TestLibYarnClient,TestGetQueueInfo){
- MockApplicationClient *appclient = new MockApplicationClient(amUser,rmHost,rmHost);
- MockApplicationMaster *amrmclient = new MockApplicationMaster(schedHost,schedPort,user,tokenService);
- MockContainerManagement *nmclient = new MockContainerManagement();
- MockLibYarnClientStub stub;
-
- string queue("test");
- int childNum = 2;
- float capcity = 0.5;
- QueueInfo queueInfo = BuildQueueinfo(queue,capcity,childNum);
- EXPECT_CALL((*appclient),getQueueInfo(_,_,_,_)).Times(AnyNumber())
- .WillRepeatedly(Return(queueInfo));
-
- EXPECT_CALL(stub, getApplicationClient()).Times(AnyNumber()).WillOnce(Return(appclient));
- EXPECT_CALL(stub, getApplicationMaster()).Times(AnyNumber()).WillOnce(Return(amrmclient));
- EXPECT_CALL(stub, getContainerManagement()).Times(AnyNumber()).WillOnce(Return(nmclient));
- LibYarnClient client(amUser, rmHost, rmPort, schedHost, schedPort, amHost, amPort, am_tracking_url,heartbeatInterval,&stub);
-
-
- QueueInfo resultQueue;
- int result = client.getQueueInfo(queue,true,true,true,resultQueue);
- EXPECT_EQ(result,0);
- EXPECT_EQ(resultQueue.getCurrentCapacity(),capcity);
- EXPECT_STREQ(resultQueue.getQueueName().c_str(),queue.c_str());
- EXPECT_EQ(int(resultQueue.getChildQueues().size()),childNum);
-}
-
-TEST_F(TestLibYarnClient,TestGetClusterNodes){
- MockApplicationClient *appclient = new MockApplicationClient(amUser,rmHost,rmHost);
- MockApplicationMaster *amrmclient = new MockApplicationMaster(schedHost,schedPort,user,tokenService);
- MockContainerManagement *nmclient = new MockContainerManagement();
- MockLibYarnClientStub stub;
-
- list<NodeReport> nodeReports;
- int nodeSize = 3;
- for (int i=0;i<nodeSize;i++){
- NodeReport report;
- nodeReports.push_back(report);
- }
- EXPECT_CALL((*appclient),getClusterNodes(_)).Times(AnyNumber())
- .WillRepeatedly(Return(nodeReports));
-
- EXPECT_CALL(stub, getApplicationClient()).Times(AnyNumber()).WillOnce(Return(appclient));
- EXPECT_CALL(stub, getApplicationMaster()).Times(AnyNumber()).WillOnce(Return(amrmclient));
- EXPECT_CALL(stub, getContainerManagement()).Times(AnyNumber()).WillOnce(Return(nmclient));
- LibYarnClient client(amUser, rmHost, rmPort, schedHost, schedPort, amHost, amPort, am_tracking_url,heartbeatInterval,&stub);
-
- list<NodeState> states;
- list<NodeReport> nodeResult;
- int result = client.getClusterNodes(states,nodeResult);
- EXPECT_EQ(result,0);
- EXPECT_EQ(int(nodeResult.size()),nodeSize);
-}
-
-TEST_F(TestLibYarnClient,TestGetErrorMessage){
- LibYarnClient client(amUser, rmHost, rmPort, schedHost, schedPort, amHost, amPort, am_tracking_url,heartbeatInterval);
- EXPECT_STREQ("",client.getErrorMessage().c_str());
- client.setErrorMessage("error!");
- EXPECT_STREQ("error!",client.getErrorMessage().c_str());
-}
-
-TEST_F(TestLibYarnClient,TestGetActiveFailContainerIds){
- LibYarnClient client(amUser, rmHost, rmPort, schedHost, schedPort, amHost, amPort, am_tracking_url,heartbeatInterval);
- set<int64_t> activeFailIds;
- client.getActiveFailContainerIds(activeFailIds);
- EXPECT_EQ(int(activeFailIds.size()),0);
-}
-
-TEST_F(TestLibYarnClient,TestLibYarn){
- MockApplicationClient *appclient = new MockApplicationClient(amUser,rmHost,rmHost);
- MockApplicationMaster *amrmclient = new MockApplicationMaster(schedHost,schedPort,user,tokenService);
- MockContainerManagement *nmclient = new MockContainerManagement();
- MockLibYarnClientStub stub;
-
- EXPECT_CALL(*appclient, getNewApplication()).Times(AnyNumber()).WillOnce(Return(BuildApplicationID(1)));
- EXPECT_CALL((*appclient),submitApplication(_)).Times(AnyNumber()).WillOnce(Return());
- EXPECT_CALL((*appclient),getApplicationReport(_)).Times(AtLeast(3))
- .WillOnce(Return(BuildApplicationReport("",YarnApplicationState::FAILED)))
- .WillOnce(Return(BuildApplicationReport("",YarnApplicationState::ACCEPTED)))
- .WillRepeatedly(Return(BuildApplicationReport("pass",YarnApplicationState::ACCEPTED)));
- EXPECT_CALL((*appclient),getContainers(_)).Times(AnyNumber())
- .WillRepeatedly(Return(BuildContainerReportList(0)));
-
- EXPECT_CALL((*amrmclient),registerApplicationMaster(_,_,_)).Times(AnyNumber()).WillRepeatedly(Return(BuildRegisterResponse()));
- EXPECT_CALL((*amrmclient),allocate(_,_,_,_,_)).Times(AnyNumber()).WillRepeatedly(Return(BuildAllocateResponse(5)));
- EXPECT_CALL((*amrmclient),finishApplicationMaster(_,_,_)).Times(AnyNumber()).WillRepeatedly(Return(true));
-
- EXPECT_CALL((*nmclient),startContainer(_,_,_)).Times(AnyNumber())
- .WillOnce(Throw(std::invalid_argument("startContainer Exception")))
- .WillRepeatedly(Return(BuildStartContainerResponse()));
- EXPECT_CALL((*nmclient),getContainerStatus(_,_)).Times(AnyNumber())
- .WillOnce(Return(BuildContainerStatus(2)))
- .WillOnce(Return(BuildContainerStatus(3)))
- .WillRepeatedly(Return(BuildContainerStatus(0)));
- EXPECT_CALL((*nmclient),stopContainer(_,_)).Times(AnyNumber())
- .WillRepeatedly(Return());
-
- EXPECT_CALL(stub, getApplicationClient()).Times(AnyNumber()).WillOnce(Return(appclient));
- EXPECT_CALL(stub, getApplicationMaster()).Times(AnyNumber()).WillOnce(Return(amrmclient));
- EXPECT_CALL(stub, getContainerManagement()).Times(AnyNumber()).WillOnce(Return(nmclient));
-
- LibYarnClient client(amUser,rmHost, rmPort, schedHost, schedPort, amHost, amPort, am_tracking_url,heartbeatInterval,&stub);
- string jobName("libyarn");
- string queue("default");
- string jobId("");
- int result = client.createJob(jobName,queue,jobId);
- EXPECT_EQ(result,0);
-
- list<string> blackListAdditions;
- list<string> blackListRemovals;
- ResourceRequest resRequest;
- list<Container> allocatedResourcesArray;
-
- resRequest = BuildRequest(3);
- result = client.allocateResources(jobId, blackListAdditions, blackListRemovals,allocatedResourcesArray,5);
- EXPECT_EQ(result,0);
-
- int allocatedResourceArraySize = allocatedResourcesArray.size();
- int64_t activeContainerIds[allocatedResourceArraySize];
- int64_t releaseContainerIds[allocatedResourceArraySize];
- int64_t statusContainerIds[allocatedResourceArraySize];
- int i = 0;
- for (list<Container>::iterator it = allocatedResourcesArray.begin();it != allocatedResourcesArray.end();it++){
- activeContainerIds[i] = it->getId().getId();
- if (i != 1){
- releaseContainerIds[i] = it->getId().getId();
- }
- statusContainerIds[i] = it->getId().getId();
- i++;
- }
- result = client.activeResources(jobId, activeContainerIds,allocatedResourceArraySize);
- EXPECT_EQ(result,0);
-
- set<int64_t> activeFailIds;
- result = client.getActiveFailContainerIds(activeFailIds);
- EXPECT_EQ(result,0);
- EXPECT_EQ(int(activeFailIds.size()),1);
-
- ApplicationReport report;
- result = client.getApplicationReport(jobId,report);
- EXPECT_EQ(result,0);
-
- list<ContainerStatus> containerStatues;
- result = client.getContainerStatuses(jobId,statusContainerIds,allocatedResourceArraySize,containerStatues);
- EXPECT_EQ(result,0);
- //EXPECT_EQ(int(containerStatues.size()),2);
-
- result = client.releaseResources(jobId, releaseContainerIds,allocatedResourceArraySize);
- EXPECT_EQ(result,0);
-
-
- result = client.finishJob(jobId, FinalApplicationStatus::APP_SUCCEEDED);
- EXPECT_EQ(result,0);
-}
-
http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/383818c2/depends/libyarn/test/unit/TestLibYarnClient/TestApplicationClient.cpp
----------------------------------------------------------------------
diff --git a/depends/libyarn/test/unit/TestLibYarnClient/TestApplicationClient.cpp b/depends/libyarn/test/unit/TestLibYarnClient/TestApplicationClient.cpp
new file mode 100644
index 0000000..b02223c
--- /dev/null
+++ b/depends/libyarn/test/unit/TestLibYarnClient/TestApplicationClient.cpp
@@ -0,0 +1,277 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+#include <list>
+#include <string>
+
+#include "gtest/gtest.h"
+#include "gmock/gmock.h"
+
+#include "libyarnclient/ApplicationClient.h"
+#include "MockApplicationClientProtocol.h"
+
+using std::string;
+using std::list;
+using namespace libyarn;
+using namespace testing;
+using namespace Mock;
+
+class TestApplicationClient: public ::testing::Test {
+public:
+ TestApplicationClient(){
+ string user("postgres");
+ string rmHost("localhost");
+ string rmPort("8032");
+ string tokenService = "";
+ Yarn::Config config;
+ Yarn::Internal::SessionConfig sessionConfig(config);
+ MockApplicationClientProtocol *protocol = new MockApplicationClientProtocol(user,rmHost,rmPort,tokenService, sessionConfig);
+
+ ApplicationId appId;
+ appId.setId(100);
+ appId.setClusterTimestamp(1454307175682);
+ GetNewApplicationResponse getNewApplicationResponse;
+ getNewApplicationResponse.setApplicationId(appId);
+ EXPECT_CALL((*protocol),getNewApplication(_)).Times(AnyNumber()).WillOnce(Return(getNewApplicationResponse));
+ EXPECT_CALL((*protocol),submitApplication(_)).Times(AnyNumber()).WillOnce(Return());
+
+ ApplicationReport appReport;
+ appReport.setApplicationId(appId);
+ appReport.setUser(user);
+ string queue("default");
+ string appName("hawq");
+ string hostname("master");
+ appReport.setQueue(queue);
+ appReport.setName(appName);
+ appReport.setHost(hostname);
+ appReport.setRpcPort(8090);
+ appReport.setProgress(0.5);
+ GetApplicationReportResponse appReportResponse;
+ appReportResponse.setApplicationReport(appReport);
+ EXPECT_CALL((*protocol),getApplicationReport(_)).Times(AnyNumber()).WillOnce(Return(appReportResponse));
+
+ ContainerId containerId;
+ containerId.setId(501);
+ containerId.setApplicationId(appId);
+ Resource resource;
+ resource.setMemory(1024);
+ resource.setVirtualCores(1);
+ Priority priority;
+ priority.setPriority(1);
+ ContainerReport report;
+ report.setId(containerId);
+ report.setResource(resource);
+ report.setPriority(priority);
+ list<ContainerReport> reportList;
+ reportList.push_back(report);
+ GetContainersResponse getContainersResponse;
+ getContainersResponse.setContainersReportList(reportList);
+ EXPECT_CALL((*protocol),getContainers(_)).Times(AnyNumber()).WillOnce(Return(getContainersResponse));
+
+ NodeId nodeId;
+ string nodeHost("node1");
+ nodeId.setHost(nodeHost);
+ nodeId.setPort(9983);
+ NodeReport nodeReport;
+ nodeReport.setNodeId(nodeId);
+ string rackName("default-rack");
+ nodeReport.setRackName(rackName);
+ nodeReport.setNumContainers(8);
+ Resource nodeResource;
+ nodeResource.setMemory(2048*8);
+ nodeResource.setVirtualCores(8);
+ nodeReport.setResourceCapablity(nodeResource);
+ nodeReport.setNodeState(NodeState::NS_RUNNING);
+ list<NodeReport> nodeReportList;
+ nodeReportList.push_back(nodeReport);
+ GetClusterNodesResponse getClusterNodesResponse;
+ getClusterNodesResponse.setNodeReports(nodeReportList);
+ EXPECT_CALL((*protocol),getClusterNodes(_)).Times(AnyNumber()).WillOnce(Return(getClusterNodesResponse));
+
+ QueueInfo queueInfo;
+ queueInfo.setQueueName(queue);
+ queueInfo.setCapacity(0.67);
+ queueInfo.setMaximumCapacity(0.95);
+ queueInfo.setCurrentCapacity(0.5);
+ queueInfo.setQueueState(QueueState::Q_RUNNING);
+ QueueInfo childQueue;
+ string childQueueName("hawq-queue");
+ childQueue.setQueueName(childQueueName);
+ childQueue.setCapacity(0.33);
+ childQueue.setMaximumCapacity(0.5);
+ childQueue.setCurrentCapacity(0.25);
+ list<QueueInfo> childQueueList;
+ childQueueList.push_back(childQueue);
+ queueInfo.setChildQueues(childQueueList);
+ list<ApplicationReport> appReportList;
+ appReportList.push_back(appReport);
+ queueInfo.setApplicationReports(appReportList);
+ GetQueueInfoResponse getQueueInfoResponse;
+ getQueueInfoResponse.setQueueInfo(queueInfo);
+ EXPECT_CALL((*protocol),getQueueInfo(_)).Times(AnyNumber()).WillOnce(Return(getQueueInfoResponse));
+
+ KillApplicationResponseProto killApplicationResponseProto;
+ EXPECT_CALL((*protocol),forceKillApplication(_)).Times(AnyNumber()).WillOnce(Return(KillApplicationResponse(killApplicationResponseProto)));
+
+ YarnClusterMetrics metrics;
+ metrics.setNumNodeManagers(10);
+ GetClusterMetricsResponse clusterMetricsResponse;
+ clusterMetricsResponse.setClusterMetrics(metrics);
+ EXPECT_CALL((*protocol),getClusterMetrics(_)).Times(AnyNumber()).WillOnce(Return(clusterMetricsResponse));
+
+ GetApplicationsResponse applicationsResponse;
+ applicationsResponse.setApplicationList(appReportList);
+ EXPECT_CALL((*protocol),getApplications(_)).Times(AnyNumber()).WillOnce(Return(applicationsResponse));
+
+ QueueUserACLInfo aclInfo;
+ aclInfo.setQueueName(queue);
+ list<QueueACL> queueACLList;
+ QueueACL acl1 = QueueACL::QACL_ADMINISTER_QUEUE;
+ QueueACL acl2 = QueueACL::QACL_SUBMIT_APPLICATIONS;
+ queueACLList.push_back(acl1);
+ queueACLList.push_back(acl2);
+ aclInfo.setUserAcls(queueACLList);
+ list<QueueUserACLInfo> aclInfoList;
+ aclInfoList.push_back(aclInfo);
+ GetQueueUserAclsInfoResponse queueUserAclsInfoResponse;
+ queueUserAclsInfoResponse.setUserAclsInfoList(aclInfoList);
+ EXPECT_CALL((*protocol),getQueueAclsInfo(_)).Times(AnyNumber()).WillOnce(Return(queueUserAclsInfoResponse));
+
+ client = new ApplicationClient(protocol);
+ }
+
+ ~TestApplicationClient(){
+ delete client;
+ }
+
+protected:
+ ApplicationClient *client;
+};
+
+TEST_F(TestApplicationClient, TestGetNewApplication){
+ ApplicationId response = client->getNewApplication();
+ EXPECT_EQ(response.getId(), 100);
+ EXPECT_EQ(response.getClusterTimestamp(), 1454307175682);
+}
+
+TEST_F(TestApplicationClient,TestSubmitApplication){
+ ApplicationSubmissionContext appContext;
+ client->submitApplication(appContext);
+}
+
+TEST_F(TestApplicationClient,TestGetApplicationReport){
+ ApplicationId appId;
+ ApplicationReport report = client->getApplicationReport(appId);
+ EXPECT_EQ(report.getUser(), "postgres");
+ EXPECT_EQ(report.getQueue(), "default");
+ EXPECT_EQ(report.getName(), "hawq");
+ EXPECT_EQ(report.getHost(), "master");
+ EXPECT_EQ(report.getRpcPort(), 8090);
+ EXPECT_FLOAT_EQ(report.getProgress(), 0.5);
+}
+
+TEST_F(TestApplicationClient,TestGetContainers){
+ ApplicationAttemptId appAttempId;
+ list<ContainerReport> reports = client->getContainers(appAttempId);
+ EXPECT_EQ(reports.size(), 1);
+ list<ContainerReport>::iterator it = reports.begin();
+ EXPECT_EQ(it->getId().getId(), 501);
+ EXPECT_EQ(it->getPriority().getPriority(), 1);
+ EXPECT_EQ(it->getResource().getMemory(), 1024);
+ EXPECT_EQ(it->getResource().getVirtualCores(), 1);
+}
+
+TEST_F(TestApplicationClient,TestGetClusterNodes){
+ list<NodeState> states;
+ list<NodeReport> reports = client->getClusterNodes(states);
+ EXPECT_EQ(reports.size(), 1);
+ list<NodeReport>::iterator it = reports.begin();
+ EXPECT_EQ(it->getNodeId().getHost(), "node1");
+ EXPECT_EQ(it->getNodeId().getPort(), 9983);
+ EXPECT_EQ(it->getRackName(), "default-rack");
+ EXPECT_EQ(it->getResourceCapability().getMemory(), 2048*8);
+ EXPECT_EQ(it->getResourceCapability().getVirtualCores(), 8);
+ EXPECT_EQ(it->getNodeState(), NodeState::NS_RUNNING);
+ EXPECT_EQ(it->getNumContainers(), 8);
+}
+
+TEST_F(TestApplicationClient,TestGetQueueInfo){
+ string queue = "";
+ QueueInfo queueInfo = client->getQueueInfo(queue,true,true,true);
+ EXPECT_EQ(queueInfo.getQueueName(), "default");
+ EXPECT_FLOAT_EQ(queueInfo.getCapacity(), 0.67);
+ EXPECT_FLOAT_EQ(queueInfo.getMaximumCapacity(), 0.95);
+ EXPECT_FLOAT_EQ(queueInfo.getCurrentCapacity(), 0.5);
+ EXPECT_EQ(queueInfo.getQueueState(), QueueState::Q_RUNNING);
+ list<QueueInfo> child = queueInfo.getChildQueues();
+ EXPECT_EQ(child.size(), 1);
+ list<QueueInfo>::iterator it = child.begin();
+ EXPECT_EQ(it->getQueueName(), "hawq-queue");
+ EXPECT_FLOAT_EQ(it->getCapacity(), 0.33);
+ EXPECT_FLOAT_EQ(it->getMaximumCapacity(), 0.5);
+ EXPECT_FLOAT_EQ(it->getCurrentCapacity(), 0.25);
+ list<ApplicationReport> appReportList = queueInfo.getApplicationReports();
+ list<ApplicationReport>::iterator itAppReport = appReportList.begin();
+ EXPECT_EQ(itAppReport->getApplicationId().getId(), 100);
+ EXPECT_EQ(itAppReport->getUser(), "postgres");
+}
+
+TEST_F(TestApplicationClient,TestForceKillApplication){
+ ApplicationId appId;
+ client->forceKillApplication(appId);
+}
+
+TEST_F(TestApplicationClient,TestGetClusterMetrics){
+ YarnClusterMetrics response = client->getClusterMetrics();
+ EXPECT_EQ(response.getNumNodeManagers(), 10);
+}
+
+TEST_F(TestApplicationClient,TestGetApplications){
+ list<string> applicationTypes;
+ list<YarnApplicationState> applicationStates;
+ list<ApplicationReport> reports = client->getApplications(applicationTypes,applicationStates);
+ EXPECT_EQ(reports.size(), 1);
+ list<ApplicationReport>::iterator it = reports.begin();
+ EXPECT_EQ(it->getApplicationId().getId(), 100);
+ EXPECT_EQ(it->getUser(), "postgres");
+}
+
+TEST_F(TestApplicationClient,TestGetQueueAclsInfo){
+ list<QueueUserACLInfo> response = client->getQueueAclsInfo();
+ EXPECT_EQ(response.size(), 1);
+ list<QueueUserACLInfo>::iterator it = response.begin();
+ EXPECT_EQ(it->getQueueName(), "default");
+ list<QueueACL> queueACLs = it->getUserAcls();
+ EXPECT_EQ(queueACLs.size(), 2);
+ list<QueueACL>::iterator queueACL = queueACLs.begin();
+ EXPECT_EQ(*queueACL, QueueACL::QACL_ADMINISTER_QUEUE);
+ *queueACL++;
+ EXPECT_EQ(*queueACL, QueueACL::QACL_SUBMIT_APPLICATIONS);
+}
+
+TEST_F(TestApplicationClient, TestRMInfo){
+ string rmHost("localhost");
+ string rmPort("8032");
+
+ RMInfo rmInfo = RMInfo();
+ rmInfo.setHost(rmHost);
+ rmInfo.setPort(rmPort);
+ EXPECT_EQ(rmInfo.getHost(), rmHost);
+ EXPECT_EQ(rmInfo.getPort(), rmPort);
+}
http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/383818c2/depends/libyarn/test/unit/TestLibYarnClient/TestApplicationMaster.cpp
----------------------------------------------------------------------
diff --git a/depends/libyarn/test/unit/TestLibYarnClient/TestApplicationMaster.cpp b/depends/libyarn/test/unit/TestLibYarnClient/TestApplicationMaster.cpp
new file mode 100644
index 0000000..18969af
--- /dev/null
+++ b/depends/libyarn/test/unit/TestLibYarnClient/TestApplicationMaster.cpp
@@ -0,0 +1,196 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+#include <list>
+#include <string>
+
+#include "gtest/gtest.h"
+#include "gmock/gmock.h"
+
+#include "libyarnclient/ApplicationMaster.h"
+#include "MockApplicationMasterProtocol.h"
+
+using std::string;
+using std::list;
+using namespace libyarn;
+using namespace testing;
+using namespace Mock;
+
+class TestApplicationMaster: public ::testing::Test {
+public:
+ TestApplicationMaster(){
+ string schedHost("localhost");
+ string schedPort("8032");
+ string tokenService = "";
+ Yarn::Config config;
+ Yarn::Internal::SessionConfig sessionConfig(config);
+ Yarn::Internal::UserInfo user = Yarn::Internal::UserInfo::LocalUser();
+ Yarn::Internal::RpcAuth rpcAuth(user, Yarn::Internal::AuthMethod::SIMPLE);
+ protocol = new MockApplicationMasterProtocol(schedHost,schedPort,tokenService, sessionConfig,rpcAuth);
+ client = new ApplicationMaster(protocol);
+ }
+ ~TestApplicationMaster(){
+ delete client;
+ }
+
+protected:
+ MockApplicationMasterProtocol *protocol;
+ ApplicationMaster *client;
+};
+
+TEST_F(TestApplicationMaster,TestRegisterApplicationMaster){
+ Resource resource;
+ resource.setMemory(1024*8*10);
+ resource.setVirtualCores(1*8*10);
+ string key("tokenkey");
+ ApplicationACLMap aclMap;
+ aclMap.setAccessType(ApplicationAccessType::APPACCESS_VIEW_APP);
+ string acl("acl");
+ aclMap.setAcl(acl);
+ list<ApplicationACLMap> aclMapList;
+ aclMapList.push_back(aclMap);
+ RegisterApplicationMasterResponse response;
+ response.setMaximumResourceCapability(resource);
+ response.setClientToAMTokenMasterKey(key);
+ response.setApplicationACLs(aclMapList);
+ EXPECT_CALL((*protocol),registerApplicationMaster(_)).Times(AnyNumber()).WillOnce(Return(response));
+
+ string amHost("localhost");
+ int amPort = 8032;
+ string am_tracking_url = "";
+ RegisterApplicationMasterResponse retResponse = client->registerApplicationMaster(amHost,amPort,am_tracking_url);
+ EXPECT_EQ(retResponse.getClientToAMTokenMasterKey(), "tokenkey");
+ Resource retResource = retResponse.getMaximumResourceCapability();
+ EXPECT_EQ(retResource.getMemory(), 1024*8*10);
+ EXPECT_EQ(retResource.getVirtualCores(), 1*8*10);
+ list<ApplicationACLMap> retAclMapList = retResponse.getApplicationACLs();
+ EXPECT_EQ(retAclMapList.size(), 1);
+ list<ApplicationACLMap>::iterator it = retAclMapList.begin();
+ EXPECT_EQ(it->getAccessType(), ApplicationAccessType::APPACCESS_VIEW_APP);
+ EXPECT_EQ(it->getAcl(), "acl");
+}
+
+TEST_F(TestApplicationMaster,TestAllocate){
+ Resource resource;
+ resource.setMemory(1024*8*10);
+ resource.setVirtualCores(1*8*10);
+ AllocateResponse allocateResponse;
+ allocateResponse.setAMCommand(AMCommand::AM_RESYNC);
+ allocateResponse.setResponseId(100);
+ list<Container> containers;
+ Container container;
+ ContainerId containerId;
+ containerId.setId(501);
+ container.setId(containerId);
+ NodeId nodeId;
+ string nodeHost("node1");
+ nodeId.setHost(nodeHost);
+ nodeId.setPort(9983);
+ container.setNodeId(nodeId);
+ string address("http://address");
+ container.setNodeHttpAddress(address);
+ container.setResource(resource);
+ Priority priority;
+ priority.setPriority(1);
+ container.setPriority(priority);
+ libyarn::Token token;
+ string identifier("identifier");
+ token.setIdentifier(identifier);
+ string password("password");
+ token.setPassword(password);
+ string kind("kind");
+ token.setKind(kind);
+ string service("service");
+ token.setService(service);
+ container.setContainerToken(token);
+ containers.push_back(container);
+ allocateResponse.setAllocatedContainers(containers);
+ ContainerStatus containerStatus;
+ containerStatus.setContainerId(containerId);
+ containerStatus.setContainerState(ContainerState::C_RUNNING);
+ string diagnostics("diagnostics");
+ containerStatus.setDiagnostics(diagnostics);
+ containerStatus.setExitStatus(-1000);
+ list<ContainerStatus> statuses;
+ statuses.push_back(containerStatus);
+ allocateResponse.setCompletedContainerStatuses(statuses);
+ allocateResponse.setResourceLimit(resource);
+ NodeReport nodeReport;
+ nodeReport.setNodeId(nodeId);
+ string rackName("default-rack");
+ nodeReport.setRackName(rackName);
+ nodeReport.setNumContainers(8);
+ list<NodeReport> nodeReports;
+ nodeReports.push_back(nodeReport);
+ allocateResponse.setUpdatedNodes(nodeReports);
+ allocateResponse.setNumClusterNodes(12);
+ NMToken nmToken;
+ nmToken.setNodeId(nodeId);
+ nmToken.setToken(token);
+ list<NMToken> nmTokens;
+ nmTokens.push_back(nmToken);
+ allocateResponse.setNMTokens(nmTokens);
+ EXPECT_CALL((*protocol),allocate(_)).Times(AnyNumber()).WillOnce(Return(allocateResponse));
+
+ list<ResourceRequest> asks;
+ list<ContainerId> releases;
+ ResourceBlacklistRequest blacklistRequest;
+ int32_t responseId;
+ float progress = 5;
+ AllocateResponse retResponse = client->allocate(asks,releases,blacklistRequest,responseId,progress);
+ EXPECT_EQ(retResponse.getAMCommand(), AMCommand::AM_RESYNC);
+ EXPECT_EQ(retResponse.getResponseId(), 100);
+ list<Container> retContainers = retResponse.getAllocatedContainers();
+ list<Container>::iterator it = retContainers.begin();
+ EXPECT_EQ(it->getId().getId(), 501);
+ EXPECT_EQ(it->getNodeId().getHost(), "node1");
+ EXPECT_EQ(it->getNodeId().getPort(), 9983);
+ EXPECT_EQ(it->getNodeHttpAddress(), "http://address");
+ EXPECT_EQ(it->getPriority().getPriority(), 1);
+ EXPECT_EQ(it->getResource().getMemory(), 1024*8*10);
+ EXPECT_EQ(it->getResource().getVirtualCores(), 1*8*10);
+ EXPECT_EQ(it->getContainerToken().getIdentifier(), "identifier");
+ EXPECT_EQ(it->getContainerToken().getPassword(), "password");
+ EXPECT_EQ(it->getContainerToken().getKind(), "kind");
+ EXPECT_EQ(it->getContainerToken().getService(), "service");
+ list<ContainerStatus>::iterator retStatus = retResponse.getCompletedContainersStatuses().begin();
+ EXPECT_EQ(retStatus->getContainerId().getId(), 501);
+ EXPECT_EQ(retStatus->getContainerState(), ContainerState::C_RUNNING);
+ //EXPECT_EQ(retStatus->getDiagnostics(), "diagnostics");
+ EXPECT_EQ(retStatus->getExitStatus(), -1000);
+ EXPECT_EQ(retResponse.getResourceLimit().getMemory(), 1024*8*10);
+ //list<NodeReport>::iterator report = response.getUpdatedNodes().begin();
+ //EXPECT_EQ(report->getNodeId().getHost(), "node1");
+ //list<NMToken>::iterator nmToken = response.getNMTokens().begin();
+ //EXPECT_EQ(nmToken->getNodeId().getHost(), "node1");
+ //EXPECT_EQ(nmToken->getToken().getIdentifier(), "identifier");
+ EXPECT_EQ(retResponse.getNumClusterNodes(), 12);
+}
+
+TEST_F(TestApplicationMaster,TestFinishApplicationMaster){
+ FinishApplicationMasterResponse finishApplicationMasterResponse;
+ finishApplicationMasterResponse.setIsUnregistered(true);
+ EXPECT_CALL((*protocol),finishApplicationMaster(_)).Times(AnyNumber()).WillOnce(Return(finishApplicationMasterResponse));
+ string diagnostics("");
+ string trackingUrl("");
+ FinalApplicationStatus finalstatus;
+ bool response = client->finishApplicationMaster(diagnostics,trackingUrl,finalstatus);
+ EXPECT_EQ(response,true);
+}
+
http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/383818c2/depends/libyarn/test/unit/TestLibYarnClient/TestContainerManagement.cpp
----------------------------------------------------------------------
diff --git a/depends/libyarn/test/unit/TestLibYarnClient/TestContainerManagement.cpp b/depends/libyarn/test/unit/TestLibYarnClient/TestContainerManagement.cpp
new file mode 100644
index 0000000..e927d68
--- /dev/null
+++ b/depends/libyarn/test/unit/TestLibYarnClient/TestContainerManagement.cpp
@@ -0,0 +1,158 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+#include <list>
+#include <map>
+#include <string>
+
+#include "gtest/gtest.h"
+#include "gmock/gmock.h"
+
+#include "libyarnclient/ContainerManagement.h"
+#include "MockContainerManagementProtocol.h"
+#include "TestContainerManagementStub.h"
+
+using std::map;
+using std::string;
+using std::list;
+using namespace libyarn;
+using namespace testing;
+using namespace Mock;
+
+class MockContainerManagementStub: public TestContainerManagementStub {
+public:
+ MOCK_METHOD0(getContainerManagementProtocol, ContainerManagementProtocol * ());
+};
+
+TEST(TestContainerManagement,TestStartContainer){
+ ContainerManagement client;
+ MockContainerManagementStub stub;
+ string nmHost("localhost");
+ string nmPort("8032");
+ string tokenService = "";
+ Yarn::Config config;
+ Yarn::Internal::SessionConfig sessionConfig(config);
+ Yarn::Internal::UserInfo user = Yarn::Internal::UserInfo::LocalUser();
+ Yarn::Internal::RpcAuth rpcAuth(user, Yarn::Internal::AuthMethod::SIMPLE);
+ MockContainerManagementProtocol *protocol =new MockContainerManagementProtocol(nmHost,nmPort,tokenService,sessionConfig,rpcAuth);
+
+ StringBytesMap map;
+ string key("key");
+ string value("value");
+ map.setKey(key);
+ map.setValue(value);
+ list<StringBytesMap> maps;
+ maps.push_back(map);
+ ContainerId containerId;
+ containerId.setId(501);
+ list<ContainerId> containerIds;
+ containerIds.push_back(containerId);
+ ContainerExceptionMap exceptionMap;
+ exceptionMap.setContainerId(containerId);
+ SerializedException exception;
+ string message("message");
+ string trace("trace");
+ string className("className");
+ exception.setMessage(message);
+ exception.setTrace(trace);
+ exception.setClassName(className);
+ SerializedException cause;
+ string message2("message2");
+ cause.setMessage(message2);
+ exception.setCause(cause);
+ exceptionMap.setSerializedException(exception);
+ list<ContainerExceptionMap> exceptionMaps;
+ exceptionMaps.push_back(exceptionMap);
+ StartContainersResponse response;
+ response.setServicesMetaData(maps);
+ response.setSucceededRequests(containerIds);
+ response.setFailedRequests(exceptionMaps);
+ EXPECT_CALL(*protocol, startContainers(_)).Times(AnyNumber()).WillOnce(Return(response));
+ client.stub = &stub;
+ EXPECT_CALL(stub, getContainerManagementProtocol()).Times(AnyNumber()).WillOnce(Return(protocol));
+
+ Container container;
+ StartContainerRequest request;
+ libyarn::Token nmToken;
+ StartContainerResponse ret = client.startContainer(container,request,nmToken);
+ list<StringBytesMap>::iterator itMap = ret.getServicesMetaData().begin();
+ //EXPECT_EQ(itMap->getKey(), "key");
+ //EXPECT_EQ(itMap->getValue(), "value");
+}
+
+TEST(TestContainerManagement,TestStopContainer){
+ ContainerManagement client;
+ MockContainerManagementStub stub;
+ string nmHost("localhost");
+ string nmPort("8032");
+ string tokenService = "";
+ Yarn::Config config;
+ Yarn::Internal::SessionConfig sessionConfig(config);
+ Yarn::Internal::UserInfo user = Yarn::Internal::UserInfo::LocalUser();
+ Yarn::Internal::RpcAuth rpcAuth(user, Yarn::Internal::AuthMethod::SIMPLE);
+ MockContainerManagementProtocol *protocol =new MockContainerManagementProtocol(nmHost,nmPort,tokenService,sessionConfig,rpcAuth);
+
+ StopContainersResponseProto stopResponseProto;
+ EXPECT_CALL(*protocol, stopContainers(_)).Times(AnyNumber()).WillOnce(Return(StopContainersResponse(stopResponseProto)));
+ client.stub = &stub;
+ EXPECT_CALL(stub, getContainerManagementProtocol()).Times(AnyNumber()).WillOnce(Return(protocol));
+
+ Container container;
+ libyarn::Token nmToken;
+ client.stopContainer(container,nmToken);
+}
+
+TEST(TestContainerManagement,TestGetContainerStatus){
+ ContainerManagement client;
+ MockContainerManagementStub stub;
+ string nmHost("localhost");
+ string nmPort("8032");
+ string tokenService = "";
+ Yarn::Config config;
+ Yarn::Internal::SessionConfig sessionConfig(config);
+ Yarn::Internal::UserInfo user = Yarn::Internal::UserInfo::LocalUser();
+ Yarn::Internal::RpcAuth rpcAuth(user, Yarn::Internal::AuthMethod::SIMPLE);
+ MockContainerManagementProtocol *protocol =new MockContainerManagementProtocol(nmHost,nmPort,tokenService,sessionConfig,rpcAuth);
+
+ GetContainerStatusesResponse getResponse;
+ ContainerId containerId;
+ containerId.setId(501);
+ ContainerStatus status;
+ status.setContainerId(containerId);
+ list<ContainerStatus> statuses;
+ statuses.push_back(status);
+ getResponse.setContainerStatuses(statuses);
+ EXPECT_CALL(*protocol, getContainerStatuses(_)).Times(1).WillOnce(Return(getResponse));
+ client.stub = &stub;
+ EXPECT_CALL(stub, getContainerManagementProtocol()).Times(1).WillRepeatedly(Return(protocol));
+
+ Container container;
+ libyarn::Token nmToken;
+ ContainerStatus retStatus = client.getContainerStatus(container,nmToken);
+ EXPECT_EQ(retStatus.getContainerId().getId(), 501);
+
+ GetContainerStatusesResponse getEmptyResponse;
+ protocol =new MockContainerManagementProtocol(nmHost,nmPort,tokenService,sessionConfig,rpcAuth);
+ EXPECT_CALL(*protocol, getContainerStatuses(_)).Times(1).WillOnce(Return(getEmptyResponse));
+ EXPECT_CALL(stub, getContainerManagementProtocol()).Times(1).WillRepeatedly(Return(protocol));
+
+ retStatus = client.getContainerStatus(container, nmToken);
+ EXPECT_EQ(retStatus.getContainerId().getId(), 0);
+}
+