* [misc] Enhance unit tests for instanceModel::updateMemorySize() method
🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -792,4 +792,18 @@ class instanceTest
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Test updateMemorySize method.
|
||||
*
|
||||
* @param object $instance
|
||||
* @param int $size
|
||||
* @access public
|
||||
* @return mixed
|
||||
*/
|
||||
public function updateMemorySizeTest(object $instance, int $size = 0)
|
||||
{
|
||||
$result = $this->objectModel->updateMemorySize($instance, $size);
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
@@ -1,27 +1,47 @@
|
||||
#!/usr/bin/env php
|
||||
<?php
|
||||
include dirname(__FILE__, 5) . '/test/lib/init.php';
|
||||
su('admin');
|
||||
|
||||
zenData('instance')->loadYaml('instance')->gen(5);
|
||||
zenData('space')->loadYaml('space')->gen(5);
|
||||
|
||||
/**
|
||||
|
||||
title=instanceModel->updateMemorySize();
|
||||
title=测试 instanceModel::updateMemorySize();
|
||||
timeout=0
|
||||
cid=1
|
||||
cid=0
|
||||
|
||||
- 编辑应用的内存,查看返回结果 @0
|
||||
- 调整内存失败,查看错误信息: @调整内存失败
|
||||
- 执行instanceTest模块的updateMemorySizeTest方法,参数是$instance1, 1024 @0
|
||||
- 执行instanceTest模块的updateMemorySizeTest方法,参数是$instance2, 0 @0
|
||||
- 执行instanceTest模块的updateMemorySizeTest方法,参数是$instance3, 2048 @0
|
||||
- 执行instanceTest模块的updateMemorySizeTest方法,参数是$instance4, 4096 @0
|
||||
- 执行 @调整内存失败
|
||||
|
||||
*/
|
||||
|
||||
global $tester;
|
||||
$tester->loadModel('instance');
|
||||
include dirname(__FILE__, 5) . '/test/lib/init.php';
|
||||
include dirname(__FILE__, 2) . '/lib/instance.unittest.class.php';
|
||||
|
||||
$instance = $tester->instance->getByID(1);
|
||||
$instance->oldValue = 0;
|
||||
zenData('instance')->loadYaml('instance_updatememorysize', false, 2)->gen(5);
|
||||
zenData('space')->loadYaml('space')->gen(5);
|
||||
|
||||
r($tester->instance->updateMemorySize($instance, 1024)) && p('') && e('0'); // 编辑应用的内存,查看返回结果
|
||||
r(dao::getError()) && p('0') && e('调整内存失败'); // 调整内存失败,查看错误信息:
|
||||
su('admin');
|
||||
|
||||
$instanceTest = new instanceTest();
|
||||
|
||||
$instance1 = $instanceTest->objectModel->getByID(1);
|
||||
$instance1->oldValue = 512;
|
||||
|
||||
$instance2 = $instanceTest->objectModel->getByID(2);
|
||||
$instance2->oldValue = 1024;
|
||||
|
||||
$instance3 = $instanceTest->objectModel->getByID(3);
|
||||
$instance3->oldValue = 2048;
|
||||
|
||||
$instance4 = $instanceTest->objectModel->getByID(4);
|
||||
$instance4->oldValue = 1024;
|
||||
|
||||
$instance5 = $instanceTest->objectModel->getByID(5);
|
||||
$instance5->oldValue = 512;
|
||||
|
||||
r($instanceTest->updateMemorySizeTest($instance1, 1024)) && p() && e('0');
|
||||
r($instanceTest->updateMemorySizeTest($instance2, 0)) && p() && e('0');
|
||||
r($instanceTest->updateMemorySizeTest($instance3, 2048)) && p() && e('0');
|
||||
r($instanceTest->updateMemorySizeTest($instance4, 4096)) && p() && e('0');
|
||||
r(dao::getError()) && p('0') && e('调整内存失败');
|
||||
@@ -0,0 +1,39 @@
|
||||
title: table zt_instance for updateMemorySize test
|
||||
desc: "内存大小调整测试数据"
|
||||
author: Claude
|
||||
version: "1.0"
|
||||
fields:
|
||||
- field: id
|
||||
range: 1-5
|
||||
- field: space
|
||||
range: 1-3
|
||||
- field: solution
|
||||
range: 1-3
|
||||
- field: name
|
||||
range: "test-app-1,test-app-2,test-app-3,memory-test-app,high-memory-app"
|
||||
- field: appVersion
|
||||
range: "1.0.0,2.0.0,3.0.0"
|
||||
- field: chart
|
||||
range: "zentao,adminer,gitlab"
|
||||
- field: logo
|
||||
range: "img.qucheng.com/app/z/zentao-icon.svg"
|
||||
- field: version
|
||||
range: "2023.12.1201,2023.12.1202,2023.12.1203"
|
||||
- field: desc
|
||||
range: "Memory test application for unit testing"
|
||||
- field: source
|
||||
range: 'cloud'
|
||||
- field: channel
|
||||
range: 'stable'
|
||||
- field: status
|
||||
range: running{3},stopped{1},abnormal{1}
|
||||
- field: domain
|
||||
range: 'test1.dops.corp.cc,test2.dops.corp.cc,test3.dops.corp.cc,memory-test.dops.corp.cc,high-mem.dops.corp.cc'
|
||||
- field: k8name
|
||||
range: 'test-app-1,test-app-2,test-app-3,memory-test,high-memory'
|
||||
- field: createdBy
|
||||
range: 'admin'
|
||||
- field: createdDate
|
||||
range: (w)-(-1w)
|
||||
- field: oldValue
|
||||
range: 512,1024,2048,4096,8192
|
||||
Reference in New Issue
Block a user