Skip to content

Commit

Permalink
Merge pull request #206 from twindb/intergration-test
Browse files Browse the repository at this point in the history
Fix integration tests on python 3
  • Loading branch information
akuzminsky authored Apr 8, 2020
2 parents 6d14df8 + 3b44add commit f7269d3
Show file tree
Hide file tree
Showing 27 changed files with 928 additions and 924 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -61,3 +61,4 @@ target/
.DS_Store
/vagrant/README.html
/.pytest_cache/
/.venv/
2 changes: 2 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,8 @@ docker-start:
--env AWS_SECRET_ACCESS_KEY=${AWS_SECRET_ACCESS_KEY} \
--env PLATFORM=${PLATFORM} \
--env OS_VERSION=${OS_VERSION} \
--env LC_ALL=C.UTF-8 \
--env LANG=C.UTF-8 \
"twindb/omnibus-${PLATFORM}:${OS_VERSION}" \
bash -l

Expand Down
2 changes: 1 addition & 1 deletion omnibus/config/projects/twindb-backup.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
# and /opt/twindb-backup on all other platforms
install_dir '/opt/twindb-backup'

build_version '2.19.0'
build_version '2.20.0'

build_iteration 1

Expand Down
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[bumpversion]
current_version = 2.19.0
current_version = 2.20.0
commit = True
tag = False

Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

setup(
name='twindb-backup',
version='2.19.0',
version='2.20.0',
description="TwinDB Backup tool for files, MySQL et al.",
long_description=readme + '\n\n' + history,
author="TwinDB Development Team",
Expand Down
10 changes: 5 additions & 5 deletions support/bootstrap/master/debian/master1.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,18 @@ do
apt-get update && break
echo "Waiting ${wait_time} seconds before retry"
sleep ${wait_time}
let wait_time=${wait_time}*2
wait_time=$((wait_time * 2))
done


TB_VERSION=$(PYTHONPATH=/twindb-backup python -c "from twindb_backup import __version__; print __version__")
TB_VERSION=$(PYTHONPATH=/twindb-backup python -c "from twindb_backup import __version__; print(__version__)")

package="/twindb-backup/omnibus/pkg/twindb-backup_${TB_VERSION}-1_amd64.deb"

dpkg -I ${package} | grep Depends: | sed -e 's/Depends://' -e 's/,//g' | xargs apt-get -y install
dpkg -i ${package}
dpkg -I "${package}" | grep Depends: | sed -e 's/Depends://' -e 's/,//g' | xargs apt-get -y install
dpkg -i "${package}"

set +u
if ! test -z "${DEV}"; then
/bin/cp -R /twindb-backup/twindb_backup /opt/twindb-backup/embedded/lib/python2.7/site-packages
/bin/cp -R /twindb-backup/twindb_backup /opt/twindb-backup/embedded/lib/python3.7/site-packages
fi
20 changes: 10 additions & 10 deletions tests/integration/__init__.py
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
from os import environ

__author__ = 'aleks'
__author__ = "aleks"


def ensure_aws_creds():
print('Integration tests need Amazon API credentials:')
print(' AWS_ACCESS_KEY_ID')
print(' AWS_SECRET_ACCESS_KEY')
print("Integration tests need Amazon API credentials:")
print(" AWS_ACCESS_KEY_ID")
print(" AWS_SECRET_ACCESS_KEY")
try:
try:
environ['AWS_ACCESS_KEY_ID']
environ["AWS_ACCESS_KEY_ID"]
except KeyError:
print('Environment variable AWS_ACCESS_KEY_ID is not defined.')
environ['AWS_ACCESS_KEY_ID'] = raw_input('Please enter it: ')
print("Environment variable AWS_ACCESS_KEY_ID is not defined.")
environ["AWS_ACCESS_KEY_ID"] = input("Please enter it: ")
try:
environ['AWS_SECRET_ACCESS_KEY']
environ["AWS_SECRET_ACCESS_KEY"]
except KeyError:
print('Environment variable AWS_SECRET_ACCESS_KEY is not defined.')
environ['AWS_SECRET_ACCESS_KEY'] = raw_input('Please enter it: ')
print("Environment variable AWS_SECRET_ACCESS_KEY is not defined.")
environ["AWS_SECRET_ACCESS_KEY"] = input("Please enter it: ")
except KeyboardInterrupt:
exit(1)
38 changes: 22 additions & 16 deletions tests/integration/backup/s3/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,32 +8,33 @@

from twindb_backup import LOG, setup_logging
from twindb_backup.destination.s3 import S3

setup_logging(LOG, debug=True)


@pytest.fixture()
def bucket_name():
travis_job_number = os.environ.get('TRAVIS_JOB_NUMBER')
LOG.debug('TRAVIS_JOB_NUMBER=%s' % travis_job_number)
travis_job_number = os.environ.get("TRAVIS_JOB_NUMBER")
LOG.debug("TRAVIS_JOB_NUMBER=%s" % travis_job_number)

number = random.randint(0, 1000000)
LOG.debug('Default job number %d' % number)
LOG.debug("Default job number %d" % number)

if travis_job_number:
bucket = 'twindb-backup-test-travis-%s' % travis_job_number
bucket = "twindb-backup-test-travis-%s" % travis_job_number
else:
bucket = 'twindb-backup-test-travis-%d' % number
bucket = "twindb-backup-test-travis-%d" % number

return '%s-%s' % (bucket, time.time())
return "%s-%s" % (bucket, time.time())


@pytest.fixture()
def s3_client(bucket_name):
LOG.debug('Bucket: %s' % bucket_name)
LOG.debug("Bucket: %s" % bucket_name)
client = S3(
bucket=bucket_name,
aws_access_key_id=os.environ['AWS_ACCESS_KEY_ID'],
aws_secret_access_key=os.environ['AWS_SECRET_ACCESS_KEY']
aws_access_key_id=os.environ["AWS_ACCESS_KEY_ID"],
aws_secret_access_key=os.environ["AWS_SECRET_ACCESS_KEY"],
)
try:
assert client.create_bucket()
Expand All @@ -47,12 +48,11 @@ def s3_client(bucket_name):

@pytest.fixture
def foo_bar_dir(tmpdir):
test_dir = tmpdir.join('foo/bar')
test_dir = tmpdir.join("foo/bar")

assert call('rm -rf %s' % str(test_dir), shell=True) == 0
assert call('mkdir -p %s' % str(test_dir), shell=True) == 0
assert call('echo $RANDOM > %s' %
str(test_dir.join('file')), shell=True) == 0
assert call("rm -rf %s" % str(test_dir), shell=True) == 0
assert call("mkdir -p %s" % str(test_dir), shell=True) == 0
assert call("echo $RANDOM > %s" % str(test_dir.join("file")), shell=True) == 0

return str(test_dir)

Expand Down Expand Up @@ -205,21 +205,27 @@ def gpg_private_key():
@pytest.fixture
def config_content_mysql_aenc(config_content_mysql_only):

return config_content_mysql_only + """
return (
config_content_mysql_only
+ """
[gpg]
keyring = {gpg_keyring}
secret_keyring = {gpg_secret_keyring}
recipient = foo@bar
"""
)


@pytest.fixture
def config_content_files_aenc(config_content_files_only):
return config_content_files_only + """
return (
config_content_files_only
+ """
[gpg]
keyring = {gpg_keyring}
secret_keyring = {gpg_secret_keyring}
recipient = foo@bar
"""
)
Loading

0 comments on commit f7269d3

Please sign in to comment.