mirror of
https://github.com/ostreedev/ostree.git
synced 2024-12-22 17:35:55 +03:00
ci: Test for clock skew
I saw `tests/test-admin-deploy.none.sh` fail in one CI run, and I want to check if it was because of clock skew, so fail fast if we detect that. xref https://github.com/ostreedev/ostree/pull/2099#issuecomment-629805375
This commit is contained in:
parent
0d7132ec79
commit
f14aa894d3
@ -306,6 +306,8 @@ prev_rev=$(${CMD_PREFIX} ostree rev-parse --repo=sysroot/ostree/repo testos/buil
|
|||||||
assert_not_streq ${head_rev} ${prev_rev}
|
assert_not_streq ${head_rev} ${prev_rev}
|
||||||
# check that we can't "upgrade" to an older commit without --allow-downgrade
|
# check that we can't "upgrade" to an older commit without --allow-downgrade
|
||||||
if ${CMD_PREFIX} ostree admin upgrade --os=testos --override-commit=${prev_rev} 2> err.txt; then
|
if ${CMD_PREFIX} ostree admin upgrade --os=testos --override-commit=${prev_rev} 2> err.txt; then
|
||||||
|
${CMD_PREFIX} ostree --repo=sysroot/ostree/repo show "${prev_rev}"
|
||||||
|
${CMD_PREFIX} ostree --repo=sysroot/ostree/repo show "${head_rev}"
|
||||||
fatal "downgraded without --allow-downgrade?"
|
fatal "downgraded without --allow-downgrade?"
|
||||||
fi
|
fi
|
||||||
assert_file_has_content err.txt "Upgrade.*is chronologically older"
|
assert_file_has_content err.txt "Upgrade.*is chronologically older"
|
||||||
|
@ -488,6 +488,11 @@ EOF
|
|||||||
cd ${oldpwd}
|
cd ${oldpwd}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
timestamp_of_commit()
|
||||||
|
{
|
||||||
|
date --date="$(ostree --repo=$1 show $2 | grep -Ee '^Date: ' | sed -e 's,^Date: *,,')" '+%s'
|
||||||
|
}
|
||||||
|
|
||||||
os_repository_new_commit ()
|
os_repository_new_commit ()
|
||||||
{
|
{
|
||||||
boot_checksum_iteration=${1:-0}
|
boot_checksum_iteration=${1:-0}
|
||||||
@ -529,6 +534,13 @@ os_repository_new_commit ()
|
|||||||
echo "content iteration ${content_iteration}" > usr/bin/content-iteration
|
echo "content iteration ${content_iteration}" > usr/bin/content-iteration
|
||||||
|
|
||||||
${CMD_PREFIX} ostree --repo=${test_tmpdir}/testos-repo commit --add-metadata-string "version=${version}" -b $branch -s "Build"
|
${CMD_PREFIX} ostree --repo=${test_tmpdir}/testos-repo commit --add-metadata-string "version=${version}" -b $branch -s "Build"
|
||||||
|
if ${CMD_PREFIX} ostree --repo=${test_tmpdir}/testos-repo rev-parse ${branch} 2>/dev/null; then
|
||||||
|
prevdate=$(timestamp_of_commit ${test_tmpdir}/testos-repo "${branch}"^)
|
||||||
|
newdate=$(timestamp_of_commit ${test_tmpdir}/testos-repo "${branch}")
|
||||||
|
if [ $((${prevdate} > ${newdate})) = 1 ]; then
|
||||||
|
fatal "clock skew detected writing commits: prev=${prevdate} new=${newdate}"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
cd ${test_tmpdir}
|
cd ${test_tmpdir}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user