Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tests/installed: Make reboot task less racy #1548

Closed
wants to merge 7 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions src/ostree/ot-builtin-fsck.c
Original file line number Diff line number Diff line change
Expand Up @@ -99,9 +99,16 @@ fsck_one_object (OstreeRepo *repo,
for (i = 0; parent_commits[i] != NULL; i++)
{
const char *parent_commit = parent_commits[i];
g_printerr ("Marking commit %s as partial\n", parent_commit);
if (!ostree_repo_mark_commit_partial (repo, parent_commit, TRUE, error))
OstreeRepoCommitState state;
if (!ostree_repo_load_commit (repo, parent_commit, NULL,
&state, error))
return FALSE;
if ((state & OSTREE_REPO_COMMIT_STATE_PARTIAL) == 0)
{
g_printerr ("Marking commit as partial: %s\n", parent_commit);
if (!ostree_repo_mark_commit_partial (repo, parent_commit, TRUE, error))
return FALSE;
}
}
}
}
Expand Down
3 changes: 2 additions & 1 deletion tests/installed/execute_batch.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,5 @@
loop_var: "async_result_item"
register: async_poll_results
until: async_poll_results.finished
retries: 240
retries: 500
retry_pause: 5
12 changes: 9 additions & 3 deletions tests/installed/nondestructive/itest-pull.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@

set -xeuo pipefail

# FIXME: https://github.com/ostreedev/ostree/pull/1548
exit 0

dn=$(dirname $0)
. ${dn}/../libinsttest.sh
date
Expand Down Expand Up @@ -35,12 +38,15 @@ echo "ok pull"
# fsck marks commits partial
# https://github.com/ostreedev/ostree/pull/1533
for d in $(find bare-repo/objects/ -maxdepth 1 -type d); do
(find ${d} -name '*.file' || true) | head -20 | xargs rm -vf
(find ${d} -name '*.file' || true) | head -20 | xargs rm -f
done
if ostree --repo=bare-repo fsck; then
date
if ostree --repo=bare-repo fsck |& tee fsck.txt; then
fatal "fsck unexpectedly succeeded"
fi
ostree --repo=bare-repo pull origin ${host_nonremoteref}
date
assert_streq $(grep -cE -e 'Marking commit as partial' fsck.txt) "1"
log_timestamps ostree --repo=bare-repo pull origin ${host_nonremoteref}
# Don't need a full fsck here
ostree --repo=bare-repo ls origin:${host_nonremoteref} >/dev/null

Expand Down
2 changes: 2 additions & 0 deletions tests/installed/playbook-run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,6 @@ rpm -q standard-test-roles

export ANSIBLE_INVENTORY=${ANSIBLE_INVENTORY:-$(test -e inventory && echo inventory || echo /usr/share/ansible/inventory)}
ls -al /dev/kvm
# Sadly having this on makes the reboot playbook break
export ANSIBLE_SSH_ARGS='-o ControlMaster=no'
exec ansible-playbook --tags=atomic "$@"
37 changes: 19 additions & 18 deletions tests/installed/tasks/reboot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,34 +33,35 @@
command: cat /proc/sys/kernel/random/boot_id
register: orig_bootid

# Stop sshd (thus preventing new connections) and kill our current user's
# connection so that we can't race to get back in to the system while it's
# shutting down
- name: restart hosts
when: (not skip_shutdown is defined) or (not skip_shutdown)
shell: sleep 3 && shutdown -r now
shell: |
systemctl stop sshd
systemd-run --on-active=5 systemctl reboot
async: 1
poll: 0
ignore_errors: true

# NB: The following tasks use local actions, so we need to explicitly ensure
# that they don't use sudo, which may require a password, and is not necessary
# anyway.
# NB: The wait_for is executed locally and doesn't require privs, so avoid sudo
- debug:
msg: "Waiting for reboot: {{ ansible_date_time.iso8601 }}"
- wait_for_connection:
delay: 5
timeout: 120
search_regex: "OpenSSH"
- debug:
msg: "SSH port is up {{ ansible_date_time.iso8601 }}"

- name: wait for hosts to come back up
local_action:
wait_for host={{ real_ansible_host }}
port={{ real_ansible_port | default('22') }}
state=started
delay=30
timeout={{ timeout }}
search_regex="OpenSSH"
become: false

# I'm not sure the retries are even necessary, but I'm keeping them in
- name: Wait until bootid changes
- name: Assert that the bootid changed
command: cat /proc/sys/kernel/random/boot_id
register: new_bootid
until: new_bootid.stdout != orig_bootid.stdout
retries: 6
delay: 10
- assert:
that:
- new_bootid.stdout != orig_bootid.stdout

# provide an empty iterator when a list is not provided
# http://docs.ansible.com/ansible/playbooks_conditionals.html#loops-and-conditionals
Expand Down
4 changes: 2 additions & 2 deletions tests/test-corruption.sh
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ if $OSTREE fsck -q 2>err.txt; then
assert_not_reached "fsck unexpectedly succeeded"
fi
assert_file_has_content_literal err.txt "Object missing:"
assert_file_has_content_literal err.txt "Marking commit $rev as partial"
assert_file_has_content_literal err.txt "Marking commit as partial: $rev"
assert_has_file repo/state/${rev}.commitpartial

echo "ok missing file"
Expand All @@ -125,7 +125,7 @@ if $OSTREE fsck -q --delete 2>err.txt; then
assert_not_reached "fsck unexpectedly succeeded"
fi
assert_file_has_content_literal err.txt "Corrupted file object;"
assert_file_has_content_literal err.txt "Marking commit $rev as partial"
assert_file_has_content_literal err.txt "Marking commit as partial: $rev"
assert_has_file repo/state/${rev}.commitpartial

echo "ok corrupt file"