-
Notifications
You must be signed in to change notification settings - Fork 123
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Test the
become
key under virtual
provision
Signed-off-by: Carlos Rodriguez-Fernandez <[email protected]>
- Loading branch information
1 parent
e47ebda
commit 64266b4
Showing
7 changed files
with
62 additions
and
45 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
FROM quay.io/fedora/fedora:latest | ||
|
||
RUN useradd user; usermod -aG wheel user; echo -e 'user\tALL=(ALL)\tNOPASSWD: ALL' >> /etc/sudoers | ||
RUN useradd fedora; usermod -aG wheel fedora; echo -e 'fedora\tALL=(ALL)\tNOPASSWD: ALL' >> /etc/sudoers | ||
|
||
USER user | ||
USER fedora |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,14 @@ | ||
provision: | ||
how: container | ||
image: localhost/become-container-test:latest | ||
user: user | ||
user: fedora | ||
adjust: | ||
- when: provisiontest == virtual | ||
provision+: | ||
how: virtual | ||
image: fedora | ||
- when: provisiontest == container | ||
provision+: | ||
how: container | ||
image: localhost/become-container-test:latest | ||
|
||
execute: | ||
how: tmt |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
#!/bin/bash -e | ||
|
||
test "$(whoami)" == "user" | ||
test "$(whoami)" == "fedora" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,4 +12,4 @@ | |
discover: | ||
tests: | ||
- name: user-is-user | ||
test: test "$(whoami)" == "user" | ||
test: test "$(whoami)" == "fedora" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,5 @@ | ||
summary: Check that become works | ||
description: As for now covers podman provision only. | ||
summary: Check that become works on virtual and container provision | ||
description: Ensures that become works when used in virtual instances and on containers. | ||
tag+: [provision-virtual,provision-container] | ||
duration: 20m | ||
tier: null |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,45 +1,52 @@ | ||
#!/bin/bash | ||
. /usr/share/beakerlib/beakerlib.sh || exit 1 | ||
|
||
PROVISION_METHODS=${PROVISION_METHODS:-container} | ||
PROVISION_METHODS=${PROVISION_METHODS:-container virtual} | ||
|
||
rlJournalStart | ||
if [[ "$PROVISION_METHODS" =~ container ]]; then | ||
rlPhaseStartSetup | ||
rlRun "pushd data" | ||
|
||
rlPhaseStartSetup | ||
rlRun "pushd data" | ||
if [[ "$PROVISION_METHODS" =~ "container" ]]; then | ||
# Try several times to build the container | ||
# https:/teemtee/tmt/issues/2063 | ||
build="podman build -t become-container-test:latest ." | ||
rlRun "rlWaitForCmd '$build' -m 5 -d 5" || rlDie "Unable to prepare the image" | ||
rlPhaseEnd | ||
|
||
rlPhaseStartTest "Container, test with become=true" | ||
rlRun "tmt run -rvvv plan --name /test/root" | ||
rlPhaseEnd | ||
|
||
rlPhaseStartTest "Container, test with become=false" | ||
rlRun "tmt run -rvvv plan --name /test/user" | ||
rlPhaseEnd | ||
|
||
rlPhaseStartTest "Container, prepare/finish inline with become=true" | ||
rlRun "tmt run -rvvv plan --name /prepare-finish/root/inline" | ||
rlPhaseEnd | ||
|
||
rlPhaseStartTest "Container, prepare/finish inline with become=false" | ||
rlRun "tmt run -rvvv plan --name /prepare-finish/user/inline" | ||
rlPhaseEnd | ||
|
||
rlPhaseStartTest "Container, prepare/finish scripts with become=true" | ||
rlRun "tmt run -rvvv plan --name /prepare-finish/root/scripts" | ||
rlPhaseEnd | ||
|
||
rlPhaseStartTest "Container, prepare/finish scripts with become=false" | ||
rlRun "tmt run -rvvv plan --name /prepare-finish/user/scripts" | ||
rlPhaseEnd | ||
|
||
rlPhaseStartCleanup | ||
rlRun "popd" | ||
fi | ||
rlPhaseEnd | ||
|
||
for method in ${PROVISION_METHODS}; do | ||
if [ "$method" = "container" ] || [ "$method" = "virtual" ]; then | ||
rlPhaseStartTest "$method, test with become=true" | ||
rlRun "tmt --context provisiontest=$method run -rvvv plan --name /test/root" | ||
rlPhaseEnd | ||
|
||
rlPhaseStartTest "$method, test with become=false" | ||
rlRun "tmt --context provisiontest=$method run -rvvv plan --name /test/user" | ||
rlPhaseEnd | ||
|
||
rlPhaseStartTest "$method, prepare/finish inline with become=true" | ||
rlRun "tmt --context provisiontest=$method run -rvvv plan --name /prepare-finish/root/inline" | ||
rlPhaseEnd | ||
|
||
rlPhaseStartTest "$method, prepare/finish inline with become=false" | ||
rlRun "tmt --context provisiontest=$method run -rvvv plan --name /prepare-finish/user/inline" | ||
rlPhaseEnd | ||
|
||
rlPhaseStartTest "$method, prepare/finish scripts with become=true" | ||
rlRun "tmt --context provisiontest=$method run -rvvv plan --name /prepare-finish/root/scripts" | ||
rlPhaseEnd | ||
|
||
rlPhaseStartTest "$method, prepare/finish scripts with become=false" | ||
rlRun "tmt --context provisiontest=$method run -rvvv plan --name /prepare-finish/user/scripts" | ||
rlPhaseEnd | ||
fi | ||
done | ||
|
||
rlPhaseStartCleanup | ||
rlRun "popd" | ||
if [[ "$PROVISION_METHODS" =~ "container" ]]; then | ||
rlRun "podman image rm -f localhost/become-container-test:latest" 0 "Remove custom image" | ||
rlPhaseEnd | ||
fi | ||
fi | ||
rlPhaseEnd | ||
rlJournalEnd |