Skip to content

Commit 2767959

Browse files
committed
Fixes as per PR review.
1 parent c250d90 commit 2767959

File tree

8 files changed

+46
-51
lines changed

8 files changed

+46
-51
lines changed

acceptancetests/assess_log_forward.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
from utility import (
2424
add_basic_testing_arguments,
2525
configure_logging,
26-
get_unit_ipaddress,
26+
get_unit_public_ip,
2727
JujuAssertionError,
2828
temp_dir,
2929
)
@@ -190,7 +190,7 @@ def deploy_rsyslog(client):
190190
def setup_tls_rsyslog(client, app_name):
191191
unit_machine = '{}/0'.format(app_name)
192192

193-
ip_address = get_unit_ipaddress(client, unit_machine)
193+
ip_address = get_unit_public_ip(client, unit_machine)
194194

195195
client.juju(
196196
'ssh',

acceptancetests/assess_upgrade.py

Lines changed: 8 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,6 @@
1515
import argparse
1616
import logging
1717
import sys
18-
from subprocess import (
19-
CalledProcessError,
20-
)
21-
2218

2319
from collections import (
2420
namedtuple,
@@ -40,18 +36,14 @@
4036
agent_tgz_from_juju_binary,
4137
)
4238
from jujupy.wait_condition import (
43-
ModelCheckFailed,
4439
WaitModelVersion,
45-
wait_for_model_check,
40+
wait_until_model_upgrades,
4641
)
4742
from jujupy.workloads import (
4843
deploy_mediawiki_with_db,
49-
assert_media_wiki_is_responding
44+
assert_mediawiki_is_responding
5045
)
5146

52-
from utility import (
53-
JujuAssertionError
54-
)
5547

5648
__metaclass__ = type
5749

@@ -67,10 +59,10 @@ def assess_upgrade_from_stable_to_develop(args, stable_bsm, devel_client):
6759
with temp_dir() as base_dir:
6860
stream_server = StreamServer(base_dir)
6961
setup_agent_metadata(
70-
stream_server, args.stable_agent,
62+
stream_server, args.stable_juju_agent,
7163
stable_client, base_dir, 'proposed')
7264
setup_agent_metadata(
73-
stream_server, args.devel_agent,
65+
stream_server, args.devel_juju_agent,
7466
devel_client, base_dir, 'proposed')
7567
with stream_server.server() as url:
7668
stable_client.env.update_config({
@@ -81,9 +73,9 @@ def assess_upgrade_from_stable_to_develop(args, stable_bsm, devel_client):
8173
assert_stable_model_is_correct(stable_client)
8274

8375
deploy_mediawiki_with_db(stable_client)
84-
assert_media_wiki_is_responding(stable_client)
76+
assert_mediawiki_is_responding(stable_client)
8577
upgrade_stable_to_devel_version(devel_client)
86-
assert_media_wiki_is_responding(devel_client)
78+
assert_mediawiki_is_responding(devel_client)
8779

8880

8981
def upgrade_stable_to_devel_version(client):
@@ -97,26 +89,6 @@ def upgrade_stable_to_devel_version(client):
9789
wait_until_model_upgrades(client)
9890

9991

100-
def wait_until_model_upgrades(client, timeout=300):
101-
# Poll using a command that will fail until the upgrade is complete.
102-
def model_upgrade_status_check(client):
103-
try:
104-
log.info('Attempting API connection, failure is not fatal.')
105-
client.list_models()
106-
client.juju('list-users', (), include_e=False)
107-
return True
108-
except CalledProcessError:
109-
# Upgrade will still be in progress and thus refuse the api call.
110-
return False
111-
try:
112-
wait_for_model_check(client, model_upgrade_status_check, timeout)
113-
except ModelCheckFailed:
114-
raise JujuAssertionError(
115-
'Upgrade for model {} failed to complete within the alloted '
116-
'timeout ({} seconds)'.format(
117-
client.model_name, timeout))
118-
119-
12092
def assert_stable_model_is_correct(stable_client):
12193
assert_model_is_version(
12294
stable_client.get_controller_client(),
@@ -170,11 +142,11 @@ def parse_args(argv):
170142
'--stable-juju-bin',
171143
help='Path to juju binary to be used as the stable version of juju.')
172144
parser.add_argument(
173-
'--stable-agent',
145+
'--stable-juju-agent',
174146
help='Path to agent to use when bootstrapping with stable binary'
175147
)
176148
parser.add_argument(
177-
'--devel-agent',
149+
'--devel-juju-agent',
178150
help='Path to agent to use when bootstrapping with stable binary'
179151
)
180152
return parser.parse_args(argv)

acceptancetests/jujupy/binaries.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,9 +61,9 @@ def get_stable_juju(args, stable_juju_bin=None):
6161
raise RuntimeError(
6262
'Provided stable juju path is not valid: {}'.format(e))
6363
known_juju_paths = (
64+
'{}/bin/juju'.format(os.environ.get('GOPATH')),
6465
'/snap/bin/juju',
65-
'/usr/bin/juju',
66-
'{}/bin/juju'.format(os.environ.get('GOPATH')))
66+
'/usr/bin/juju')
6767

6868
for path in known_juju_paths:
6969
try:
@@ -77,4 +77,4 @@ def get_stable_juju(args, stable_juju_bin=None):
7777
log.debug('Attempt at using {} failed.'.format(path))
7878
pass
7979

80-
raise RuntimeError('Unable to get a stable system juju binary.')
80+
raise RuntimeError('Unable to get a stable system juju binary.')

acceptancetests/jujupy/utility.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ def split_address_port(address_port):
128128
return address, port
129129

130130

131-
def get_unit_ipaddress(client, unit_name):
131+
def get_unit_public_ip(client, unit_name):
132132
status = client.get_status()
133133
return status.get_unit(unit_name)['public-address']
134134

acceptancetests/jujupy/wait_condition.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,10 @@
1313
# You should have received a copy of the Lesser GNU General Public License
1414
# along with this program. If not, see <http://www.gnu.org/licenses/>.
1515

16+
import logging
1617
from datetime import datetime
1718
from time import sleep
19+
from subprocess import CalledProcessError
1820

1921
from jujupy.exceptions import (
2022
VersionsNotUpdated,
@@ -28,6 +30,8 @@
2830
)
2931

3032

33+
log = logging.getLogger(__name__)
34+
3135
__metaclass__ = type
3236

3337

@@ -53,6 +57,25 @@ def wait_for_model_check(client, model_check, timeout):
5357
raise ModelCheckFailed()
5458

5559

60+
def wait_until_model_upgrades(client, timeout=300):
61+
# Poll using a command that will fail until the upgrade is complete.
62+
def model_upgrade_status_check(client):
63+
try:
64+
log.info('Attempting API connection, failure is not fatal.')
65+
client.juju('list-users', (), include_e=False)
66+
return True
67+
except CalledProcessError:
68+
# Upgrade will still be in progress and thus refuse the api call.
69+
return False
70+
try:
71+
wait_for_model_check(client, model_upgrade_status_check, timeout)
72+
except ModelCheckFailed:
73+
raise AssertionError(
74+
'Upgrade for model {} failed to complete within the alloted '
75+
'timeout ({} seconds)'.format(
76+
client.model_name, timeout))
77+
78+
5679
class BaseCondition:
5780
"""Base class for conditions that support client.wait_for."""
5881

acceptancetests/jujupy/workloads.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
AllApplicationWorkloads,
2828
)
2929
from jujupy.utility import (
30-
get_unit_ipaddress,
30+
get_unit_public_ip,
3131
temp_dir,
3232
)
3333

@@ -54,13 +54,13 @@ def deploy_mediawiki_with_db(client):
5454
client.wait_for_started()
5555

5656

57-
def assert_media_wiki_is_responding(client):
58-
log.debug('Assert media wiki is responding.')
57+
def assert_mediawiki_is_responding(client):
58+
log.debug('Assert mediawiki is responding.')
5959
status = client.get_status()
6060
[wiki_unit_name] = [
6161
k for k, v in status.get_applications()['mediawiki']['units'].items()
6262
if v.get('leader', False)]
63-
wiki_ip = get_unit_ipaddress(client, wiki_unit_name)
63+
wiki_ip = get_unit_public_ip(client, wiki_unit_name)
6464
resp = requests.get('http://{}'.format(wiki_ip))
6565
if not resp.ok:
6666
raise AssertionError('Mediawiki not responding; {}: {}'.format(
@@ -132,7 +132,7 @@ def assert_deployed_charm_is_responding(client, expected_output=None):
132132
# Set default value if needed.
133133
if expected_output is None:
134134
expected_output = 'simple-server.'
135-
ipaddress = get_unit_ipaddress(client, 'simple-resource-http/0')
135+
ipaddress = get_unit_public_ip(client, 'simple-resource-http/0')
136136
if expected_output != get_server_response(ipaddress):
137137
raise AssertionError('Server charm is not responding as expected.')
138138

acceptancetests/pprof_collector.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
import os
88
import requests
99

10-
from utility import get_unit_ipaddress
10+
from utility import get_unit_public_ip
1111

1212
__metaclass__ = type
1313

@@ -105,7 +105,7 @@ def install_introspection_charm(client, machine_id):
105105
client.wait_for_workloads()
106106
client.juju('expose', 'juju-introspection')
107107

108-
return get_unit_ipaddress(client, 'juju-introspection/0')
108+
return get_unit_public_ip(client, 'juju-introspection/0')
109109

110110

111111
def _get_introspection_charm_url():

acceptancetests/utility.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
ensure_deleted,
2121
ensure_dir,
2222
get_timeout_path,
23-
get_unit_ipaddress,
23+
get_unit_public_ip,
2424
is_ipv6_address,
2525
print_now,
2626
qualified_model_name,
@@ -37,7 +37,7 @@
3737
'ensure_deleted',
3838
'ensure_dir',
3939
'get_timeout_path',
40-
'get_unit_ipaddress',
40+
'get_unit_public_ip',
4141
'qualified_model_name',
4242
'quote',
4343
'scoped_environ',

0 commit comments

Comments
 (0)