From f3b3549a35218d4ad3c48616064a77ec978e822c Mon Sep 17 00:00:00 2001 From: Stephan Kulow Date: Wed, 27 Mar 2019 14:36:11 +0100 Subject: [PATCH] Rename the snapshot functions and add gocd config --- dist/package/openSUSE-release-tools.spec | 35 +--- gocd/generate.sh | 3 + gocd/totestmanager.gocd.yaml | 212 +++++++++++++++++++++++ gocd/totestmanager.gocd.yaml.erb | 27 +++ systemd/osrt-totest-manager@.service | 8 - systemd/osrt-totest-manager@.timer | 9 - ttm/manager.py | 37 ++-- 7 files changed, 262 insertions(+), 69 deletions(-) create mode 100755 gocd/generate.sh create mode 100644 gocd/totestmanager.gocd.yaml create mode 100644 gocd/totestmanager.gocd.yaml.erb delete mode 100644 systemd/osrt-totest-manager@.service delete mode 100644 systemd/osrt-totest-manager@.timer diff --git a/dist/package/openSUSE-release-tools.spec b/dist/package/openSUSE-release-tools.spec index 84126dd6..210c97a4 100644 --- a/dist/package/openSUSE-release-tools.spec +++ b/dist/package/openSUSE-release-tools.spec @@ -239,18 +239,6 @@ Requires(pre): shadow %description staging-bot Staging bot services and system user. -%package totest-manager -Summary: Manages product ToTest repository -Group: Development/Tools/Other -BuildArch: noarch -# TODO Update requirements. -Requires: osclib = %{version} -Requires: python2-openqa_client -Requires: python2-pika - -%description totest-manager -Manages product ToTest repository workflow and openQA interaction - %package pkglistgen Summary: Generates package lists in 000product Group: Development/Tools/Other @@ -424,20 +412,6 @@ exit 0 %postun staging-bot %systemd_postun -%pre totest-manager -getent passwd osrt-totest-manager > /dev/null || \ - useradd -r -m -s /sbin/nologin -c "user for openSUSE-release-tools-totest-manager" osrt-totest-manager -exit 0 - -%postun totest-manager -%systemd_postun -if [ -x /usr/bin/systemctl ] ; then - instances=($(systemctl list-units -t service --full | grep -oP osrt-totest-manager@[^.]+ || true)) - if [ ${#instances[@]} -gt 0 ] ; then - systemctl try-restart --no-block ${instances[@]} - fi -fi - %postun pkglistgen %systemd_postun @@ -466,6 +440,7 @@ fi %{_bindir}/osrt-sync-rebuild %{_bindir}/osrt-unmaintained %{_bindir}/osrt-staging-installcheck +%{_bindir}/osrt-totest-manager %{_datadir}/%{source_dir} %exclude %{_datadir}/%{source_dir}/abichecker %exclude %{_datadir}/%{source_dir}/%{announcer_filename} @@ -485,7 +460,6 @@ fi %exclude %{_datadir}/%{source_dir}/repo_checker.pl %exclude %{_datadir}/%{source_dir}/repo_checker.py %exclude %{_datadir}/%{source_dir}/suppkg_rebuild.py -%exclude %{_datadir}/%{source_dir}/totest-manager.py %exclude %{_datadir}/%{source_dir}/osclib %exclude %{_datadir}/%{source_dir}/osc-check_dups.py %exclude %{_datadir}/%{source_dir}/osc-cycle.py @@ -626,13 +600,6 @@ fi %{_unitdir}/osrt-staging-bot-support-rebuild@.service %{_unitdir}/osrt-staging-bot-support-rebuild@.timer -%files totest-manager -%defattr(-,root,root,-) -%{_bindir}/osrt-totest-manager -%{_datadir}/%{source_dir}/totest-manager.py -%{_unitdir}/osrt-totest-manager@.service -%{_unitdir}/osrt-totest-manager@.timer - %files pkglistgen %defattr(-,root,root,-) %{_bindir}/osrt-pkglistgen diff --git a/gocd/generate.sh b/gocd/generate.sh new file mode 100755 index 00000000..15f135a0 --- /dev/null +++ b/gocd/generate.sh @@ -0,0 +1,3 @@ +for file in *.erb; do + erb -T - $file > $(basename $file .erb) +done diff --git a/gocd/totestmanager.gocd.yaml b/gocd/totestmanager.gocd.yaml new file mode 100644 index 00000000..020049e9 --- /dev/null +++ b/gocd/totestmanager.gocd.yaml @@ -0,0 +1,212 @@ +format_version: 3 +pipelines: + TTM.Factory: + group: openSUSE.Checkers + lock_behavior: unlockWhenFinished + environment_variables: + OSC_CONFIG: /home/go/config/oscrc-totest-manager + materials: + script: + git: https://github.com/openSUSE/openSUSE-release-tools.git + destination: scripts + timer: + spec: 0 */15 * ? * * + only_on_changes: false + stages: + - Run: + approval: manual + resources: + - staging-bot + tasks: + - script: |- + install -D /home/go/config/openqa-client.conf /home/go/.config/openqa/client.conf + scripts/totest-manager.py -A https://api.opensuse.org --osc-debug --debug run openSUSE:Factory + TTM.Factory_ARM: + group: openSUSE.Checkers + lock_behavior: unlockWhenFinished + environment_variables: + OSC_CONFIG: /home/go/config/oscrc-totest-manager + materials: + script: + git: https://github.com/openSUSE/openSUSE-release-tools.git + destination: scripts + timer: + spec: 0 */15 * ? * * + only_on_changes: false + stages: + - Run: + approval: manual + resources: + - staging-bot + tasks: + - script: |- + install -D /home/go/config/openqa-client.conf /home/go/.config/openqa/client.conf + scripts/totest-manager.py -A https://api.opensuse.org --osc-debug --debug run openSUSE:Factory:ARM + TTM.Factory_PowerPC: + group: openSUSE.Checkers + lock_behavior: unlockWhenFinished + environment_variables: + OSC_CONFIG: /home/go/config/oscrc-totest-manager + materials: + script: + git: https://github.com/openSUSE/openSUSE-release-tools.git + destination: scripts + timer: + spec: 0 */15 * ? * * + only_on_changes: false + stages: + - Run: + approval: manual + resources: + - staging-bot + tasks: + - script: |- + install -D /home/go/config/openqa-client.conf /home/go/.config/openqa/client.conf + scripts/totest-manager.py -A https://api.opensuse.org --osc-debug --debug run openSUSE:Factory:PowerPC + TTM.Factory_zSystems: + group: openSUSE.Checkers + lock_behavior: unlockWhenFinished + environment_variables: + OSC_CONFIG: /home/go/config/oscrc-totest-manager + materials: + script: + git: https://github.com/openSUSE/openSUSE-release-tools.git + destination: scripts + timer: + spec: 0 */15 * ? * * + only_on_changes: false + stages: + - Run: + approval: manual + resources: + - staging-bot + tasks: + - script: |- + install -D /home/go/config/openqa-client.conf /home/go/.config/openqa/client.conf + scripts/totest-manager.py -A https://api.opensuse.org --osc-debug --debug run openSUSE:Factory:zSystems + TTM.Leap_15.0_Images: + group: openSUSE.Checkers + lock_behavior: unlockWhenFinished + environment_variables: + OSC_CONFIG: /home/go/config/oscrc-totest-manager + materials: + script: + git: https://github.com/openSUSE/openSUSE-release-tools.git + destination: scripts + timer: + spec: 0 */15 * ? * * + only_on_changes: false + stages: + - Run: + approval: manual + resources: + - staging-bot + tasks: + - script: |- + install -D /home/go/config/openqa-client.conf /home/go/.config/openqa/client.conf + scripts/totest-manager.py -A https://api.opensuse.org --osc-debug --debug run openSUSE:Leap:15.0:Images + TTM.Leap_15.1_Images: + group: openSUSE.Checkers + lock_behavior: unlockWhenFinished + environment_variables: + OSC_CONFIG: /home/go/config/oscrc-totest-manager + materials: + script: + git: https://github.com/openSUSE/openSUSE-release-tools.git + destination: scripts + timer: + spec: 0 */15 * ? * * + only_on_changes: false + stages: + - Run: + approval: manual + resources: + - staging-bot + tasks: + - script: |- + install -D /home/go/config/openqa-client.conf /home/go/.config/openqa/client.conf + scripts/totest-manager.py -A https://api.opensuse.org --osc-debug --debug run openSUSE:Leap:15.1:Images + TTM.Leap_15.1_ARM_Images: + group: openSUSE.Checkers + lock_behavior: unlockWhenFinished + environment_variables: + OSC_CONFIG: /home/go/config/oscrc-totest-manager + materials: + script: + git: https://github.com/openSUSE/openSUSE-release-tools.git + destination: scripts + timer: + spec: 0 */15 * ? * * + only_on_changes: false + stages: + - Run: + approval: manual + resources: + - staging-bot + tasks: + - script: |- + install -D /home/go/config/openqa-client.conf /home/go/.config/openqa/client.conf + scripts/totest-manager.py -A https://api.opensuse.org --osc-debug --debug run openSUSE:Leap:15.1:ARM:Images + TTM.Leap_15.1: + group: openSUSE.Checkers + lock_behavior: unlockWhenFinished + environment_variables: + OSC_CONFIG: /home/go/config/oscrc-totest-manager + materials: + script: + git: https://github.com/openSUSE/openSUSE-release-tools.git + destination: scripts + timer: + spec: 0 */15 * ? * * + only_on_changes: false + stages: + - Run: + approval: manual + resources: + - staging-bot + tasks: + - script: |- + install -D /home/go/config/openqa-client.conf /home/go/.config/openqa/client.conf + scripts/totest-manager.py -A https://api.opensuse.org --osc-debug --debug run openSUSE:Leap:15.1 + TTM.Leap_15.1_ARM: + group: openSUSE.Checkers + lock_behavior: unlockWhenFinished + environment_variables: + OSC_CONFIG: /home/go/config/oscrc-totest-manager + materials: + script: + git: https://github.com/openSUSE/openSUSE-release-tools.git + destination: scripts + timer: + spec: 0 */15 * ? * * + only_on_changes: false + stages: + - Run: + approval: manual + resources: + - staging-bot + tasks: + - script: |- + install -D /home/go/config/openqa-client.conf /home/go/.config/openqa/client.conf + scripts/totest-manager.py -A https://api.opensuse.org --osc-debug --debug run openSUSE:Leap:15.1:ARM + TTM.Leap_15.1_PowerPC: + group: openSUSE.Checkers + lock_behavior: unlockWhenFinished + environment_variables: + OSC_CONFIG: /home/go/config/oscrc-totest-manager + materials: + script: + git: https://github.com/openSUSE/openSUSE-release-tools.git + destination: scripts + timer: + spec: 0 */15 * ? * * + only_on_changes: false + stages: + - Run: + approval: manual + resources: + - staging-bot + tasks: + - script: |- + install -D /home/go/config/openqa-client.conf /home/go/.config/openqa/client.conf + scripts/totest-manager.py -A https://api.opensuse.org --osc-debug --debug run openSUSE:Leap:15.1:PowerPC diff --git a/gocd/totestmanager.gocd.yaml.erb b/gocd/totestmanager.gocd.yaml.erb new file mode 100644 index 00000000..00b565bc --- /dev/null +++ b/gocd/totestmanager.gocd.yaml.erb @@ -0,0 +1,27 @@ +format_version: 3 +pipelines: +<% for project in %w(openSUSE:Factory openSUSE:Factory:ARM openSUSE:Factory:PowerPC + openSUSE:Factory:zSystems openSUSE:Leap:15.0:Images openSUSE:Leap:15.1:Images + openSUSE:Leap:15.1:ARM:Images openSUSE:Leap:15.1 openSUSE:Leap:15.1:ARM openSUSE:Leap:15.1:PowerPC) -%> + TTM.<%= project.gsub('openSUSE:', '').gsub(':', '_') %>: + group: openSUSE.Checkers + lock_behavior: unlockWhenFinished + environment_variables: + OSC_CONFIG: /home/go/config/oscrc-totest-manager + materials: + script: + git: https://github.com/openSUSE/openSUSE-release-tools.git + destination: scripts + timer: + spec: 0 */15 * ? * * + only_on_changes: false + stages: + - Run: + approval: manual + resources: + - staging-bot + tasks: + - script: |- + install -D /home/go/config/openqa-client.conf /home/go/.config/openqa/client.conf + scripts/totest-manager.py -A https://api.opensuse.org --osc-debug --debug run <%= project %> +<% end -%> diff --git a/systemd/osrt-totest-manager@.service b/systemd/osrt-totest-manager@.service deleted file mode 100644 index b5bfa93e..00000000 --- a/systemd/osrt-totest-manager@.service +++ /dev/null @@ -1,8 +0,0 @@ -[Unit] -Description=openSUSE Release Tools: ToTest Manager for %i - -[Service] -User=osrt-totest-manager -SyslogIdentifier=osrt-totest-manager -WorkingDirectory=~ -ExecStart=/usr/bin/osrt-totest-manager --verbose run "%i" diff --git a/systemd/osrt-totest-manager@.timer b/systemd/osrt-totest-manager@.timer deleted file mode 100644 index 62dd8e27..00000000 --- a/systemd/osrt-totest-manager@.timer +++ /dev/null @@ -1,9 +0,0 @@ -[Unit] -Description=openSUSE Release Tools: ToTest Manager for %i - -[Timer] -OnBootSec=15min -OnUnitActiveSec=5m - -[Install] -WantedBy=timers.target diff --git a/ttm/manager.py b/ttm/manager.py index 55d5555b..b8cd2a33 100644 --- a/ttm/manager.py +++ b/ttm/manager.py @@ -89,12 +89,12 @@ class ToTestManager(ToolBase.ToolBase): def totest(self, project): self.setup(project) try: - current_snapshot = self.get_current_snapshot() + current_snapshot = self.version_from_totest_project() except NotFoundException as e: # nothing in test project (yet) self.logger.warn(e) current_snapshot = None - new_snapshot = self.current_sources() + new_snapshot = self.version_from_project() self.update_pinned_descr = False current_result = self.overall_result(current_snapshot) current_qa_version = self.current_qa_version() @@ -157,7 +157,7 @@ class ToTestManager(ToolBase.ToolBase): def release(self, project): self.setup(project) - new_snapshot = self.current_sources() + new_snapshot = self.version_from_project() self.update_totest(new_snapshot) def write_version_to_dashboard(self, target, version): @@ -194,18 +194,17 @@ class ToTestManager(ToolBase.ToolBase): raise NotFoundException("can't find %s version" % self.project) - def current_sources(self): - if self.project.take_source_from_product is None: - raise Exception('No idea where to take the source version from') - - if self.project.take_source_from_product: - if self.project.is_image_product: - return self.iso_build_version(self.project.name, self.project.image_products[0].package, - arch=self.project.image_products[0].archs[0]) - return self.iso_build_version(self.project.name, self.project.main_products[0]) - else: + def version_from_project(self): + if not self.project.take_source_from_product: return self.release_version() + if len(self.project.main_products): + return self.iso_build_version(self.project.name, self.project.main_products[0]) + + #assert(self.project.is_image_product) + return self.iso_build_version(self.project.name, self.project.image_products[0].package, + arch=self.project.image_products[0].archs[0]) + def binaries_of_product(self, project, product, repo=None, arch=None): if repo is None: repo = self.project.product_repo @@ -225,11 +224,13 @@ class ToTestManager(ToolBase.ToolBase): return ret - def get_current_snapshot(self): - if self.project.is_image_product: - return self.iso_build_version(self.project.test_project, self.project.image_products[0].package, - arch=self.project.image_products[0].archs[0]) - return self.iso_build_version(self.project.test_project, self.project.main_products[0]) + def version_from_totest_project(self): + if len(self.project.main_products): + return self.iso_build_version(self.project.test_project, self.project.main_products[0]) + + return self.iso_build_version(self.project.test_project, self.project.image_products[0].package, + arch=self.project.image_products[0].archs[0]) + def ftp_build_version(self, project, tree): for binary in self.binaries_of_product(project, tree):