int getQueueInfo(LibYarnClient_t *client, char *queue, bool includeApps, bool includeChildQueues, bool recursive, LibYarnQueueInfo_t **queueInfo) { string queueStr(queue); QueueInfo queueInfoCpp; int result = client->getQueueInfo(queueStr, includeApps, includeChildQueues,recursive, queueInfoCpp); if (result == FUNCTION_SUCCEEDED) { *queueInfo = (LibYarnQueueInfo_t *) malloc(sizeof(LibYarnQueueInfo_t)); (*queueInfo)->queueName = strdup(queueInfoCpp.getQueueName().c_str()); (*queueInfo)->capacity = queueInfoCpp.getCapacity(); (*queueInfo)->maximumCapacity = queueInfoCpp.getMaximumCapacity(); (*queueInfo)->currentCapacity = queueInfoCpp.getCurrentCapacity(); (*queueInfo)->state = queueInfoCpp.getQueueState(); list<QueueInfo> childQueueInfos = queueInfoCpp.getChildQueues(); (*queueInfo)->childQueueNameArraySize = childQueueInfos.size(); (*queueInfo)->childQueueNameArray = (char**) malloc(sizeof(char *) * childQueueInfos.size()); int i = 0; for (list<QueueInfo>::iterator it = childQueueInfos.begin(); it != childQueueInfos.end(); it++) { (*queueInfo)->childQueueNameArray[i] = strdup(it->getQueueName().c_str()); i++; } return FUNCTION_SUCCEEDED; } else { setErrorMessage(client->getErrorMessage()); return FUNCTION_FAILED; } }
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"); }