修复数据库插入异常
This commit is contained in:
parent
4a6bfe4866
commit
caa7e580d2
|
@ -267,8 +267,10 @@ class Sqlite3Server(object):
|
|||
return upgradeable_pkgs,upgradeable_groups
|
||||
|
||||
# 接收更新列表与信息,生成数据并插入数据库中
|
||||
def insert_info(self, success,matedata,error_code):
|
||||
def insert_info(self, success,error_code):
|
||||
try:
|
||||
output_config_name = '/var/cache/kylin-system-updater/json/kylin-update-desktop-system.json'
|
||||
|
||||
if success:
|
||||
status = 'success'
|
||||
status_cn = '成功'
|
||||
|
@ -276,9 +278,17 @@ class Sqlite3Server(object):
|
|||
status = 'failed'
|
||||
status_cn = '失败'
|
||||
|
||||
pkgappname = matedata.get("name",{}).get("zh_CN", "")
|
||||
try:
|
||||
with open(output_config_name,'r') as f:
|
||||
matedata = json.load(f)
|
||||
except Exception as exc:
|
||||
matedata = {}
|
||||
logging.error(exc)
|
||||
|
||||
pkgappname = matedata.get("update-name",{}).get("zh_CN", "")
|
||||
logging.info(pkgappname)
|
||||
pkgversion = matedata.get("version", "")
|
||||
pkgdescription = matedata.get("description", {}).get("zh_CN", "")
|
||||
pkgdescription = matedata.get("description","")
|
||||
pkgchangelog = matedata.get("changelog", "")
|
||||
|
||||
pkgtimestr = datetime.datetime.strftime(datetime.datetime.now(), "%Y-%m-%d %H:%M:%S")
|
||||
|
|
|
@ -99,7 +99,7 @@ class UpdateManager():
|
|||
def start_deploy(self,device_status):
|
||||
try:
|
||||
def _deploy_finished(parent,trans):
|
||||
self.dbus_send.DeployUpdatFinishedNext(parent.exit,[SYSTEM_UPDATE_GROUPS],trans.available_metadata,parent.error_code)
|
||||
self.dbus_send.DeployUpdatFinishedNext(parent.exit,[SYSTEM_UPDATE_GROUPS],parent.error_code)
|
||||
|
||||
trans.deployable = False
|
||||
if parent.exit:
|
||||
|
@ -158,6 +158,7 @@ class UpdateManager():
|
|||
logging.info("Generate Jsonfile(%s) to complete... ",output_config_name)
|
||||
except Exception as e:
|
||||
logging.error(e)
|
||||
|
||||
def _check_conf_dir(self):
|
||||
# 检查var配置目录是否存在 不存在时进行创建
|
||||
VAR_CONFG_DIR = '/var/lib/kylin-system-updater'
|
||||
|
|
|
@ -224,8 +224,8 @@ class UpdateManagerDbusController(dbus.service.Object):
|
|||
logging.error(str(e))
|
||||
return self.RETURN_UNKNOWN_CODE,str(e)
|
||||
|
||||
def DeployUpdatFinishedNext(self,success,upgrade_group,metadata,error_code=''):
|
||||
self.database.insert_info(success,metadata,error_code)
|
||||
def DeployUpdatFinishedNext(self,success,upgrade_group,error_code=''):
|
||||
self.database.insert_info(success,error_code)
|
||||
self.DeployUpdatFinished(success,upgrade_group,error_code,get_error_description_from_enum(error_code))
|
||||
|
||||
@dbus.service.signal(UPDATER_DBUS_INTERFACE,signature='basss')
|
||||
|
|
|
@ -21,7 +21,9 @@ deploy_finished_signal="DeployUpdatFinished"
|
|||
CMD_PREFIX=""
|
||||
test_tmpdir="/tmp/ostree-auto-test"
|
||||
|
||||
BUILD_MASTER_BRACH="testos/buildmaster/newbranch"
|
||||
|
||||
http_port="8889"
|
||||
process_name="python3 -m http.server "$http_port
|
||||
|
||||
metadata_string="--add-metadata=update-name={\"zh_CN\":\"系统更新\",\"en_US\":\"KylinOS\"} --add-metadata=description={\"zh_CN\":\"银河麒麟V10SP1-系统更新包\",\"en_US\":\"GalaxyKylinV10SP1SystemUpdate\"} --add-metadata-string=\"icon=/usr/share/kylin-update-desktop-config/icon/kylin-update-desktop-system.png\" --add-metadata-string=changelog=\"initialcommit\" --add-metadata-string=total_download_size=\"800MB\" --add-metadata-string=total_install_size=\"1.2GB\" --add-metadata-string=update-type=\"kylin-update-desktop-system\""
|
||||
metadata_string="--add-metadata=update-name_zh_CN='系统更新' --add-metadata=update-name_en_US='dddddddddd' --add-metadata=description='GalaxyKylinV10SP1SystemUpdate' --add-metadata-string='icon=/usr/share/kylin-update-desktop-config/icon/kylin-update-desktop-system.png' --add-metadata-string=changelog='initialcommit' --add-metadata-string=total_download_size='800MB' --add-metadata-string=total_install_size='1.2GB' --add-metadata-string=update-type='kylin-update-desktop-system'"
|
||||
|
|
|
@ -3,9 +3,9 @@
|
|||
|
||||
if [ ! -d "$test_tmpdir" ]; then
|
||||
mkdir -p "$test_tmpdir"
|
||||
echo "Test directory created: $test_tmpdir"
|
||||
echo "创建测试目录: $test_tmpdir"
|
||||
else
|
||||
echo "Test directory exists and recreate: $test_tmpdir"
|
||||
echo "创建测试目录: $test_tmpdir"
|
||||
sudo chattr -R -i $test_tmpdir/* >/dev/null 2>&1 || true
|
||||
chmod -R 777 $test_tmpdir/* >/dev/null 2>&1 || true
|
||||
rm -rf $test_tmpdir
|
||||
|
@ -16,7 +16,7 @@ os_repository_new_commit ()
|
|||
{
|
||||
boot_checksum_iteration=${1:-0}
|
||||
content_iteration=${2:-0}
|
||||
branch=${3:-testos/buildmaster/x86_64-runtime}
|
||||
branch=${3:-$BUILD_MASTER_BRACH}
|
||||
export version=${4:-$(date "+%Y%m%d.${content_iteration}")}
|
||||
# echo "BOOT ITERATION: $boot_checksum_iteration"
|
||||
cd ${test_tmpdir}/osdata
|
||||
|
@ -54,7 +54,7 @@ os_repository_new_commit ()
|
|||
|
||||
echo "content iteration ${content_iteration}" > usr/bin/content-iteration
|
||||
|
||||
echo -n "Repo create new branch:$branch and commit revision:"
|
||||
echo -n "创建新分支:$branch and commit revision:"
|
||||
|
||||
${CMD_PREFIX} ostree --repo=${test_tmpdir}/testos-repo commit $metadata_string --add-metadata-string "version=${version}" -b $branch -s "Build"
|
||||
cd ${test_tmpdir}
|
||||
|
@ -90,6 +90,7 @@ setup_os_repository () {
|
|||
oldpwd=`pwd`
|
||||
|
||||
cd ${test_tmpdir}
|
||||
echo "创建远程仓库 $test_tmpdir/test-repo"
|
||||
mkdir testos-repo
|
||||
if test -n "$mode"; then
|
||||
ostree_repo_init testos-repo --mode=${mode}
|
||||
|
@ -98,6 +99,7 @@ setup_os_repository () {
|
|||
fi
|
||||
|
||||
cd ${test_tmpdir}
|
||||
echo "模拟创建最小系统 $test_tmpdir/osdata"
|
||||
mkdir osdata
|
||||
cd osdata
|
||||
kver=3.6.0
|
||||
|
@ -141,14 +143,14 @@ EOF
|
|||
mkdir -p usr/etc/testdirectory
|
||||
echo "a default daemon file" > usr/etc/testdirectory/test
|
||||
|
||||
echo -n "First commit refs:testos/buildmaster/x86_64-runtime and revision:"
|
||||
${CMD_PREFIX} ostree --repo=${test_tmpdir}/testos-repo commit --add-metadata-string new_version=1.0.9 -b testos/buildmaster/x86_64-runtime -s "Build"
|
||||
echo -n "第一次提交,分支:$BUILD_MASTER_BRACH and revision:"
|
||||
${CMD_PREFIX} ostree --repo=${test_tmpdir}/testos-repo commit --add-metadata-string new_version=1.0.9 -b $BUILD_MASTER_BRACH -s "Build"
|
||||
|
||||
# Ensure these commits have distinct second timestamps
|
||||
sleep 2
|
||||
echo "a new executable" > usr/bin/sh
|
||||
echo -n "Second commit refs:testos/buildmaster/x86_64-runtime and revision:"
|
||||
${CMD_PREFIX} ostree --repo=${test_tmpdir}/testos-repo commit --add-metadata-string new_version=1.0.10 -b testos/buildmaster/x86_64-runtime -s "Build"
|
||||
echo -n "第二次提交,分支:$BUILD_MASTER_BRACH and revision:"
|
||||
${CMD_PREFIX} ostree --repo=${test_tmpdir}/testos-repo commit --add-metadata-string new_version=1.0.10 -b $BUILD_MASTER_BRACH -s "Build"
|
||||
|
||||
cd ${test_tmpdir}
|
||||
rm -rf osdata-devel
|
||||
|
@ -157,7 +159,7 @@ EOF
|
|||
cd osdata-devel
|
||||
mkdir -p usr/include
|
||||
echo "a development header" > usr/include/foo.h
|
||||
echo -n "Third commit new refs:testos/buildmaster/x86_64-devel and revision:"
|
||||
echo -n "第三次提交,分支:testos/buildmaster/x86_64-devel and revision:"
|
||||
${CMD_PREFIX} ostree --repo=${test_tmpdir}/testos-repo commit --add-metadata-string new_version=1.0.9 -b testos/buildmaster/x86_64-devel -s "Build"
|
||||
|
||||
# 更新summary文件
|
||||
|
@ -167,6 +169,7 @@ EOF
|
|||
|
||||
cd ${test_tmpdir}
|
||||
mkdir sysroot
|
||||
echo -n "初始化部署系统,位置$test_tmpdir/sysroot "
|
||||
export OSTREE_SYSROOT=sysroot
|
||||
${CMD_PREFIX} ostree admin init-fs sysroot
|
||||
|
||||
|
@ -187,6 +190,7 @@ EOF
|
|||
;;
|
||||
esac
|
||||
|
||||
echo "创建http服务链接到当前仓库 $test_tmpdir/test-repo"
|
||||
cd ${test_tmpdir}
|
||||
mkdir ${test_tmpdir}/httpd
|
||||
cd httpd
|
||||
|
|
|
@ -5,7 +5,9 @@
|
|||
# - 在osdata目录创建模拟一些系统文件 and 提交两次到testos-repo 仓库
|
||||
# - 复制osdata数据到osdata-devel,做出修改然后再次提交
|
||||
# - 用init-fs创建sysroot 和 os-init 和 syslinux
|
||||
# - 提交一个新的commit用空目录,标记初始分支(testos/buildmaster/x86_64-runtime)为EOL 重新定向到新分支(testos/buildmaster/newbranch)
|
||||
# - 提交一个新的commit用空目录,标记初始分支($BUILD_MASTER_BRACH)为EOL 重新定向到新分支(testos/buildmaster/newbranch)
|
||||
|
||||
run_system=$(pwd)/../kylin-system-updater
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
|
@ -36,56 +38,61 @@ test_deploy_limit() {
|
|||
if [ $y -eq 0 ]; then
|
||||
y=""
|
||||
fi
|
||||
os_repository_new_commit 1 1 testos/buildmaster/newbranch$i
|
||||
echo ""
|
||||
echo "测试:从当前分支切换到新分支部署升级"
|
||||
|
||||
new_brach="testos/buildmaster/newbranch$i"
|
||||
os_repository_new_commit 1 1 $new_brach
|
||||
|
||||
mkdir empty$i
|
||||
echo -n "Refs:testos/buildmaster/x86_64-runtime and new commit revision:"
|
||||
echo -n "当前系统分支:$BUILD_MASTER_BRACH,配置切换到新分支$new_brach revision:"
|
||||
${CMD_PREFIX} ostree --repo=${test_tmpdir}/testos-repo commit --tree=dir=$(pwd)/empty$i --add-metadata-string "ostree.endoflife-rebase=testos/buildmaster/newbranch$i" -b testos/buildmaster/newbranch$y -s "EOL redirect to new branch"
|
||||
|
||||
echo ""
|
||||
echo "Ostree test environment is deployed, Start System update Fuction tested"
|
||||
echo "Ostree 测试环境创建成功, 开始系统更新功能测试"
|
||||
echo ""
|
||||
|
||||
# 检查更新
|
||||
echo "检查更新"
|
||||
sudo gdbus call --system --dest $bus_name --object-path $object_path --method $interface_name.$update_method > /dev/null
|
||||
moniter_signal_success $update_finished_signal
|
||||
|
||||
# 下载过程
|
||||
echo "部署下载"
|
||||
sudo gdbus call --system --dest $bus_name --object-path $object_path --method $interface_name.$download_method > /dev/null
|
||||
moniter_signal_success $download_finished_signal
|
||||
|
||||
# 部署
|
||||
echo "部署内容"
|
||||
sudo gdbus call --system --dest $bus_name --object-path $object_path --method $interface_name.$deploy_method > /dev/null
|
||||
moniter_signal_success $deploy_finished_signal
|
||||
|
||||
# 部署完成后的检查
|
||||
assert_file_has_content sysroot/boot/loader/entries/ostree-2-testos.conf "${bootcsum}"
|
||||
rev=$(${CMD_PREFIX} ostree --repo=${test_tmpdir}/testos-repo rev-parse $new_brach)
|
||||
assert_file_has_content sysroot/ostree/deploy/testos/deploy/${rev}.0/usr/bin/content-iteration "1"
|
||||
|
||||
assert_file_has_content sysroot/ostree/deploy/testos/deploy/${rev}.0.origin "newbranch"
|
||||
done
|
||||
}
|
||||
|
||||
# 创建仓库 仓库类型 and boot类型
|
||||
# 创建ostree仓库 仓库类型 and boot类型 包括默认开启一个远程
|
||||
setup_os_repository "archive" "syslinux"
|
||||
|
||||
cd ${test_tmpdir}
|
||||
${CMD_PREFIX} ostree --repo=sysroot/ostree/repo remote add --set=gpg-verify=false testos $(cat httpd-address)/ostree/testos-repo
|
||||
|
||||
${CMD_PREFIX} ostree --repo=sysroot/ostree/repo pull testos testos/buildmaster/x86_64-runtime > /dev/null
|
||||
rev=$(${CMD_PREFIX} ostree --repo=sysroot/ostree/repo rev-parse testos/buildmaster/x86_64-runtime)
|
||||
echo "Pull a branch(testos/buildmaster/x86_64-runtime) from remote repo and revision=${rev}"
|
||||
${CMD_PREFIX} ostree --repo=sysroot/ostree/repo pull testos $BUILD_MASTER_BRACH > /dev/null
|
||||
rev=$(${CMD_PREFIX} ostree --repo=sysroot/ostree/repo rev-parse $BUILD_MASTER_BRACH)
|
||||
echo "拉取分支:$BUILD_MASTER_BRACH 从远程仓库testos-repo and revision=${rev}"
|
||||
|
||||
${CMD_PREFIX} ostree admin deploy --karg=root=LABEL=MOO --karg=quiet --os=testos testos:testos/buildmaster/x86_64-runtime > /dev/null
|
||||
echo "部署分支:$BUILD_MASTER_BRACH"
|
||||
${CMD_PREFIX} ostree admin deploy --karg=root=LABEL=MOO --karg=quiet --os=testos testos:$BUILD_MASTER_BRACH > /dev/null
|
||||
assert_has_dir sysroot/boot/ostree/testos-${bootcsum}
|
||||
|
||||
echo "Frist deploy refs:testos/buildmaster/x86_64-runtime to success"
|
||||
|
||||
exec 3< <(/home/x/share/ostree/kylin-system-updater/backend/kylin-system-updater -r -d --sysroot=$test_tmpdir/sysroot --os=testos 2>&1)
|
||||
exec 3< <($run_system -r -d --sysroot=$test_tmpdir/sysroot --os=testos 2>&1)
|
||||
# 等待dbus服务启动
|
||||
sleep 3
|
||||
|
||||
test_deploy_limit 1
|
||||
|
||||
# 部署完成后的检查
|
||||
# assert_file_has_content sysroot/boot/loader/entries/ostree-2-testos.conf "${bootcsum}"
|
||||
# rev=$(${CMD_PREFIX} ostree --repo=${test_tmpdir}/testos-repo rev-parse testos/buildmaster/newbranch)
|
||||
# assert_file_has_content sysroot/ostree/deploy/testos/deploy/${rev}.0/usr/bin/content-iteration "1"
|
||||
|
||||
# assert_file_has_content sysroot/ostree/deploy/testos/deploy/${rev}.0.origin "newbranch"
|
||||
|
||||
echo "ok update and redirect"
|
Loading…
Reference in New Issue