提交 3d017330 编写于 作者: O openeuler-ci-bot 提交者: Gitee

!72 add testcase for pause/resume

Merge pull request !72 from Jackey_1024/master
......@@ -21,6 +21,10 @@
#include "libisulad.h"
#include "monitord.h"
#ifdef __cplusplus
extern "C" {
#endif
struct context_lists {
pthread_mutex_t context_mutex;
struct linked_list context_list;
......@@ -42,5 +46,9 @@ void free_event(struct isulad_events_format *event);
int isulad_monitor_send_event(const char *name, runtime_state_t state, int pid, int exit_code);
#ifdef __cplusplus
}
#endif
#endif /* __COLLECTOR_H */
......@@ -22,6 +22,10 @@
#define etcOsRelease "/etc/os-release"
#define altOsRelease "/usr/lib/os-release"
#ifdef __cplusplus
extern "C" {
#endif
typedef struct {
bool limit;
bool swap;
......@@ -134,5 +138,9 @@ mountinfo_t *find_mount_info(mountinfo_t **minfos, const char *dir);
void free_mounts_info(mountinfo_t **minfos);
#ifdef __cplusplus
}
#endif
#endif /* __SYSINFO_H */
......@@ -17,6 +17,11 @@
#include "oci_runtime_spec.h"
#include "host_config.h"
#include "container_config.h"
#ifdef __cplusplus
extern "C" {
#endif
int verify_container_settings(const oci_runtime_spec *container);
......@@ -28,6 +33,9 @@ int verify_host_config_settings(host_config *hostconfig, bool update);
int verify_health_check_parameter(const container_config *container_spec);
#ifdef __cplusplus
}
#endif
#endif /* __VERIFY_H */
/******************************************************************************
* Copyright (c) Huawei Technologies Co., Ltd. 2020. All rights reserved.
* iSulad licensed under the Mulan PSL v1.
* You can use this software according to the terms and conditions of the Mulan PSL v1.
* You may obtain a copy of Mulan PSL v1 at:
* http://license.coscl.org.cn/MulanPSL
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR
* PURPOSE.
* See the Mulan PSL v1 for more details.
* Author: jikui
* Create: 2020-02-25
* Description: provide collector mock
******************************************************************************/
#include "collector_mock.h"
namespace {
MockCollector *g_collector_mock = NULL;
}
void MockCollector_SetMock(MockCollector *mock)
{
g_collector_mock = mock;
}
int events_subscribe(const char *name, const types_timestamp_t *since, const types_timestamp_t *until,
const stream_func_wrapper *stream)
{
if (g_collector_mock != nullptr) {
return g_collector_mock->EventsSubscribe(name, since, until, stream);
}
return 0;
}
int add_monitor_client(char *name, const types_timestamp_t *since, const types_timestamp_t *until,
const stream_func_wrapper *stream)
{
if (g_collector_mock != nullptr) {
return g_collector_mock->AddMonitorClient(name, since, until, stream);
}
return 0;
}
/******************************************************************************
* Copyright (c) Huawei Technologies Co., Ltd. 2020. All rights reserved.
* iSulad licensed under the Mulan PSL v1.
* You can use this software according to the terms and conditions of the Mulan PSL v1.
* You may obtain a copy of Mulan PSL v1 at:
* http://license.coscl.org.cn/MulanPSL
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR
* PURPOSE.
* See the Mulan PSL v1 for more details.
* Author: jikui
* Create: 2020-02-25
* Description: provide collector mock
******************************************************************************/
#ifndef COLLECTOR_MOCK_H_
#define COLLECTOR_MOCK_H_
#include <gmock/gmock.h>
#include "collector.h"
class MockCollector {
public:
MOCK_METHOD4(EventsSubscribe, int(const char *name, const types_timestamp_t *since, const types_timestamp_t *until,
const stream_func_wrapper *stream));
MOCK_METHOD4(AddMonitorClient, int(const char *name, const types_timestamp_t *since, const types_timestamp_t *until,
const stream_func_wrapper *stream));
};
void MockCollector_SetMock(MockCollector* mock);
#endif
/******************************************************************************
* Copyright (c) Huawei Technologies Co., Ltd. 2020. All rights reserved.
* iSulad licensed under the Mulan PSL v1.
* You can use this software according to the terms and conditions of the Mulan PSL v1.
* You may obtain a copy of Mulan PSL v1 at:
* http://license.coscl.org.cn/MulanPSL
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR
* PURPOSE.
* See the Mulan PSL v1 for more details.
* Author: jikui
* Create: 2020-02-25
* Description: provide container_state mock
******************************************************************************/
#include "container_state_mock.h"
namespace {
MockContainerState *g_container_state_mock = NULL;
}
void MockContainerState_SetMock(MockContainerState *mock)
{
g_container_state_mock = mock;
}
bool is_running(container_state_t *s)
{
if (g_container_state_mock != nullptr) {
return g_container_state_mock->IsRunning(s);
}
return true;
}
bool is_restarting(container_state_t *s)
{
if (g_container_state_mock != nullptr) {
return g_container_state_mock->IsRestarting(s);
}
return false;
}
bool is_dead(container_state_t *s)
{
if (g_container_state_mock != nullptr) {
return g_container_state_mock->IsDead(s);
}
return true;
}
void container_state_set_error(container_state_t *s, const char *err)
{
if (g_container_state_mock != nullptr) {
return g_container_state_mock->ContainerStateSetError(s, err);
}
}
bool is_paused(container_state_t *s)
{
if (g_container_state_mock != nullptr) {
return g_container_state_mock->IsPaused(s);
}
return true;
}
void state_reset_paused(container_state_t *s)
{
if (g_container_state_mock != nullptr) {
return g_container_state_mock->StateResetPaused(s);
}
}
void state_set_paused(container_state_t *s)
{
if (g_container_state_mock != nullptr) {
return g_container_state_mock->StateSetPaused(s);
}
}
bool is_removal_in_progress(container_state_t *s)
{
if (g_container_state_mock != nullptr) {
return g_container_state_mock->IsRemovalInProgress(s);
}
return true;
}
/******************************************************************************
* Copyright (c) Huawei Technologies Co., Ltd. 2020. All rights reserved.
* iSulad licensed under the Mulan PSL v1.
* You can use this software according to the terms and conditions of the Mulan PSL v1.
* You may obtain a copy of Mulan PSL v1 at:
* http://license.coscl.org.cn/MulanPSL
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR
* PURPOSE.
* See the Mulan PSL v1 for more details.
* Author: jikui
* Create: 2020-02-25
* Description: provide container_state mock
******************************************************************************/
#ifndef CONTAINER_STATE_MOCK_H_
#define CONTAINER_STATE_MOCK_H_
#include <gmock/gmock.h>
#include "container_state.h"
class MockContainerState {
public:
MOCK_METHOD1(IsRunning, bool(container_state_t *s));
MOCK_METHOD1(IsPaused, bool(container_state_t *s));
MOCK_METHOD1(IsRestarting, bool(container_state_t *s));
MOCK_METHOD1(IsDead, bool(container_state_t *s));
MOCK_METHOD1(StateResetPaused, void(container_state_t *s));
MOCK_METHOD2(ContainerStateSetError, void(container_state_t *s, const char *err));
MOCK_METHOD1(StateSetPaused, void(container_state_t *s));
MOCK_METHOD1(IsRemovalInProgress, bool(container_state_t *s));
};
void MockContainerState_SetMock(MockContainerState* mock);
#endif
......@@ -46,3 +46,33 @@ int container_read_proc(uint32_t pid, container_pid_t *pid_info)
{
return 0;
}
int container_to_disk(const container_t *cont)
{
if (g_container_unix_mock != nullptr) {
return g_container_unix_mock->ContainerToDisk(cont);
}
return 0;
}
void container_unlock(container_t *cont)
{
if (g_container_unix_mock != nullptr) {
return g_container_unix_mock->ContainerUnlock(cont);
}
}
void container_lock(container_t *cont)
{
if (g_container_unix_mock != nullptr) {
return g_container_unix_mock->ContainerLock(cont);
}
}
void container_update_restart_manager(container_t *cont, const host_config_restart_policy *policy)
{
if (g_container_unix_mock != nullptr) {
return g_container_unix_mock->ContainerUpdateRestartManager(cont, policy);
}
}
......@@ -23,9 +23,13 @@ class MockContainerUnix {
public:
virtual ~MockContainerUnix() = default;
MOCK_METHOD2(HasMountFor, bool(container_t *cont, const char *mpath));
MOCK_METHOD1(ContainerToDisk, int(const container_t *cont));
MOCK_METHOD1(ContainerUnlock, void(const container_t *cont));
MOCK_METHOD1(ContainerLock, void(const container_t *cont));
MOCK_METHOD1(ContainerUnref, void(container_t *cont));
MOCK_METHOD2(ContainerUpdateRestartManager, void(container_t *cont, const host_config_restart_policy *policy));
};
void MockContainerUnix_SetMock(MockContainerUnix* mock);
#endif // CONTAINER_UNIX_MOCK_H_
\ No newline at end of file
#endif // CONTAINER_UNIX_MOCK_H_
/******************************************************************************
* Copyright (c) Huawei Technologies Co., Ltd. 2020. All rights reserved.
* iSulad licensed under the Mulan PSL v1.
* You can use this software according to the terms and conditions of the Mulan PSL v1.
* You may obtain a copy of Mulan PSL v1 at:
* http://license.coscl.org.cn/MulanPSL
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR
* PURPOSE.
* See the Mulan PSL v1 for more details.
* Author: jikui
* Create: 2020-02-25
* Description: provide containers_gc mock
******************************************************************************/
#include "containers_gc_mock.h"
namespace {
MockContainersGc *g_containers_gc_mock = NULL;
}
void MockContainersGc_SetMock(MockContainersGc *mock)
{
g_containers_gc_mock = mock;
}
bool gc_is_gc_progress(const char *id)
{
if (g_containers_gc_mock != nullptr) {
return g_containers_gc_mock->GcIsGcProgress(id);
}
return true;
}
/******************************************************************************
* Copyright (c) Huawei Technologies Co., Ltd. 2020. All rights reserved.
* iSulad licensed under the Mulan PSL v1.
* You can use this software according to the terms and conditions of the Mulan PSL v1.
* You may obtain a copy of Mulan PSL v1 at:
* http://license.coscl.org.cn/MulanPSL
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR
* PURPOSE.
* See the Mulan PSL v1 for more details.
* Author: jikui
* Create: 2020-02-25
* Description: provide containers_gc mock
******************************************************************************/
#ifndef CONTAINERS_GC_MOCK_H_
#define CONTAINERS_GC_MOCK_H_
#include <gmock/gmock.h>
#include "containers_gc.h"
class MockContainersGc {
public:
MOCK_METHOD1(GcIsGcProgress, bool(const char *id));
};
void MockContainersGc_SetMock(MockContainersGc* mock);
#endif
/******************************************************************************
* Copyright (c) Huawei Technologies Co., Ltd. 2020. All rights reserved.
* iSulad licensed under the Mulan PSL v1.
* You can use this software according to the terms and conditions of the Mulan PSL v1.
* You may obtain a copy of Mulan PSL v1 at:
* http://license.coscl.org.cn/MulanPSL
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR
* PURPOSE.
* See the Mulan PSL v1 for more details.
* Author: jikui
* Create: 2020-02-25
* Description: provide driver mock
******************************************************************************/
#include "driver_mock.h"
namespace {
MockDriver *g_driver_mock = NULL;
}
void MockDriver_SetMock(MockDriver *mock)
{
g_driver_mock = mock;
}
/******************************************************************************
* Copyright (c) Huawei Technologies Co., Ltd. 2020. All rights reserved.
* iSulad licensed under the Mulan PSL v1.
* You can use this software according to the terms and conditions of the Mulan PSL v1.
* You may obtain a copy of Mulan PSL v1 at:
* http://license.coscl.org.cn/MulanPSL
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR
* PURPOSE.
* See the Mulan PSL v1 for more details.
* Author: jikui
* Create: 2020-02-25
* Description: provide driver mock
******************************************************************************/
#ifndef DRIVER_MOCK_H_
#define DRIVER_MOCK_H_
#include <gmock/gmock.h>
#include "driver.h"
class MockDriver {
};
void MockDriver_SetMock(MockDriver* mock);
#endif
/******************************************************************************
* Copyright (c) Huawei Technologies Co., Ltd. 2020. All rights reserved.
* iSulad licensed under the Mulan PSL v1.
* You can use this software according to the terms and conditions of the Mulan PSL v1.
* You may obtain a copy of Mulan PSL v1 at:
* http://license.coscl.org.cn/MulanPSL
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR
* PURPOSE.
* See the Mulan PSL v1 for more details.
* Author: jikui
* Create: 2020-02-25
* Description: provide health_check mock
******************************************************************************/
#include "health_check_mock.h"
namespace {
MockHealthCheck *g_health_check_mock = NULL;
}
void MockHealthCheck_SetMock(MockHealthCheck *mock)
{
g_health_check_mock = mock;
}
void update_health_monitor(const char *container_id)
{
if (g_health_check_mock != nullptr) {
return g_health_check_mock->UpdateHealthMonitor(container_id);
}
return;
}
/******************************************************************************
* Copyright (c) Huawei Technologies Co., Ltd. 2020. All rights reserved.
* iSulad licensed under the Mulan PSL v1.
* You can use this software according to the terms and conditions of the Mulan PSL v1.
* You may obtain a copy of Mulan PSL v1 at:
* http://license.coscl.org.cn/MulanPSL
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR
* PURPOSE.
* See the Mulan PSL v1 for more details.
* Author: jikui
* Create: 2020-02-25
* Description: provide health_check mock
******************************************************************************/
#ifndef HEALTH_CHECK_MOCK_H_
#define HEALTH_CHECK_MOCK_H_
#include <gmock/gmock.h>
#include "health_check.h"
class MockHealthCheck {
public:
MOCK_METHOD1(UpdateHealthMonitor, void(const char *container_id));
};
void MockHealthCheck_SetMock(MockHealthCheck* mock);
#endif
......@@ -40,3 +40,18 @@ void free_im_storage_status_response(im_storage_status_response *ptr)
}
return;
}
int im_container_export(const im_export_request *request)
{
if (g_image_mock != nullptr) {
return g_image_mock->ImContainerExport(request);
}
return 0;
}
void free_im_export_request(im_export_request *ptr)
{
if (g_image_mock != nullptr) {
return g_image_mock->FreeImExportRequest(ptr);
}
}
......@@ -24,6 +24,8 @@ public:
virtual ~MockImage() = default;
MOCK_METHOD2(ImGetStorageStatus, int(const char *, im_storage_status_response **));
MOCK_METHOD1(FreeImStorageStatusResponse, void(im_storage_status_response *));
MOCK_METHOD1(ImContainerExport, int(const im_export_request *request));
MOCK_METHOD1(FreeImExportRequest, void(im_export_request *ptr));
};
void MockImage_SetMock(MockImage* mock);
......
......@@ -112,3 +112,19 @@ struct service_arguments *conf_get_server_conf()
{
return NULL;
}
int get_system_cpu_usage(uint64_t *val)
{
if (g_isulad_conf_mock != nullptr) {
return g_isulad_conf_mock->GetSystemCpuUsage(val);
}
return 0;
}
char *conf_get_isulad_storage_driver_backing_fs()
{
if (g_isulad_conf_mock != nullptr) {
return g_isulad_conf_mock->ConfGetIsuladStorageDriverBackingFs();
}
return nullptr;
}
......@@ -31,6 +31,9 @@ public:
MOCK_METHOD0(GetUmask, char *(void));
MOCK_METHOD0(ConfGetGraphRootpath, char *(void));
MOCK_METHOD0(ConfGetIsuladStorageDriver, char *(void));
MOCK_METHOD1(GetSystemCpuUsage, int(uint64_t *val));
MOCK_METHOD0(ConfGetIsuladStorageDriverBackingFs, char*());
};
void MockIsuladConf_SetMock(MockIsuladConf* mock);
......
/******************************************************************************
* Copyright (c) Huawei Technologies Co., Ltd. 2020. All rights reserved.
* iSulad licensed under the Mulan PSL v1.
* You can use this software according to the terms and conditions of the Mulan PSL v1.
* You may obtain a copy of Mulan PSL v1 at:
* http://license.coscl.org.cn/MulanPSL
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR
* PURPOSE.
* See the Mulan PSL v1 for more details.
* Author: jikui
* Create: 2020-02-25
* Description: provide restartmanager mock
******************************************************************************/
#include "restartmanager_mock.h"
namespace {
MockRestartmanager *g_restartmanager_mock = NULL;
}
void MockRestartmanager_SetMock(MockRestartmanager *mock)
{
g_restartmanager_mock = mock;
}
/******************************************************************************
* Copyright (c) Huawei Technologies Co., Ltd. 2020. All rights reserved.
* iSulad licensed under the Mulan PSL v1.
* You can use this software according to the terms and conditions of the Mulan PSL v1.
* You may obtain a copy of Mulan PSL v1 at:
* http://license.coscl.org.cn/MulanPSL
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR
* PURPOSE.
* See the Mulan PSL v1 for more details.
* Author: jikui
* Create: 2020-02-25
* Description: provide restartmanager mock
******************************************************************************/
#ifndef RESTARTMANAGER_MOCK_H_
#define RESTARTMANAGER_MOCK_H_
#include <gmock/gmock.h>
#include "restartmanager.h"
class MockRestartmanager {
public:
};
void MockRestartmanager_SetMock(MockRestartmanager *mock);
#endif
/******************************************************************************
* Copyright (c) Huawei Technologies Co., Ltd. 2020. All rights reserved.
* iSulad licensed under the Mulan PSL v1.
* You can use this software according to the terms and conditions of the Mulan PSL v1.
* You may obtain a copy of Mulan PSL v1 at:
* http://license.coscl.org.cn/MulanPSL
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR
* PURPOSE.
* See the Mulan PSL v1 for more details.
* Author: jikui
* Create: 2020-02-25
* Description: provide runtime mock
******************************************************************************/
#include "runtime_mock.h"
namespace {
MockRuntime *g_runtime_mock = NULL;
}
void MockRuntime_SetMock(MockRuntime *mock)
{
g_runtime_mock = mock;
}
int runtime_pause(const char *name, const char *runtime, const rt_pause_params_t *params)
{
if (g_runtime_mock != nullptr) {
return g_runtime_mock->RuntimePause(name, runtime, params);
}
return 0;
}
int runtime_resources_stats(const char *name, const char *runtime, const rt_stats_params_t *params,
struct engine_container_resources_stats_info *rs_stats)
{
if (g_runtime_mock != nullptr) {
return g_runtime_mock->RuntimeResourcesStats(name, runtime, params, rs_stats);
}
return 0;
}
int runtime_resume(const char *name, const char *runtime, const rt_resume_params_t *params)
{
if (g_runtime_mock != nullptr) {
return g_runtime_mock->RuntimeResume(name, runtime, params);
}
return 0;
}
int runtime_update(const char *name, const char *runtime, const rt_update_params_t *params)
{
if (g_runtime_mock != nullptr) {
return g_runtime_mock->RuntimeUpdate(name, runtime, params);
}
return 0;
}
int runtime_resize(const char *name, const char *runtime, const rt_resize_params_t *params)
{
if (g_runtime_mock != nullptr) {
return g_runtime_mock->RuntimeResize(name, runtime, params);
}
return 0;
}
int runtime_exec_resize(const char *name, const char *runtime, const rt_exec_resize_params_t *params)
{
if (g_runtime_mock != nullptr) {
return g_runtime_mock->RuntimeExecResize(name, runtime, params);
}
return 0;
}
/******************************************************************************
* Copyright (c) Huawei Technologies Co., Ltd. 2020. All rights reserved.
* iSulad licensed under the Mulan PSL v1.
* You can use this software according to the terms and conditions of the Mulan PSL v1.
* You may obtain a copy of Mulan PSL v1 at:
* http://license.coscl.org.cn/MulanPSL
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR
* PURPOSE.
* See the Mulan PSL v1 for more details.
* Author: jikui
* Create: 2020-02-25
* Description: provide runtime mock
******************************************************************************/
#ifndef RUNTIME_MOCK_H_
#define RUNTIME_MOCK_H_
#include <gmock/gmock.h>
#include "runtime.h"
class MockRuntime {
public:
MOCK_METHOD3(RuntimePause, int(const char *name, const char *runtime, const rt_pause_params_t *params));
MOCK_METHOD3(RuntimeResume, int(const char *name, const char *runtime, const rt_resume_params_t *params));
MOCK_METHOD3(RuntimeUpdate, int(const char *name, const char *runtime, const rt_update_params_t *params));
MOCK_METHOD3(RuntimeResize, int(const char *name, const char *runtime, const rt_resize_params_t *params));
MOCK_METHOD3(RuntimeExecResize, int(const char *name, const char *runtime, const rt_exec_resize_params_t *params));
MOCK_METHOD4(RuntimeResourcesStats, int(const char *name, const char *runtime, const rt_stats_params_t *params,
struct engine_container_resources_stats_info *rs_stats));
};
void MockRuntime_SetMock(MockRuntime* mock);
#endif
/******************************************************************************
* Copyright (c) Huawei Technologies Co., Ltd. 2020. All rights reserved.
* iSulad licensed under the Mulan PSL v1.
* You can use this software according to the terms and conditions of the Mulan PSL v1.
* You may obtain a copy of Mulan PSL v1 at:
* http://license.coscl.org.cn/MulanPSL
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR
* PURPOSE.
* See the Mulan PSL v1 for more details.
* Author: jikui
* Create: 2020-02-25
* Description: provide specs mock
******************************************************************************/
#include "specs_mock.h"
namespace {
MockSpecs *g_specs_mock = NULL;
}
void MockSpecs_SetMock(MockSpecs *mock)
{
g_specs_mock = mock;
}
oci_runtime_spec *load_oci_config(const char *rootpath, const char *name)
{
if (g_specs_mock != nullptr) {
return g_specs_mock->LoadOciConfig(rootpath, name);
}
return nullptr;
}
int merge_conf_cgroup(oci_runtime_spec *oci_spec, const host_config *host_spec)
{
if (g_specs_mock != nullptr) {
return g_specs_mock->MergeConfCgroup(oci_spec, host_spec);
}
return 0;
}
int save_oci_config(const char *id, const char *rootpath, const oci_runtime_spec *oci_spec)
{
if (g_specs_mock != nullptr) {
return g_specs_mock->SaveOciConfig(id, rootpath, oci_spec);
}
return 0;
}
/******************************************************************************
* Copyright (c) Huawei Technologies Co., Ltd. 2020. All rights reserved.
* iSulad licensed under the Mulan PSL v1.
* You can use this software according to the terms and conditions of the Mulan PSL v1.
* You may obtain a copy of Mulan PSL v1 at:
* http://license.coscl.org.cn/MulanPSL
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR
* PURPOSE.
* See the Mulan PSL v1 for more details.
* Author: jikui
* Create: 2020-02-25
* Description: provide specs mock
******************************************************************************/
#ifndef SPECS_MOCK_H_
#define SPECS_MOCK_H_
#include <gmock/gmock.h>
#include "specs.h"
class MockSpecs {
public:
MOCK_METHOD2(LoadOciConfig, oci_runtime_spec * (const char *rootpath, const char *name));
MOCK_METHOD2(MergeConfCgroup, int(oci_runtime_spec *oci_spec, const host_config *host_spec));
MOCK_METHOD3(SaveOciConfig, int(const char *id, const char *rootpath, const oci_runtime_spec *oci_spec));
};
void MockSpecs_SetMock(MockSpecs* mock);
#endif
/******************************************************************************
* Copyright (c) Huawei Technologies Co., Ltd. 2020. All rights reserved.
* iSulad licensed under the Mulan PSL v1.
* You can use this software according to the terms and conditions of the Mulan PSL v1.
* You may obtain a copy of Mulan PSL v1 at:
* http://license.coscl.org.cn/MulanPSL
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR
* PURPOSE.
* See the Mulan PSL v1 for more details.
* Author: jikui
* Create: 2020-02-25
* Description: provide sysinfo mock
******************************************************************************/
#include "sysinfo_mock.h"
namespace {
MockSysinfo *g_sysinfo_mock = NULL;
}
void MockSysinfo_SetMock(MockSysinfo *mock)
{
g_sysinfo_mock = mock;
}
uint64_t get_default_total_mem_size(void)
{
if (g_sysinfo_mock != nullptr) {
return g_sysinfo_mock->GetDefaultTotalMemSize();
}
return 0;
}
mountinfo_t *find_mount_info(mountinfo_t **minfos, const char *dir)
{
if (g_sysinfo_mock != nullptr) {
return g_sysinfo_mock->FindMountInfo(minfos, dir);
}
return nullptr;
}
void free_mounts_info(mountinfo_t **minfos)
{
if (g_sysinfo_mock != nullptr) {
return g_sysinfo_mock->FreeMountsInfo(minfos);
}
}
char *validate_hugetlb(const char *pagesize, uint64_t limit)
{
if (g_sysinfo_mock != nullptr) {
return g_sysinfo_mock->ValidateHugetlb(pagesize, limit);
}
return nullptr;
}
void free_sysinfo(sysinfo_t *sysinfo)
{
if (g_sysinfo_mock != nullptr) {
return g_sysinfo_mock->FreeSysinfo(sysinfo);
}
}
/******************************************************************************
* Copyright (c) Huawei Technologies Co., Ltd. 2020. All rights reserved.
* iSulad licensed under the Mulan PSL v1.
* You can use this software according to the terms and conditions of the Mulan PSL v1.
* You may obtain a copy of Mulan PSL v1 at:
* http://license.coscl.org.cn/MulanPSL
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR
* PURPOSE.
* See the Mulan PSL v1 for more details.
* Author: jikui
* Create: 2020-02-25
* Description: provide sysinfo mock
******************************************************************************/
#ifndef SYSINFO_MOCK_H_
#define SYSINFO_MOCK_H_
#include <gmock/gmock.h>
#include "sysinfo.h"
class MockSysinfo {
public:
MOCK_METHOD0(GetDefaultTotalMemSize, uint64_t(void));
MOCK_METHOD2(FindMountInfo, mountinfo_t*(mountinfo_t **minfos, const char *dir));
MOCK_METHOD1(FreeMountsInfo, void(mountinfo_t **minfos));
MOCK_METHOD2(ValidateHugetlb, char*(const char *pagesize, uint64_t limit));
MOCK_METHOD1(FreeSysinfo, void(sysinfo_t *sysinfo));
};
void MockSysinfo_SetMock(MockSysinfo* mock);
#endif
/******************************************************************************
* Copyright (c) Huawei Technologies Co., Ltd. 2020. All rights reserved.
* iSulad licensed under the Mulan PSL v1.
* You can use this software according to the terms and conditions of the Mulan PSL v1.
* You may obtain a copy of Mulan PSL v1 at:
* http://license.coscl.org.cn/MulanPSL
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR
* PURPOSE.
* See the Mulan PSL v1 for more details.
* Author: jikui
* Create: 2020-02-25
* Description: provide verify mock
******************************************************************************/
#include "verify_mock.h"
namespace {
MockVerify *g_verify_mock = NULL;
}
void MockVerify_SetMock(MockVerify *mock)
{
g_verify_mock = mock;
}
int verify_host_config_settings(host_config *hostconfig, bool update)
{
if (g_verify_mock != nullptr) {
return g_verify_mock->VerifyHostConfigSettings(hostconfig, update);
}
return 0;
}
/******************************************************************************
* Copyright (c) Huawei Technologies Co., Ltd. 2020. All rights reserved.
* iSulad licensed under the Mulan PSL v1.
* You can use this software according to the terms and conditions of the Mulan PSL v1.
* You may obtain a copy of Mulan PSL v1 at:
* http://license.coscl.org.cn/MulanPSL
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR
* PURPOSE.
* See the Mulan PSL v1 for more details.
* Author: jikui
* Create: 2020-02-25
* Description: provide verify mock
******************************************************************************/
#ifndef VERIFY_MOCK_H_
#define VERIFY_MOCK_H_
#include <gmock/gmock.h>
#include "verify.h"
class MockVerify {
public:
MOCK_METHOD2(VerifyHostConfigSettings, int(host_config *hostconfig, bool update));
};
void MockVerify_SetMock(MockVerify* mock);
#endif
......@@ -127,6 +127,6 @@ TEST_F(IsulaRtOpsUnitTest, test_rt_isula_status)
ASSERT_EQ(rt_isula_status("123", nullptr, nullptr, nullptr), -1);
ASSERT_EQ(rt_isula_status("123", "kata-runtime", nullptr, nullptr), -1);
ASSERT_EQ(rt_isula_status("123", "kata-runtime", &params, nullptr), -1);
params.state="/var/run/isulad/kata-runtime";
params.state = "/var/run/isulad/kata-runtime";
ASSERT_EQ(rt_isula_status("123", "kata-runtime", &params, &status), -1);
}
project(iSulad_LLT)
add_subdirectory(spec)
add_subdirectory(execute)
project(iSulad_LLT)
add_subdirectory(execution_extend)
project(iSulad_LLT)
SET(EXE execution_extend_llt)
add_executable(${EXE}
${CMAKE_CURRENT_SOURCE_DIR}/../../../../../src/log.c
${CMAKE_CURRENT_SOURCE_DIR}/../../../../../src/cutils/utils_string.c
${CMAKE_CURRENT_SOURCE_DIR}/../../../../../src/cutils/utils.c
${CMAKE_CURRENT_SOURCE_DIR}/../../../../../src/cutils/utils_array.c
${CMAKE_CURRENT_SOURCE_DIR}/../../../../../src/cutils/utils_file.c
${CMAKE_CURRENT_SOURCE_DIR}/../../../../../src/cutils/utils_convert.c
${CMAKE_CURRENT_SOURCE_DIR}/../../../../../src/cutils/utils_verify.c
${CMAKE_CURRENT_SOURCE_DIR}/../../../../../src/cutils/util_atomic.c
${CMAKE_CURRENT_SOURCE_DIR}/../../../../../src/cutils/utils_regex.c
${CMAKE_CURRENT_SOURCE_DIR}/../../../../../src/sha256/sha256.c
${CMAKE_CURRENT_SOURCE_DIR}/../../../../../src/error.c
${CMAKE_CURRENT_SOURCE_DIR}/../../../../../src/path.c
${CMAKE_CURRENT_SOURCE_DIR}/../../../../../src/mainloop.c
${CMAKE_CURRENT_SOURCE_DIR}/../../../../../src/filters.c
${CMAKE_CURRENT_SOURCE_DIR}/../../../../../src/libisulad.c
${CMAKE_CURRENT_SOURCE_DIR}/../../../../../src/console/console.c
${CMAKE_CURRENT_SOURCE_DIR}/../../../../../src/cutils/utils.c
${CMAKE_CURRENT_SOURCE_DIR}/../../../../../src/cutils/utils_verify.c
${CMAKE_CURRENT_SOURCE_DIR}/../../../../../src/map/map.c
${CMAKE_CURRENT_SOURCE_DIR}/../../../../../src/map/rb_tree.c
${CMAKE_CURRENT_SOURCE_DIR}/../../../../../src/services/execution/execute/execution_extend.c
${CMAKE_CURRENT_SOURCE_DIR}/../../../../../src/json/oci_runtime_hooks.c
${CMAKE_CURRENT_SOURCE_DIR}/../../../../../src/json/schema/src/read_file.c
${CMAKE_CURRENT_SOURCE_DIR}/../../../../mocks/runtime_mock.cc
${CMAKE_CURRENT_SOURCE_DIR}/../../../../mocks/containers_store_mock.cc
${CMAKE_CURRENT_SOURCE_DIR}/../../../../mocks/collector_mock.cc
${CMAKE_CURRENT_SOURCE_DIR}/../../../../mocks/containers_gc_mock.cc
${CMAKE_CURRENT_SOURCE_DIR}/../../../../mocks/container_unix_mock.cc
${CMAKE_CURRENT_SOURCE_DIR}/../../../../mocks/health_check_mock.cc
${CMAKE_CURRENT_SOURCE_DIR}/../../../../mocks/image_mock.cc
${CMAKE_CURRENT_SOURCE_DIR}/../../../../mocks/isulad_config_mock.cc
${CMAKE_CURRENT_SOURCE_DIR}/../../../../mocks/sysinfo_mock.cc
${CMAKE_CURRENT_SOURCE_DIR}/../../../../mocks/container_state_mock.cc
${CMAKE_CURRENT_SOURCE_DIR}/../../../../mocks/verify_mock.cc
${CMAKE_CURRENT_SOURCE_DIR}/../../../../mocks/engine_mock.cc
${CMAKE_CURRENT_SOURCE_DIR}/../../../../mocks/driver_mock.cc
${CMAKE_CURRENT_SOURCE_DIR}/../../../../mocks/restartmanager_mock.cc
${CMAKE_CURRENT_SOURCE_DIR}/../../../../mocks/specs_mock.cc
${CMAKE_BINARY_DIR}/json/container_inspect.c
${CMAKE_BINARY_DIR}/json/oci_runtime_spec.c
${CMAKE_BINARY_DIR}/json/json_common.c
${CMAKE_BINARY_DIR}/json/container_stats_request.c
${CMAKE_BINARY_DIR}/json/container_info.c
${CMAKE_BINARY_DIR}/json/host_config.c
${CMAKE_BINARY_DIR}/json/oci_runtime_config_linux.c
${CMAKE_BINARY_DIR}/json/defs.c
${CMAKE_BINARY_DIR}/json/docker_types_mount_point.c
execution_extend_llt.cc)
target_include_directories(${EXE} PUBLIC
${GTEST_INCLUDE_DIR}
${CMAKE_CURRENT_SOURCE_DIR}/../../../../include
${CMAKE_CURRENT_SOURCE_DIR}/../../../../../src
${CMAKE_CURRENT_SOURCE_DIR}/../../../../../src/runtime
${CMAKE_CURRENT_SOURCE_DIR}/../../../../../src/cmd
${CMAKE_CURRENT_SOURCE_DIR}/../../../../../src/sha256
${CMAKE_CURRENT_SOURCE_DIR}/../../../../../src/map
${CMAKE_CURRENT_SOURCE_DIR}/../../../../../src/json
${CMAKE_CURRENT_SOURCE_DIR}/../../../../../src/engines
${CMAKE_CURRENT_SOURCE_DIR}/../../../../../src/console
${CMAKE_CURRENT_SOURCE_DIR}/../../../../../src/config
${CMAKE_CURRENT_SOURCE_DIR}/../../../../../src/cutils
${CMAKE_CURRENT_SOURCE_DIR}/../../../../../src/image
${CMAKE_CURRENT_SOURCE_DIR}/../../../../../src/image/oci
${CMAKE_CURRENT_SOURCE_DIR}/../../../../../src/services
${CMAKE_CURRENT_SOURCE_DIR}/../../../../../src/services/execution/manager
${CMAKE_CURRENT_SOURCE_DIR}/../../../../../src/services/execution/spec
${CMAKE_CURRENT_SOURCE_DIR}/../../../../../src/services/execution/events
${CMAKE_CURRENT_SOURCE_DIR}/../../../../../src/services/execution/execute
${CMAKE_CURRENT_SOURCE_DIR}/../../../../../src/services/graphdriver
${CMAKE_CURRENT_SOURCE_DIR}/../../../../../src/json/schema/src
${CMAKE_CURRENT_SOURCE_DIR}/../../../../../conf
${CMAKE_CURRENT_SOURCE_DIR}/../../../../mocks
${CMAKE_BINARY_DIR}/json
)
target_link_libraries(${EXE} ${GTEST_BOTH_LIBRARIES} ${GMOCK_LIBRARY} ${GMOCK_MAIN_LIBRARY} ${CMAKE_THREAD_LIBS_INIT} -lgrpc++ -lprotobuf -lcrypto -lyajl -lsecurec -lz)
/******************************************************************************
* Copyright (c) Huawei Technologies Co., Ltd. 2020. All rights reserved.
* iSulad licensed under the Mulan PSL v1.
* You can use this software according to the terms and conditions of the Mulan PSL v1.
* You may obtain a copy of Mulan PSL v1 at:
* http://license.coscl.org.cn/MulanPSL
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR
* PURPOSE.
* See the Mulan PSL v1 for more details.
* Author: jikui
* Create: 2020-02-25
* Description: provide execution_extend llt test
******************************************************************************/
#include "execution_extend.h"
#include <gtest/gtest.h>
#include <gmock/gmock.h>
#include "runtime_mock.h"
#include "containers_store_mock.h"
#include "container_state_mock.h"
#include "sysinfo_mock.h"
#include "health_check_mock.h"
#include "collector_mock.h"
#include "container_unix_mock.h"
#include "image_mock.h"
#include "isulad_config_mock.h"
#include "containers_gc_mock.h"
#include "engine_mock.h"
#include "driver_mock.h"
#include "restartmanager_mock.h"
#include "verify_mock.h"
#include "specs_mock.h"
#include "callback.h"
#include "utils.h"
using ::testing::Args;
using ::testing::ByRef;
using ::testing::SetArgPointee;
using ::testing::DoAll;
using ::testing::NiceMock;
using ::testing::Return;
using ::testing::NotNull;
using ::testing::AtLeast;
using ::testing::Invoke;
using ::testing::_;
using namespace std;
class ExecutionExtendUnitTest : public testing::Test {
public:
void SetUp() override
{
MockRuntime_SetMock(&m_runtime);
MockContainersStore_SetMock(&m_containersStore);
MockCollector_SetMock(&m_collector);
MockContainersGc_SetMock(&m_containersGc);
MockContainerUnix_SetMock(&m_containerUnix);
MockHealthCheck_SetMock(&m_healthCheck);
MockIsuladConf_SetMock(&m_isuladConf);
MockImage_SetMock(&m_image);
MockSysinfo_SetMock(&m_sysinfo);
MockEngine_SetMock(&m_engine);
MockDriver_SetMock(&m_driver);
MockVerify_SetMock(&m_verify);
MockRestartmanager_SetMock(&m_restartmanager);
MockContainerState_SetMock(&m_containerState);
MockSpecs_SetMock(&m_specs);
::testing::Mock::AllowLeak(&m_runtime);
::testing::Mock::AllowLeak(&m_containersStore);
::testing::Mock::AllowLeak(&m_collector);
::testing::Mock::AllowLeak(&m_containersGc);
::testing::Mock::AllowLeak(&m_containerUnix);
::testing::Mock::AllowLeak(&m_healthCheck);
::testing::Mock::AllowLeak(&m_image);
::testing::Mock::AllowLeak(&m_isuladConf);
::testing::Mock::AllowLeak(&m_sysinfo);
::testing::Mock::AllowLeak(&m_engine);
::testing::Mock::AllowLeak(&m_driver);
::testing::Mock::AllowLeak(&m_restartmanager);
::testing::Mock::AllowLeak(&m_containerState);
::testing::Mock::AllowLeak(&m_verify);
::testing::Mock::AllowLeak(&m_specs);
}
void TearDown() override
{
MockRuntime_SetMock(nullptr);
MockContainersStore_SetMock(nullptr);
MockCollector_SetMock(nullptr);
MockContainersGc_SetMock(nullptr);
MockContainerUnix_SetMock(nullptr);
MockHealthCheck_SetMock(nullptr);
MockImage_SetMock(nullptr);
MockIsuladConf_SetMock(nullptr);
MockSysinfo_SetMock(nullptr);
MockEngine_SetMock(nullptr);
MockDriver_SetMock(nullptr);
MockRestartmanager_SetMock(nullptr);
MockContainerState_SetMock(nullptr);
MockVerify_SetMock(nullptr);
MockSpecs_SetMock(nullptr);
}
NiceMock<MockRuntime> m_runtime;
NiceMock<MockContainersStore> m_containersStore;
NiceMock<MockCollector> m_collector;
NiceMock<MockContainersGc> m_containersGc;
NiceMock<MockContainerUnix> m_containerUnix;
NiceMock<MockHealthCheck> m_healthCheck;
NiceMock<MockImage> m_image;
NiceMock<MockIsuladConf> m_isuladConf;
NiceMock<MockSysinfo> m_sysinfo;
NiceMock<MockEngine> m_engine;
NiceMock<MockDriver> m_driver;
NiceMock<MockRestartmanager> m_restartmanager;
NiceMock<MockContainerState> m_containerState;
NiceMock<MockVerify> m_verify;
NiceMock<MockSpecs> m_specs;
};
int invokeRuntimePause(const char *name, const char *runtime, const rt_pause_params_t *params)
{
return 0;
}
int invokeRuntimeResume(const char *name, const char *runtime, const rt_resume_params_t *params)
{
return 0;
}
container_t *invokeContainersStoreGet(const char *id_or_name)
{
if (id_or_name == nullptr) {
return nullptr;
}
container_t *cont = (container_t *)util_common_calloc_s(sizeof(container_t));
cont->common_config = (container_config_v2_common_config *)util_common_calloc_s(sizeof(
container_config_v2_common_config));
return cont;
}
bool invokeGcIsGcProgress(const char *id)
{
return false;
}
int invokeContainerToDisk(const container_t *cont)
{
return 0;
}
void invokeContainerUnlock(container_t *cont)
{
return;
}
void invokeContainerLock(container_t *cont)
{
return;
}
void invokeContainerUnref(container_t *cont)
{
return;
}
void invokeUpdateHealthMonitor(const char *container_id)
{
return;
}
bool invokeIsRunning(container_state_t *s)
{
return true;
}
bool invokeIsPaused(container_state_t *s)
{
return false;
}
void invokeStateResetPaused(container_state_t *s)
{
return;
}
bool invokeIsRestarting(container_state_t *s)
{
return false;
}
void invokeContainerStateSetError(container_state_t *s, const char *err)
{
return;
}
void invokeStateSetPaused(container_state_t *s)
{
return;
}
TEST_F(ExecutionExtendUnitTest, test_container_extend_callback_init_pause)
{
service_container_callback_t cb;
container_pause_request *request = (container_pause_request*)util_common_calloc_s(sizeof(container_pause_request));
container_pause_response *response = (container_pause_response*)util_common_calloc_s(sizeof(container_pause_response));
request->id = util_strdup_s("64ff21ebf4e4");
EXPECT_CALL(m_runtime, RuntimePause(_, _, _)).WillRepeatedly(Invoke(invokeRuntimePause));
EXPECT_CALL(m_containersStore, ContainersStoreGet(_)).WillRepeatedly(Invoke(invokeContainersStoreGet));
EXPECT_CALL(m_containerState, IsRunning(_)).WillRepeatedly(Invoke(invokeIsRunning));
EXPECT_CALL(m_containersGc, GcIsGcProgress(_)).WillRepeatedly(Invoke(invokeGcIsGcProgress));
EXPECT_CALL(m_containerState, IsPaused(_)).WillRepeatedly(Invoke(invokeIsPaused));
EXPECT_CALL(m_containerState, IsRestarting(_)).WillRepeatedly(Invoke(invokeIsRestarting));
EXPECT_CALL(m_containerUnix, ContainerToDisk(_)).WillRepeatedly(Invoke(invokeContainerToDisk));
container_extend_callback_init(&cb);
ASSERT_EQ(cb.pause(request, &response), 0);
testing::Mock::VerifyAndClearExpectations(&m_runtime);
testing::Mock::VerifyAndClearExpectations(&m_containersStore);
testing::Mock::VerifyAndClearExpectations(&m_containerState);
testing::Mock::VerifyAndClearExpectations(&m_containersGc);
testing::Mock::VerifyAndClearExpectations(&m_containerUnix);
}
TEST_F(ExecutionExtendUnitTest, test_container_extend_callback_init_resume)
{
service_container_callback_t cb;
container_resume_request *request = (container_resume_request*)util_common_calloc_s(sizeof(container_resume_request));
container_resume_response *response = (container_resume_response*)util_common_calloc_s(sizeof(
container_resume_response));
request->id = util_strdup_s("64ff21ebf4e4");
EXPECT_CALL(m_runtime, RuntimeResume(_, _, _)).WillRepeatedly(Invoke(invokeRuntimeResume));
EXPECT_CALL(m_containersStore, ContainersStoreGet(_)).WillRepeatedly(Invoke(invokeContainersStoreGet));
EXPECT_CALL(m_containerState, IsRunning(_)).WillRepeatedly(Invoke(invokeIsRunning));
EXPECT_CALL(m_containersGc, GcIsGcProgress(_)).WillRepeatedly(Invoke(invokeGcIsGcProgress));
EXPECT_CALL(m_containerState, IsPaused(_)).WillOnce(Return(true));
EXPECT_CALL(m_containerUnix, ContainerToDisk(_)).WillRepeatedly(Invoke(invokeContainerToDisk));
container_extend_callback_init(&cb);
ASSERT_EQ(cb.resume(request, &response), 0);
testing::Mock::VerifyAndClearExpectations(&m_runtime);
testing::Mock::VerifyAndClearExpectations(&m_containersStore);
testing::Mock::VerifyAndClearExpectations(&m_containerState);
testing::Mock::VerifyAndClearExpectations(&m_containersGc);
testing::Mock::VerifyAndClearExpectations(&m_containerUnix);
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册