URL: https://github.com/freeipa/freeipa/pull/439
Author: MartinBasti
 Title: #439: Testing both py2/py3 in travis
Action: synchronized

To pull the PR as Git branch:
git remote add ghfreeipa https://github.com/freeipa/freeipa
git fetch ghfreeipa pull/439/head:pr439
git checkout pr439
From 1889f079ba6bca91bcc73f74f4ef347e923229bd Mon Sep 17 00:00:00 2001
From: Martin Basti <mba...@redhat.com>
Date: Tue, 7 Feb 2017 14:56:39 +0100
Subject: [PATCH 1/3] Build: allow to build only py2 rpms for fedora

This is more or less for testing purposes of py2/py3 compatibility
---
 BUILD.txt       | 5 +++++
 Makefile.am     | 4 ++--
 freeipa.spec.in | 4 ++++
 3 files changed, 11 insertions(+), 2 deletions(-)

diff --git a/BUILD.txt b/BUILD.txt
index 7901d0748c..1729daebf5 100644
--- a/BUILD.txt
+++ b/BUILD.txt
@@ -36,6 +36,11 @@ It may be possible to do a simple make install but this has not been
 well-tested. Additional work is done in pre/post install scripts in the ipa
 spec file.
 
+To build only python2 packages on fedora following steps are required:
+$ autoreconf -i
+$ ./configure
+$ make rpms RPMBUILD_OPTS="--define 'with_python3 0'"
+
 Developing plugins
 ------------------
 
diff --git a/Makefile.am b/Makefile.am
index cbe4f2df49..972e260012 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -122,7 +122,7 @@ rpms: $(VERSION_UPDATE_TARGET)
 	$(MAKE) _rpms-body
 
 _rpms-body: _rpms-prep
