#1503 Simplify environment for beaker tests
Merged 3 years ago by praiskup. Opened 3 years ago by praiskup.
Unknown source simplify-docker-testing  into  master

@@ -1,28 +1,22 @@

  FROM fedora:32

+ ARG COPR_PACKAGES=devel

  MAINTAINER copr-devel@lists.fedorahosted.org

- 

  ENV container docker

- RUN dnf -y update

- RUN dnf -y install systemd

- RUN (cd /lib/systemd/system/sysinit.target.wants/; for i in *; do [ $i == systemd-tmpfiles-setup.service ] || rm -f $i; done); \

- rm -f /lib/systemd/system/multi-user.target.wants/*;\

- rm -f /etc/systemd/system/*.wants/*;\

- rm -f /lib/systemd/system/local-fs.target.wants/*; \

- rm -f /lib/systemd/system/sockets.target.wants/*udev*; \

- rm -f /lib/systemd/system/sockets.target.wants/*initctl*; \

- rm -f /lib/systemd/system/basic.target.wants/*;\

- rm -f /lib/systemd/system/anaconda.target.wants/*;

- VOLUME ["/sys/fs/cgroup"]

- 

- RUN dnf -y install dnf-plugins-core && dnf -y copr enable @copr/copr

- RUN dnf -y install htop wget net-tools iputils vim mlocate git sudo openssh-server psmisc python-jedi procps-ng findutils tmux expect

- RUN for repo in fedora updates updates-testing; do \

-     dnf -y config-manager --save --setopt $repo.excludepkgs=hello ; done

  

- # Sanity tests

- RUN wget https://beaker-project.org/yum/beaker-client-Fedora.repo -P /etc/yum.repos.d

+ RUN dnf -y update \

+     && dnf -y install dnf-plugins-core wget \

+     && wget https://beaker-project.org/yum/beaker-client-Fedora.repo -P /etc/yum.repos.d \

+     && dnf -y copr enable @copr/copr \

+     && if test "$COPR_PACKAGES" = devel; then dnf -y copr enable @copr/copr-dev; fi \

+     && dnf -y install htop net-tools iputils vim mlocate git sudo \

+               openssh-server psmisc python-jedi procps-ng findutils tmux \

+               expect \

+     && dnf -y install python3-copr rpm-build copr-cli jq \

+     && dnf -y install rhts-test-env beakerlib \

+     && dnf -y clean all

  

- RUN dnf -y install rhts-test-env beakerlib

+ RUN for repo in fedora updates updates-testing; do \

+     dnf -y config-manager --save --setopt $repo.excludepkgs=hello ; done

  

  RUN echo "LANG=en_US.UTF-8" >> /etc/locale

  RUN setcap cap_net_raw,cap_net_admin+p /usr/bin/ping
@@ -33,4 +27,11 @@

  RUN echo 'export LANG=en_US.UTF-8' >> /root/.bashrc

  RUN echo 'set -g history-limit 40960' > /root/.tmux.conf

  

+ COPY bashrc /root/.bashrc_copr

+ 

+ RUN echo "source /root/.bashrc_copr" >> /root/.bashrc

+ 

+ RUN echo -e "[tested-copr]\nhostname = copr-fe-dev.cloud.fedoraproject.org\nprotocol = https\nport = 443\n" \

+     >  /etc/dnf/plugins/copr.d/tested-copr.conf

+ 

  CMD ["/usr/bin/sleep", "infinity"]

@@ -9,9 +9,7 @@

  

  run:

  	docker run \

- 		--privileged \

  		-dit \

- 		-v /sys/fs/cgroup:/sys/fs/cgroup:ro \

  		-v $(mkfile_path)/../../../copr:/root/copr \

  		--name="test-env" \

  		-h test-env \

@@ -0,0 +1,19 @@

+ # This file is sourced in /root/.bashrc inside the container

+ 

+ if ! test -f "$HOME/.config/copr"; then

+     echo

+     echo "Please obtain your personal API config from"

+     echo "https://YOUR_COPR_HOST/api/"

+     echo "and paste it to the ~/.config/copr"

+     echo

+     mkdir -p "$HOME/.config"

+ else

+     echo

+     echo "There's $HOME/.config/copr pre-configured, may need edits."

+ fi

+ 

+ echo "There's /etc/dnf/plugins/copr.d/tested-copr.conf, may need manual edits"

+ echo

+ 

+ # most of the time we want to be in this directory

+ cd /root/copr/beaker-tests/Sanity/copr-cli-basic-operations || :

@@ -1,62 +0,0 @@

- # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

- #

- #   Makefile of /tools/tests/Install/Config-copr-cli

- #   Description: Install copr-cli and configure it.

- #   Author: Miroslav Suchy <msuchy@redhat.com>

- #

- # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

- #

- #   Copyright (c) 2014 Red Hat, Inc.

- #

- #   This program is free software: you can redistribute it and/or

- #   modify it under the terms of the GNU General Public License as

- #   published by the Free Software Foundation, either version 2 of

- #   the License, or (at your option) any later version.

- #

- #   This program is distributed in the hope that it will be

- #   useful, but WITHOUT ANY WARRANTY; without even the implied

- #   warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR

- #   PURPOSE.  See the GNU General Public License for more details.

- #

- #   You should have received a copy of the GNU General Public License

- #   along with this program. If not, see http://www.gnu.org/licenses/.

- #

- # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

- 

- export TEST=/tools/tests/Install/Config-copr-cli

- export TESTVERSION=1.0

- 

- BUILT_FILES=

- 

- FILES=$(METADATA) runtest.sh Makefile PURPOSE copr-dev.repo copr.repo config

- 

- .PHONY: all install download clean

- 

- run: $(FILES) build

- 	./runtest.sh

- 

- build: $(BUILT_FILES)

- 	test -x runtest.sh || chmod a+x runtest.sh

- 

- clean:

- 	rm -f *~ $(BUILT_FILES)

- 

- 

- include /usr/share/rhts/lib/rhts-make.include

- 

- $(METADATA): Makefile

- 	@echo "Owner:           Miroslav Suchy <msuchy@redhat.com>" > $(METADATA)

- 	@echo "Name:            $(TEST)" >> $(METADATA)

- 	@echo "TestVersion:     $(TESTVERSION)" >> $(METADATA)

- 	@echo "Path:            $(TEST_DIR)" >> $(METADATA)

- 	@echo "Description:     Install copr-cli and configure it." >> $(METADATA)

- 	@echo "Type:            Install" >> $(METADATA)

- 	@echo "TestTime:        10m" >> $(METADATA)

- 	@echo "RunFor:          tests" >> $(METADATA)

- 	@echo "Requires:        tests" >> $(METADATA)

- 	@echo "Priority:        Normal" >> $(METADATA)

- 	@echo "License:         GPLv2+" >> $(METADATA)

- 	@echo "Confidential:    no" >> $(METADATA)

- 	@echo "Destructive:     no" >> $(METADATA)

- 

- 	rhts-lint $(METADATA)

@@ -1,3 +0,0 @@

- PURPOSE of /tools/tests/Install/Config-copr-cli

- Description: Install copr-cli and configure it.

- Author: Miroslav Suchy <msuchy@redhat.com>

@@ -1,6 +0,0 @@

- [msuchy-copr-dev]

- name=Copr repo for copr-dev owned by msuchy

- baseurl=https://copr-be.cloud.fedoraproject.org/results/@copr/copr-dev/fedora-$releasever-$basearch/

- skip_if_unavailable=True

- gpgcheck=0

- enabled=1

@@ -1,6 +0,0 @@

- [msuchy-copr]

- name=Copr repo for copr owned by msuchy

- baseurl=https://copr-be.cloud.fedoraproject.org/results/@copr/copr/fedora-$releasever-$basearch/

- skip_if_unavailable=True

- gpgcheck=0

- enabled=1

@@ -1,71 +0,0 @@

- #!/bin/bash

- # vim: dict=/usr/share/beakerlib/dictionary.vim cpt=.,w,b,u,t,i,k

- # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

- #

- #   runtest.sh of /tools/tests/Install/Config-copr-cli

- #   Description: Install copr-cli and configure it.

- #   Author: Miroslav Suchy <msuchy@redhat.com>

- #

- # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

- #

- #   Copyright (c) 2014 Red Hat, Inc.

- #

- #   This program is free software: you can redistribute it and/or

- #   modify it under the terms of the GNU General Public License as

- #   published by the Free Software Foundation, either version 2 of

- #   the License, or (at your option) any later version.

- #

- #   This program is distributed in the hope that it will be

- #   useful, but WITHOUT ANY WARRANTY; without even the implied

- #   warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR

- #   PURPOSE.  See the GNU General Public License for more details.

- #

- #   You should have received a copy of the GNU General Public License

- #   along with this program. If not, see http://www.gnu.org/licenses/.

- #

- # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

- 

- # Include Beaker environment

- . /usr/bin/rhts-environment.sh || exit 1

- . /usr/share/beakerlib/beakerlib.sh || exit 1

- 

- HERE=$(dirname "$(realpath "$0")")

- PACKAGE="tests"

- 

- rlJournalStart

-     rlPhaseStartSetup

-         if [[ ! $RELEASETEST ]]; then

-             rlLog "Installing copr dev repos."

-             cp "$HERE/copr-dev.repo" /etc/yum.repos.d/

-         fi

-         rlLog "Installing copr production repos."

-         cp "$HERE/copr.repo" /etc/yum.repos.d/

-         mkdir -p ~/.config || :

-         rlRun "dnf config-manager --set-enabled fedora --save"

-         rlRun "dnf install -y python3-copr copr-cli"

-         rlRun "dnf upgrade -y python3-copr copr-cli"

-         rlRun "dnf install -y rpm-build jq"

- 

-         cat > /etc/dnf/plugins/copr.d/tested-copr.conf <<EOF

- [tested-copr]

- hostname = copr-fe-dev.cloud.fedoraproject.org

- protocol = https

- port = 443

- EOF

- 

-         rlAssertRpm copr-cli

-     rlPhaseEnd

- 

- rlJournalPrintText

- rlJournalEnd

- 

- echo "A manual work is required!"

- echo "Please obtain your personal API config from"

- echo "https://YOUR_COPR_HOST/api/"

- echo "and paste it to the ~/.config/copr"

- echo

- echo "Create /etc/dnf/plugins/copr.d/tested-copr.conf with contents:"

- echo [tested-copr]

- echo hostname = YOUR_COPR_HOST

- echo protocol = https

- echo port = 443

file modified
+6 -3
@@ -80,7 +80,10 @@

  

  - rhts-test-env

  - beakerlib

+ - rpm-build

+ - jq

+ - python3-copr and copr-cli (tested version)

  

- Next, you cannot run Sanity/copr-cli-basic-operations/runtest.sh without first running

- Install/Config-copr-cli/runtest.sh which needs root access to setup the system into the

- required state. That's why you might want to run the test inside a container or vm.

+ Next, you cannot run Sanity/copr-cli-basic-operations/runtest.sh which needs

+ a root access for many tasks.  That's why you might want to run the test inside

+ a container or vm (see DockerTestEnv docs above).

file modified
-4
@@ -37,10 +37,6 @@

  

  ::

  

-     # Install dependencies and configure copr-cli

-     [root@test-env ~] cd ~/copr/beaker-tests/Install/Config-copr-cli

-     [root@test-env Config-copr-cli] ./runtest.sh

- 

      # Set your API token and Copr URL

      [root@test-env ~] vim ~/.config/copr

  

no initial comment

Did you want to use $HOME here or the /root is intentional? Doesn't particularly matter though.

I am not sure what all places where the usage is documented are, but I usually use this page as a reference about how to run beaker tests https://docs.pagure.org/copr.copr/sanity_tests.html

Don't mind the title, there are only two steps related to running the beaker against a local instance, except for them it is a good guide for running them generally.

Can you please update it accordingly to this PR changes?

Did you want to use $HOME here or the /root is intentional? Doesn't particularly matter though.

I didn't pay too much attention to it, thanks. I'll fix this.

Can you please update it accordingly to this PR changes?

Sure. Thank you for the hint.

rebased onto 90fc1e6

3 years ago

2 new commits added

  • beaker, doc: move Install/*/runtest.sh into an image
  • beaker: minimize docker environment image
3 years ago

I forgot to install dnf-plugins-core config file, fixed. Sorry for another turnaround.

Np. I haven't fetched and tested the code, but it looks good to me,
+1

Pull-Request has been merged by praiskup

3 years ago