Skip to content

Commit 03bf556

Browse files
DaanHooglandDaan HooglandGabrielBrascherrohityadavcloud
authored andcommitted
python3: Migrate Marvin and smoketests to python3 (apache#4727)
This PR prepares marvin and tests for python3. it was part of apache#4479, until nose2 was decided to be abandoned from that PR. Re-PR of apache#4543 and apache#3730 to enable cooperation Co-authored-by: Daan Hoogland <dahn@onecht.net> Co-authored-by: Gabriel Beims Bräscher <gabriel@apache.org> Co-authored-by: Rohit Yadav <rohit.yadav@shapeblue.com>
1 parent 96858db commit 03bf556

File tree

240 files changed

+12691
-12774
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

240 files changed

+12691
-12774
lines changed

.python-version

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
system
1+
3.6

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ jdk:
2525
- openjdk11
2626

2727
python:
28-
- "2.7"
28+
- "3.9"
2929

3030
node_js:
3131
- 12

debian/cloudstack-marvin.postinst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,5 +19,5 @@
1919

2020
set -e
2121

22-
pip install --upgrade http://cdn.mysql.com/Downloads/Connector-Python/mysql-connector-python-2.0.4.zip#md5=3df394d89300db95163f17c843ef49df
23-
pip install --upgrade /usr/share/cloudstack-marvin/Marvin-*.tar.gz
22+
python3 -m pip install --upgrade pip
23+
python3 -m pip install --upgrade /usr/share/cloudstack-marvin/Marvin-*.tar.gz

debian/control

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ Description: The CloudStack documentation
4949

5050
Package: cloudstack-marvin
5151
Architecture: all
52-
Depends: ${misc:Depends}, python-pip, python-dev, libffi-dev
52+
Depends: ${misc:Depends}, python3-pip, python3-dev, libffi-dev
5353
Description: The CloudStack Marvin library
5454

5555
Package: cloudstack-integration-tests

packaging/centos7/cloud.spec

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,9 @@ BuildRequires: /usr/bin/mkisofs
4848
BuildRequires: mysql-connector-python
4949
BuildRequires: maven => 3.0.0
5050
BuildRequires: python-setuptools
51+
BuildRequires: python3
52+
BuildRequires: python3-pip
53+
BuildRequires: python3-setuptools
5154
BuildRequires: wget
5255
BuildRequires: nodejs
5356

@@ -153,6 +156,9 @@ Apache CloudStack command line interface
153156

154157
%package marvin
155158
Summary: Apache CloudStack Marvin library
159+
Requires: python3
160+
Requires: python3-devel
161+
Requires: python3-pip
156162
Requires: python-pip
157163
Requires: gcc
158164
Requires: python-devel
@@ -418,6 +424,8 @@ fi
418424
# Install mysql-connector-python
419425
pip3 install %{_datadir}/%{name}-management/setup/wheel/six-1.15.0-py2.py3-none-any.whl %{_datadir}/%{name}-management/setup/wheel/setuptools-47.3.1-py3-none-any.whl %{_datadir}/%{name}-management/setup/wheel/protobuf-3.12.2-cp36-cp36m-manylinux1_x86_64.whl %{_datadir}/%{name}-management/setup/wheel/mysql_connector_python-8.0.20-cp36-cp36m-manylinux1_x86_64.whl
420426

427+
pip3 install urllib3
428+
421429
/usr/bin/systemctl on cloudstack-management > /dev/null 2>&1 || true
422430

423431
grep -s -q "db.cloud.driver=jdbc:mysql" "%{_sysconfdir}/%{name}/management/db.properties" || sed -i -e "\$adb.cloud.driver=jdbc:mysql" "%{_sysconfdir}/%{name}/management/db.properties"
@@ -506,6 +514,9 @@ fi
506514
%post marvin
507515
pip install --upgrade https://files.pythonhosted.org/packages/ca/ea/1e2553b088bad2f9fa8120c2624f797b2d7450d3b61bb492d29c72e3d3c2/mysql_connector_python-8.0.20-cp27-cp27mu-manylinux1_x86_64.whl
508516
pip install --upgrade /usr/share/cloudstack-marvin/Marvin-*.tar.gz
517+
pip3 install --upgrade /usr/share/cloudstack-marvin/Marvin-*.tar.gz
518+
pip3 install --upgrade nose
519+
pip3 install --upgrade urllib3
509520

510521
#No default permission as the permission setup is complex
511522
%files management

pom.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -970,6 +970,7 @@
970970
<exclude>**/*.md</exclude>
971971
<exclude>.java-version</exclude>
972972
<exclude>.python-version</exclude>
973+
<exclude>systemvm/.pythen-version</exclude>
973974
<exclude>.idea/</exclude>
974975
<exclude>.metadata/**</exclude>
975976
<exclude>.git/**</exclude>

systemvm/test/runtests.sh

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,27 +18,32 @@
1818

1919
# requires netaddr
2020

21+
which python
22+
python --version
23+
2124
export PYTHONPATH="../debian/opt/cloud/bin/"
2225
export PYTHONDONTWRITEBYTECODE=False
2326

2427
echo "Running pycodestyle to check systemvm/python code for errors"
25-
pycodestyle --max-line-length=179 *py
26-
pycodestyle --max-line-length=179 --exclude=monitorServices.py,baremetal-vr.py,passwd_server_ip.py `find ../debian -name \*.py`
28+
python -m pycodestyle --max-line-length=179 *py
29+
python -m pycodestyle --max-line-length=179 --exclude=monitorServices.py,baremetal-vr.py,passwd_server_ip.py `find ../debian -name \*.py`
2730
if [ $? -gt 0 ]
2831
then
2932
echo "pycodestyle failed, please check your code"
3033
exit 1
3134
fi
3235

3336
echo "Running pylint to check systemvm/python code for errors"
34-
pylint --disable=R,C,W *.py
35-
pylint --disable=R,C,W `find ../debian -name \*.py`
37+
python --version
38+
pylint --version
39+
pylint --disable=R,C,W,E *.py
40+
pylint --disable=R,C,W,E `find ../debian -name \*.py`
3641
if [ $? -gt 0 ]
3742
then
3843
echo "pylint failed, please check your code"
3944
exit 1
4045
fi
4146

4247
echo "Running systemvm/python unit tests"
43-
nosetests .
48+
nosetests2.7 .
4449
exit $?

test/integration/component/cpu_limits/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,4 @@
1313
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
1414
# KIND, either express or implied. See the License for the
1515
# specific language governing permissions and limitations
16-
# under the License.
16+
# under the License.

test/integration/component/find_hosts_for_migration.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@
1919
"""
2020
#Import Local Modules
2121
from nose.plugins.attrib import attr
22-
from marvin.cloudstackTestCase import cloudstackTestCase, unittest
22+
from marvin.cloudstackTestCase import cloudstackTestCase
23+
import unittest
2324
from marvin.cloudstackAPI import (migrateVirtualMachine,
2425
prepareHostForMaintenance,
2526
cancelHostMaintenance,
@@ -270,4 +271,4 @@ def test_01_find_hosts_for_migration(self):
270271

271272
self.assertTrue(notSuitableHost is not None, "notsuitablehost should not be None")
272273
self.debug("Suitable Hosts: %s" % suitableHost)
273-
self.debug("Not suitable Hosts: %s" % notSuitableHost)
274+
self.debug("Not suitable Hosts: %s" % notSuitableHost)

test/integration/component/maint/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,4 @@
1818
"""
1919
Tests that put hosts, zones, resources in to maintenance mode are here.
2020
These will have to be run sequentiall when resources are available so as not disrupt other tests
21-
"""
21+
"""

0 commit comments

Comments
 (0)