-	rpmbuild --define "_topdir $(RPMBUILD)" -ba $(top_builddir)/$(PACKAGE).spec
+	rpmbuild --define "_topdir $(RPMBUILD)" -ba $(top_builddir)/$(PACKAGE).spec  $(RPMBUILD_OPTS)
 	cp $(RPMBUILD)/RPMS/*/*$$(cat $(top_builddir)/.version)*.rpm $(top_builddir)/dist/rpms/
 	cp $(RPMBUILD)/SRPMS/*$$(cat $(top_builddir)/.version)*.src.rpm $(top_builddir)/dist/srpms/
 	rm -f rm -f $(top_builddir)/.version
@@ -131,7 +131,7 @@ srpms: $(VERSION_UPDATE_TARGET)
 	$(MAKE) _srpms-body
 
 _srpms-body: _rpms-prep
-	rpmbuild --define "_topdir $(RPMBUILD)" -bs $(top_builddir)/$(PACKAGE).spec
+	rpmbuild --define "_topdir $(RPMBUILD)" -bs $(top_builddir)/$(PACKAGE).spec $(RPMBUILD_OPTS)
 	cp $(RPMBUILD)/SRPMS/*$$(cat $(top_builddir)/.version)*.src.rpm $(top_builddir)/dist/srpms/
 	rm -f rm -f $(top_builddir)/.version
 
diff --git a/freeipa.spec.in b/freeipa.spec.in
index e6f63a2675..33e59af04d 100644
--- a/freeipa.spec.in
+++ b/freeipa.spec.in
@@ -17,11 +17,15 @@
     %global with_ipatests_option --without-ipatests
 %endif
 
+%if 0%{?with_python3:1}
+# with_python3 already defined
+%else
 %if 0%{?rhel}
 %global with_python3 0
 %else
 %global with_python3 1
 %endif
+%endif
 
 # lint is not executed during rpmbuild
 # %%global with_lint 1

From 5d3ef3b5271ff2285a6dbf25954c6a98b3db6613 Mon Sep 17 00:00:00 2001
From: Martin Basti <mba...@redhat.com>
Date: Tue, 7 Feb 2017 17:23:54 +0100
Subject: [PATCH 2/3] Travis: build only py2 packages for py2 testing

We will testing both py2 and py3 packages, first step is use only py2
builds for testing py2 packages
---
 .travis.yml         |  2 ++
 .travis_run_task.sh | 10 +++++++++-
 2 files changed, 11 insertions(+), 1 deletion(-)

diff --git a/.travis.yml b/.travis.yml
index c275cdca5d..62578d3e41 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -17,8 +17,10 @@ env:
     matrix:
         - TASK_TO_RUN="lint"
         - TASK_TO_RUN="run-tests"
+          PYTHON=/usr/bin/python2
           TESTS_TO_RUN="test_xmlrpc/test_[a-k]*.py"
         - TASK_TO_RUN="run-tests"
+          PYTHON=/usr/bin/python2
           TESTS_TO_RUN="test_cmdline
             test_install
             test_ipaclient
diff --git a/.travis_run_task.sh b/.travis_run_task.sh
index 7d050b0b6f..540c883d83 100755
--- a/.travis_run_task.sh
+++ b/.travis_run_task.sh
@@ -4,10 +4,17 @@
 #
 # NOTE: this script is intended to run in Travis CI only
 
-PYTHON="/usr/bin/python${TRAVIS_PYTHON_VERSION}"
 test_set=""
 developer_mode_opt="--developer-mode"
 
+if [[ $PYTHON == "/usr/bin/python2" ]]
+then
+env_opt="--define 'with_python3 0'"
+else
+env_opt=""
+fi
+
+
 function truncate_log_to_test_failures() {
     # chop off everything in the CI_RESULTS_LOG preceding pytest error output
     # if there are pytest errors in the log
@@ -43,6 +50,7 @@ ipa-docker-test-runner -l $CI_RESULTS_LOG \
     -c $TEST_RUNNER_CONFIG \
     $developer_mode_opt \
     --container-environment "PYTHON=$PYTHON" \
+    --container-environment "RPMBUILD_OPTS=$env_opt" \
     --container-image $TEST_RUNNER_IMAGE \
     --git-repo $TRAVIS_BUILD_DIR \
     $TASK_TO_RUN $test_set

From 4a0c566168d08c05a7289fc03629887f9c1399a1 Mon Sep 17 00:00:00 2001
From: Martin Basti <mba...@redhat.com>
Date: Tue, 7 Feb 2017 18:29:08 +0100
Subject: [PATCH 3/3] Travis: enable temporal Py3 testing

This testconfig is temporal until all plugins are migrated into py3.
After that this temporal config file will be removed and used only the
previous one again
---
 .test_runner_config_py3_temp.yaml | 60 ++++++++++++++++++++++++++
 .travis.yml                       | 90 ++++++++++++++++++++++++++++++++++++++-
 2 files changed, 149 insertions(+), 1 deletion(-)
 create mode 100644 .test_runner_config_py3_temp.yaml

diff --git a/.test_runner_config_py3_temp.yaml b/.test_runner_config_py3_temp.yaml
new file mode 100644
index 0000000000..cece1c4149
--- /dev/null
+++ b/.test_runner_config_py3_temp.yaml
@@ -0,0 +1,60 @@
+#
+# Copyright (C) 2017 FreeIPA Contributors see COPYING for license
+#
+
+# Configuration file for the test runner used in Travis CI
+# This config file is temporal and will be used only for migration period
+# from py2 to fully supported py3
+
+container:
+  detach: true
+  hostname: master.ipa.test
+  working_dir: /freeipa
+host:
+  binds:
+  - /sys/fs/cgroup:/sys/fs/cgroup:ro
+  - /dev/urandom:/dev/random:ro
+  privileged: true
+  security_opt:
+  - label:disable
+  tmpfs:
+  - /tmp
+  - /run
+server:
+  domain: ipa.test
+  password: Secret123
+  realm: IPA.TEST
+steps:
+  build:
+  - make V=0 ${make_target}
+  builddep:
+  - rm -rf /var/cache/dnf/*
+  - "dnf makecache fast || :"
+  - dnf builddep -y ${builddep_opts} --spec freeipa.spec.in --best --allowerasing
+  cleanup:
+  - chown -R ${uid}:${gid} ${container_working_dir}
+  configure:
+  - ./autogen.sh
+  install_packages:
+  - dnf install -y ${container_working_dir}/dist/rpms/*.rpm --best --allowerasing
+  - dnf install -y python3-mod_wsgi --best --allowerasing  # Py3 temporary
+  install_server:
+  - ipa-server-install -U --domain ${server_domain} --realm ${server_realm} -p ${server_password}
+    -a ${server_password} --setup-dns --auto-forwarders
+  - ipa-kra-install -p ${server_password}
+  lint:
+  - make PYTHON=/usr/bin/python2 V=0 lint
+  - make PYTHON=/usr/bin/python3 V=0 pylint
+  prepare_tests:
+  - echo ${server_password} | kinit admin && ipa ping
+  - cp -r /etc/ipa/* ~/.ipa/
+  - echo ${server_password} > ~/.ipa/.dmpw
+  - echo 'wait_for_dns=5' >> ~/.ipa/default.conf
+  run_tests:
+  - ipa-run-tests-3 ${tests_ignore} -k-test_dns_soa ${tests_verbose} ${path}
+tests:
+  verbose: true
+  ignore:
+  - test_integration
+  - test_webui
+  - test_ipapython/test_keyring.py
diff --git a/.travis.yml b/.travis.yml
index 62578d3e41..177fa8beda 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -8,7 +8,6 @@ cache: pip
 env:
     global:
         - TEST_RUNNER_IMAGE="martbab/freeipa-fedora-test-runner:master-latest"
-          TEST_RUNNER_CONFIG=".test_runner_config.yaml"
           PEP8_ERROR_LOG="pep8_errors.log"
           CI_RESULTS_LOG="ci_results_${TRAVIS_BRANCH}.log"
           CI_BACKLOG_SIZE=5000
@@ -16,11 +15,14 @@ env:
           CI_RUNNER_LOG_ARCHIVE="freeipa-ci-pr-${TRAVIS_PULL_REQUEST}-job-${TRAVIS_JOB_NUMBER}.tar.gz"
     matrix:
         - TASK_TO_RUN="lint"
+          TEST_RUNNER_CONFIG=".test_runner_config.yaml"
         - TASK_TO_RUN="run-tests"
           PYTHON=/usr/bin/python2
+          TEST_RUNNER_CONFIG=".test_runner_config.yaml"
           TESTS_TO_RUN="test_xmlrpc/test_[a-k]*.py"
         - TASK_TO_RUN="run-tests"
           PYTHON=/usr/bin/python2
+          TEST_RUNNER_CONFIG=".test_runner_config.yaml"
           TESTS_TO_RUN="test_cmdline
             test_install
             test_ipaclient
@@ -29,6 +31,92 @@ env:
             test_ipaserver
             test_pkcs10
             test_xmlrpc/test_[l-z]*.py"
+        - TASK_TO_RUN="run-tests"
+          PYTHON=/usr/bin/python3
+          TEST_RUNNER_CONFIG=".test_runner_config_py3_temp.yaml"
+          TESTS_TO_RUN="test_xmlrpc/test_dns_plugin.py
+            test_xmlrpc/test_host_plugin.py"
+            ### Tests which haven't been ported to py3 yet ###
+            ## test_xmlrpc/test_[a-k]*.py
+            # test_xmlrpc/test_add_remove_cert_cmd.py
+            # test_xmlrpc/test_attr.py
+            # test_xmlrpc/test_automember_plugin.py
+            # test_xmlrpc/test_automount_plugin.py
+            # test_xmlrpc/test_baseldap_plugin.py
+            # test_xmlrpc/test_batch_plugin.py
+            # test_xmlrpc/test_ca_plugin.py
+            # test_xmlrpc/test_caacl_plugin.py
+            # test_xmlrpc/test_caacl_profile_enforcement.py
+            # test_xmlrpc/test_cert_plugin.py
+            # test_xmlrpc/test_certprofile_plugin.py
+            # test_xmlrpc/test_config_plugin.py
+            # test_xmlrpc/test_delegation_plugin.py
+            # test_xmlrpc/test_dns_realmdomains_integration.py
+            # test_xmlrpc/test_external_members.py
+            # test_xmlrpc/test_group_plugin.py
+            # test_xmlrpc/test_hbac_plugin.py
+            # test_xmlrpc/test_hbacsvcgroup_plugin.py
+            # test_xmlrpc/test_hbactest_plugin.py
+            # test_xmlrpc/test_hostgroup_plugin.py
+            # test_xmlrpc/test_idviews_plugin.py
+            # test_xmlrpc/test_kerberos_principal_aliases.py
+            # test_xmlrpc/test_krbtpolicy.py
+        - TASK_TO_RUN="run-tests"
+          PYTHON=/usr/bin/python3
+          TEST_RUNNER_CONFIG=".test_runner_config_py3_temp.yaml"
+          TESTS_TO_RUN="test_cmdline
+                test_ipalib
+                test_pkcs10
+                test_xmlrpc/test_ping_plugin.py"
+            ### Tests which haven't been ported to py3 yet ###
+            ## test_install
+            ## test_ipapython
+            # test_ipapython/test_cookie.py
+            # test_ipapython/test_dn.py
+            # test_ipapython/test_ipautil.py
+            # test_ipapython/test_ipavalidate.py
+            # test_ipapython/test_kerberos.py
+            # test_ipapython/test_ssh.py
+            # test_ipaserver/httptest.py
+            # test_ipaserver/test_changepw.py
+            # test_ipaserver/test_dnssec.py
+            # test_ipaserver/test_install/test_adtrustinstance.py
+            # test_ipaserver/test_install/test_service.py
+            # test_ipaserver/test_ipap11helper.py
+            # test_ipaserver/test_kadmin.py
+            # test_ipaserver/test_ldap.py
+            # test_ipaserver/test_otptoken_import.py
+            # test_ipaserver/test_rpcserver.py
+            # test_ipaserver/test_secrets.py
+            # test_ipaserver/test_serverroles.py
+            # test_ipaserver/test_topology_plugin.py
+            # test_ipaserver/test_version_comparison.py
+            ## test_ipaserver
+            ## test_xmlrpc/test_[l-z]*.py
+            # test_xmlrpc/test_location_plugin.py
+            # test_xmlrpc/test_nesting.py
+            # test_xmlrpc/test_netgroup_plugin.py
+            # test_xmlrpc/test_old_permission_plugin.py
+            # test_xmlrpc/test_passwd_plugin.py
+            # test_xmlrpc/test_permission_plugin.py
+            # test_xmlrpc/test_privilege_plugin.py
+            # test_xmlrpc/test_pwpolicy_plugin.py
+            # test_xmlrpc/test_radiusproxy_plugin.py
+            # test_xmlrpc/test_range_plugin.py
+            # test_xmlrpc/test_realmdomains_plugin.py
+            # test_xmlrpc/test_replace.py
+            # test_xmlrpc/test_role_plugin.py
+            # test_xmlrpc/test_selfservice_plugin.py
+            # test_xmlrpc/test_selinuxusermap_plugin.py
+            # test_xmlrpc/test_service_plugin.py
+            # test_xmlrpc/test_servicedelegation_plugin.py
+            # test_xmlrpc/test_stageuser_plugin.py
+            # test_xmlrpc/test_sudocmd_plugin.py
+            # test_xmlrpc/test_sudocmdgroup_plugin.py
+            # test_xmlrpc/test_sudorule_plugin.py
+            # test_xmlrpc/test_trust_plugin.py
+            # test_xmlrpc/test_user_plugin.py
+            # test_xmlrpc/test_vault_plugin.py
 install:
     - pip install --upgrade pip
     - pip3 install --upgrade pip
_______________________________________________
FreeIPA-devel mailing list -- freeipa-devel@lists.fedorahosted.org
To unsubscribe send an email to freeipa-devel-le...@lists.fedorahosted.org

Reply via email to