Skip to content

Commit

Permalink
Merge 3d6685c into 350b4db
Browse files Browse the repository at this point in the history
  • Loading branch information
atodorov committed May 14, 2020
2 parents 350b4db + 3d6685c commit ef47a6b
Show file tree
Hide file tree
Showing 9 changed files with 178 additions and 0 deletions.
55 changes: 55 additions & 0 deletions .github/workflows/integration_bugtracker.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
name: 'integration / bugtracker'

on:
push:
branches: master
pull_request:

jobs:
integration_test:
name: ${{ matrix.tracker }}
runs-on: ubuntu-latest
strategy:
matrix:
python-version: [3.7]
tracker: [bugzilla]

steps:
- uses: actions/checkout@v2

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v1
with:
python-version: ${{ matrix.python-version }}

- name: Dockerize
run: |
docker-compose -f tests/${{ matrix.tracker}}/docker-compose.yml build
docker-compose -f tests/${{ matrix.tracker}}/docker-compose.yml up -d
sleep 10
IP_ADDR=`docker inspect -f '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' bugtracker_kiwitcms_org`
sudo sh -c "echo '$IP_ADDR bugtracker.kiwitcms.org' >> /etc/hosts"
# install all dev dependencies here b/c these steps are now part of a
# job matrix which unconditionally initializes the bugtracker DB and
# runs the tests. Some trackers may end up with empty initialization!
- name: Install Python dependencies
run: |
sudo apt-get install libkrb5-dev
pip install -r requirements/devel.txt
- name: Initialize bugs DB
run: |
./tests/${{ matrix.tracker }}/initialize-data
- name: Execute tests
run: |
export LANG="en_US.UTF-8"
export TEST_BUGTRACKER_INTEGRATION=1
coverage run --source='.' ./manage.py test -v2 --noinput --settings=tcms.settings.test tcms.issuetracker.tests.test_${{ matrix.tracker }}
- name: Send coverage to codecov.io
run: |
coverage report -m
bash <(curl -s https://codecov.io/bash)
6 changes: 6 additions & 0 deletions codecov.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
codecov:
require_ci_to_pass: no
coverage:
status:
patch: no
comment: no
Empty file.
40 changes: 40 additions & 0 deletions tcms/issuetracker/tests/test_bugzilla.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
import os
import unittest

from tcms.issuetracker.types import Bugzilla
from tcms.testcases.models import BugSystem
from tcms.tests import LoggedInTestCase


@unittest.skipUnless(os.getenv('TEST_BUGTRACKER_INTEGRATION'),
'Bug tracker integration testing not enabled')
class TestBugzillaIntegration(LoggedInTestCase):
existing_bug_url = 'http://bugtracker.kiwitcms.org/bugzilla/show_bug.cgi?id=1'

@classmethod
def setUpTestData(cls):
super().setUpTestData()

bug_system = BugSystem.objects.create( # nosec:B106:hardcoded_password_funcarg
name='Dockerized Bugzilla',
tracker_type='Bugzilla',
base_url='http://bugtracker.kiwitcms.org/bugzilla/',
api_url='http://bugtracker.kiwitcms.org/bugzilla/xmlrpc.cgi',
api_username='admin@bugzilla.bugs',
api_password='password',
)
cls.integration = Bugzilla(bug_system)

def test_bug_id_from_url(self):
result = self.integration.bug_id_from_url(self.existing_bug_url)
self.assertEqual(1, result)

def test_details(self):
result = self.integration.details(self.existing_bug_url)

# Bugzilla doesn't support OpenGraph and ATM we don't provide
# additional integration here
# warning: this vvv is not the regular - (dash) character
self.assertEqual('1 – Hello World', result['title'])
self.assertEqual('', result['description'])
self.assertEqual('', result['image'])
16 changes: 16 additions & 0 deletions tests/bugzilla/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
FROM fedora

RUN dnf -y install bugzilla "perl(DBD::SQLite)" findutils
# install optional modules, incl. XMLRPC
RUN /usr/share/bugzilla/checksetup.pl --check-modules 2>/dev/null | grep "dnf install" | cut -f2-99 -d: | sed "s/dnf install//" | xargs dnf -y install
RUN /usr/share/bugzilla/checksetup.pl --check-modules

COPY . /root/
RUN patch -b /usr/share/bugzilla/Bugzilla/Util.pm /root/Util.pm.patch

# generate /etc/bugzilla/localconfig
RUN /usr/share/bugzilla/checksetup.pl /root/checksetup_answers.txt


EXPOSE 80
CMD /usr/sbin/httpd -DFOREGROUND
12 changes: 12 additions & 0 deletions tests/bugzilla/Util.pm.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
--- /usr/share/bugzilla/Bugzilla/Util.pm.orig 2020-05-13 15:25:00.031963484 +0300
+++ /usr/share/bugzilla/Bugzilla/Util.pm 2020-05-13 15:31:54.668329481 +0300
@@ -106,7 +106,8 @@
# |U+200e|Left-To-Right Mark |0xe2 0x80 0x8e |
# |U+200f|Right-To-Left Mark |0xe2 0x80 0x8f |
# --------------------------------------------------------
- $var =~ tr/\x{202a}-\x{202e}//d;
+ # workaround for https://bugzilla.mozilla.org/show_bug.cgi?id=1588175
+ # $var =~ tr/\x{202a}-\x{202e}//d;
}
return $var;
}
26 changes: 26 additions & 0 deletions tests/bugzilla/checksetup_answers.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
$answer{'ADMIN_EMAIL'} = 'admin@bugzilla.bugs';
$answer{'ADMIN_LOGIN'} = 'admin';
$answer{'ADMIN_OK'} = 'Y';
$answer{'ADMIN_PASSWORD'} = 'password';
$answer{'ADMIN_REALNAME'} = 'QA Admin';
$answer{'NO_PAUSE'} = 1;
$answer{'apache_size_limit'} = 700000;
$answer{'create_htaccess'} = 1;
$answer{'db_check'} = 1;
$answer{'db_driver'} = 'sqlite';
$answer{'db_host'} = 'localhost';
$answer{'db_mysql_ssl_ca_file'} = '';
$answer{'db_mysql_ssl_ca_path'} = '';
$answer{'db_mysql_ssl_client_cert'} = '';
$answer{'db_mysql_ssl_client_key'} = '';
$answer{'db_name'} = 'bugs',
$answer{'db_pass'} = 'bugs';
$answer{'db_port'} = 0;
$answer{'db_sock'} = '';
$answer{'db_user'} = 'bugs';
$answer{'diffpath'} = '/usr/bin';
$answer{'index_html'} = 0;
$answer{'interdiffbin'} = '/usr/bin/interdiff';
$answer{'urlbase'} = 'http://bugtracker.kiwitcms.org/bugzilla/';
$answer{'use_suexec'} = 0;
$answer{'webservergroup'} = 'apache';
12 changes: 12 additions & 0 deletions tests/bugzilla/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
version: '3'

services:
# build ourselves b/c bugzilla/docker-bugzilla-dev
# is too old and doesn't work
bugtracker_kiwitcms_org:
container_name: bugtracker_kiwitcms_org
build:
context: .
dockerfile: Dockerfile
image: kiwitcms/bugzilla
restart: always
11 changes: 11 additions & 0 deletions tests/bugzilla/initialize-data
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/bin/bash

BZ_URL="http://bugtracker.kiwitcms.org/bugzilla/xmlrpc.cgi"
BZ_USER="admin@bugzilla.bugs"
BZ_PASS="password"

# this is Bug #1
bugzilla --bugzilla $BZ_URL --username $BZ_USER --password $BZ_PASS --ensure-logged-in \
new --product TestProduct --version unspecified --component TestComponent \
--summary 'Hello World' --comment 'This is reported via cli' \
--os Linux --arch All

0 comments on commit ef47a6b

Please sign in to comment.