Skip to content

Commit

Permalink
Merge pull request #14533 from ycliuhw/2.9-into-develop
Browse files Browse the repository at this point in the history
#14533

Merge 2.9 into develop

```
# Conflicts:
# tests/suites/deploy/bundles/cmr_bundles_test_deploy.yaml
# tests/suites/backup/backup.sh
# tests/suites/deploy/bundles/telegraf_bundle.yaml
# tests/suites/expose_ec2/expose_app.sh
# tests/suites/hooks/reboot.sh
# tests/suites/hooktools/state_tools.sh
```

- #14526
- #14529
- #14530
- #14523
- #14531
- #14532
- #14534
  • Loading branch information
jujubot committed Aug 30, 2022
2 parents eab17f7 + dc97be6 commit a20759e
Show file tree
Hide file tree
Showing 19 changed files with 99 additions and 89 deletions.
2 changes: 1 addition & 1 deletion acceptancetests/assess_storage.py
Expand Up @@ -181,7 +181,7 @@ def storage_pool_list(client):

def create_storage_charm(charm_dir, name, summary, storage):
"""Manually create a temporary charm to test with storage."""
storage_charm = Charm(name, summary, storage=storage, series=['jammy'])
storage_charm = Charm(name, summary, storage=storage, series=['jammy', 'focal'])
# Valid charms require at least one hook.
# Add a dummy install hook.
install = '#!/bin/sh\necho install'
Expand Down
10 changes: 1 addition & 9 deletions cmd/juju/application/deploy_test.go
Expand Up @@ -945,7 +945,7 @@ func (s *DeploySuite) TestDeployBundleWithOffers(c *gc.C) {
s.fakeAPI.Call("ListSpaces").Returns([]params.Space{{Name: "alpha", Id: "0"}}, error(nil))

deploy := s.deployCommand()
bundlePath := testcharms.RepoWithSeries("bionic").ClonedBundleDirPath(c.MkDir(), "apache2-with-offers")
bundlePath := testcharms.RepoWithSeries("bionic").ClonedBundleDirPath(c.MkDir(), "apache2-with-offers-legacy")
_, err := cmdtesting.RunCommand(c, modelcmd.Wrap(deploy), bundlePath)
c.Assert(err, jc.ErrorIsNil)

Expand Down Expand Up @@ -2132,14 +2132,6 @@ func (s *FakeStoreStateSuite) setupBundle(c *gc.C, url, name string, series ...s
}
}

func (s *FakeStoreStateSuite) combinedSettings(ch charm.Charm, inSettings charm.Settings) charm.Settings {
result := ch.Config().DefaultSettings()
for name, value := range inSettings {
result[name] = value
}
return result
}

// assertCharmsUploaded checks that the given charm ids have been uploaded.
func (s *FakeStoreStateSuite) assertCharmsUploaded(c *gc.C, ids ...string) {
allCharms, err := s.State.AllCharms()
Expand Down
@@ -0,0 +1 @@
A bundle installing apache2 and exposing two offers for its endpoints
@@ -0,0 +1,19 @@
series: bionic
applications:
apache2:
charm: cs:apache2-26
---
series: bionic
applications:
apache2:
offers:
my-offer:
endpoints:
- apache-website
- website-cache
acl:
admin: admin
bar: consume
my-other-offer:
endpoints:
- apache-website
6 changes: 3 additions & 3 deletions testcharms/charm-repo/bundle/apache2-with-offers/bundle.yaml
@@ -1,9 +1,9 @@
series: bionic
series: focal
applications:
apache2:
charm: cs:apache2-26
charm: apache2
---
series: bionic
series: focal
applications:
apache2:
offers:
Expand Down
8 changes: 4 additions & 4 deletions tests/suites/backup/backup.sh
Expand Up @@ -31,8 +31,8 @@ run_basic_backup_restore() {
ensure "test-basic-backup-restore" "${file}"

echo "Deploy a workload (1 machine)"
juju deploy ubuntu
wait_for "ubuntu" "$(idle_condition "ubuntu")"
juju deploy jameinel-ubuntu-lite
wait_for "ubuntu-lite" "$(idle_condition "ubuntu-lite")"
juju status --format json | jq '.machines | length' | check 1
id0=$(juju status --format json | jq -r '.machines["0"]["instance-id"]')

Expand All @@ -42,7 +42,7 @@ run_basic_backup_restore() {

echo "Add another machine (after the backup)"
juju switch test-basic-backup-restore
juju add-unit ubuntu
juju add-unit ubuntu-lite
wait_for_machine_agent_status "1" "started"
juju status --format json | jq '.machines | length' | check 2
id1=$(juju status --format json | jq -r '.machines["1"]["instance-id"]')
Expand All @@ -55,7 +55,7 @@ run_basic_backup_restore() {

echo "Ensure there's only one machine (state before the backup)"
juju switch test-basic-backup-restore
wait_for "ubuntu" "$(idle_condition "ubuntu")"
wait_for "ubuntu-lite" "$(idle_condition "ubuntu-lite")"
juju status --format json | jq '.machines | length' | check 1

# Only do this check if provider is LXD (too hard to do for all providers)
Expand Down
10 changes: 5 additions & 5 deletions tests/suites/branches/active_branch.sh
Expand Up @@ -6,9 +6,9 @@ run_indicate_active_branch_no_active() {

ensure "indicate-active-branch-no-active" "${file}"

juju deploy ubuntu
juju deploy jameinel-ubuntu-lite

wait_for "ubuntu" "$(idle_condition "ubuntu")"
wait_for "ubuntu-lite" "$(idle_condition "ubuntu-lite")"

check_not_contains "$(juju status)" "Branch"

Expand All @@ -28,10 +28,10 @@ run_indicate_active_branch_active() {

ensure "indicate-active-branch-active" "${file}"

juju deploy ubuntu
juju deploy jameinel-ubuntu-lite

juju add-branch bla
wait_for "ubuntu" "$(idle_condition "ubuntu")"
wait_for "ubuntu-lite" "$(idle_condition "ubuntu-lite")"

check_contains "$(juju status)" "bla\*"

Expand All @@ -41,7 +41,7 @@ run_indicate_active_branch_active() {
fi

juju add-branch testtest
wait_for "ubuntu" "$(idle_condition "ubuntu")"
wait_for "ubuntu-lite" "$(idle_condition "ubuntu-lite")"

# juju status can be slow, we might need to wait for testtest to appear
wait_for "active" ".branches.testtest"
Expand Down
2 changes: 1 addition & 1 deletion tests/suites/controller/enable_ha.sh
Expand Up @@ -104,7 +104,7 @@ run_enable_ha() {

ensure "enable-ha" "${file}"

juju deploy ubuntu
juju deploy jameinel-ubuntu-lite

juju enable-ha

Expand Down
12 changes: 6 additions & 6 deletions tests/suites/deploy/bundles/cmr_bundles_test_deploy.yaml
@@ -1,11 +1,11 @@
series: jammy
saas:
mysql:
url: {{BOOTSTRAPPED_JUJU_CTRL_NAME}}:admin/test-cmr-bundles-deploy.mysql
easyrsa:
url: {{BOOTSTRAPPED_JUJU_CTRL_NAME}}:admin/test-cmr-bundles-deploy.easyrsa
applications:
wordpress:
charm: wordpress
etcd:
charm: etcd
num_units: 1
relations:
- - wordpress:db
- mysql:db
- - etcd:certificates
- easyrsa:client
6 changes: 3 additions & 3 deletions tests/suites/deploy/bundles/telegraf_bundle.yaml
@@ -1,17 +1,17 @@
series: focal # charms do not support jammy.
series: focal
applications:
influxdb:
charm: influxdb
channel: stable
revision: 23
revision: 24
num_units: 1
to:
- "0"
constraints: arch=amd64
telegraf:
charm: telegraf
channel: stable
revision: 48
revision: 53
ubuntu:
charm: ubuntu
channel: stable
Expand Down
@@ -1,4 +1,4 @@
series: focal # charms do not support jammy.
series: focal
applications:
influxdb:
charm: influxdb
Expand Down
@@ -1,4 +1,4 @@
series: focal # charms do not support jammy.
series: focal
applications:
influxdb:
charm: influxdb
Expand Down
13 changes: 6 additions & 7 deletions tests/suites/deploy/deploy_bundles.sh
Expand Up @@ -35,11 +35,10 @@ run_deploy_cmr_bundle() {

ensure "test-cmr-bundles-deploy" "${file}"

# mysql charm does not have stable channel, so we use the candidate channel
juju deploy mysql --channel=candidate --force --series jammy
wait_for "mysql" ".applications | keys[0]"
juju deploy easyrsa
wait_for "easyrsa" ".applications | keys[0]"

juju offer mysql:db
juju offer easyrsa:client
juju add-model other

juju switch other
Expand All @@ -51,7 +50,7 @@ run_deploy_cmr_bundle() {
# https://charmhub.io/wordpress
juju deploy "${TEST_DIR}/cmr_bundles_test_deploy.yaml"

wait_for "wordpress" "$(idle_condition "wordpress")"
wait_for "etcd" "$(idle_condition "etcd")"

destroy_model "test-cmr-bundles-deploy"
destroy_model "other"
Expand Down Expand Up @@ -144,7 +143,7 @@ run_deploy_trusted_bundle() {
OUT=$(juju deploy ${bundle} 2>&1 || true)
echo "${OUT}" | check "repeat the deploy command with the --trust argument"

juju deploy --trust ${bundle}
juju deploy --trust ${bundle} --force # TODO: remove --force once "juju-qa-trust-checker" supports jammy.

wait_for "trust-checker" "$(idle_condition "trust-checker")"

Expand All @@ -163,7 +162,7 @@ run_deploy_charmhub_bundle() {
juju deploy "${bundle}"

wait_for "juju-qa-test" "$(charm_channel "juju-qa-test" "2.0/stable")"
wait_for "juju-qa-test-focal" "$(charm_channel "juju-qa-test-focal" "candidate")"
wait_for "juju-qa-test-focal" "$(charm_channel "juju-qa-test-focal" "latest/candidate")"
wait_for "juju-qa-test" "$(idle_condition "juju-qa-test")"
wait_for "juju-qa-test-focal" "$(idle_condition "juju-qa-test-focal" 1)"
wait_for "ntp" "$(idle_subordinate_condition "ntp" "juju-qa-test")"
Expand Down
4 changes: 2 additions & 2 deletions tests/suites/deploy/deploy_charms.sh
Expand Up @@ -5,8 +5,8 @@ run_deploy_charm() {

ensure "test-deploy-charm" "${file}"

juju deploy ubuntu
wait_for "ubuntu" "$(idle_condition "ubuntu")"
juju deploy jameinel-ubuntu-lite
wait_for "ubuntu-lite" "$(idle_condition "ubuntu-lite")"

destroy_model "test-deploy-charm"
}
Expand Down
4 changes: 2 additions & 2 deletions tests/suites/expose_ec2/bundles/invalid.yaml
Expand Up @@ -3,7 +3,7 @@
# parameters in its overlay section
series: jammy
applications:
ubuntu:
ubuntu-lite:
charm: ubuntu
num_units: 1
to:
Expand All @@ -13,7 +13,7 @@ machines:
"0": {}
--- # overlay.yaml
applications:
ubuntu:
ubuntu-lite:
exposed-endpoints:
"":
expose-to-cidrs:
Expand Down
20 changes: 10 additions & 10 deletions tests/suites/expose_ec2/expose_app.sh
Expand Up @@ -6,8 +6,8 @@ run_expose_app_ec2() {
ensure "expose-app" "${file}"

# Deploy test charm
juju deploy ubuntu
wait_for "ubuntu" "$(idle_condition "ubuntu")"
juju deploy jameinel-ubuntu-lite
wait_for "ubuntu-lite" "$(idle_condition "ubuntu-lite")"

# Open ports and verify hook tool behavior
assert_opened_ports_output
Expand All @@ -24,13 +24,13 @@ run_expose_app_ec2() {
assert_opened_ports_output() {
echo "==> Checking open/opened-ports hook tools work as expected"

juju exec --unit ubuntu/0 "open-port 1337-1339/tcp"
juju exec --unit ubuntu/0 "open-port 1234/tcp --endpoints ubuntu"
juju exec --unit ubuntu-lite/0 "open-port 1337-1339/tcp"
juju exec --unit ubuntu-lite/0 "open-port 1234/tcp --endpoints ubuntu"

# Test the backwards-compatible version of opened-ports where the output
# includes the unique set of opened ports for all endpoints.
exp="1234/tcp 1337-1339/tcp"
got=$(juju exec --unit ubuntu/0 "opened-ports" | tr '\n' ' ' | sed -e 's/[[:space:]]*$//')
got=$(juju exec --unit ubuntu-lite/0 "opened-ports" | tr '\n' ' ' | sed -e 's/[[:space:]]*$//')
if [ "$got" != "$exp" ]; then
# shellcheck disable=SC2046
echo $(red "expected opened-ports output to be:\n${exp}\nGOT:\n${got}")
Expand All @@ -39,7 +39,7 @@ assert_opened_ports_output() {

# Try the new version where we group by endpoint.
exp="1234/tcp (ubuntu) 1337-1339/tcp (*)"
got=$(juju exec --unit ubuntu/0 "opened-ports --endpoints" | tr '\n' ' ' | sed -e 's/[[:space:]]*$//')
got=$(juju exec --unit ubuntu-lite/0 "opened-ports --endpoints" | tr '\n' ' ' | sed -e 's/[[:space:]]*$//')
if [ "$got" != "$exp" ]; then
# shellcheck disable=SC2046
echo $(red "expected opened-ports output when using --endpoints to be:\n${exp}\nGOT:\n${got}")
Expand All @@ -50,10 +50,10 @@ assert_opened_ports_output() {
assert_ingress_cidrs_for_exposed_app() {
echo "==> Checking that expose --to-cidrs works as expected"

juju expose ubuntu --to-cidrs 10.0.0.0/24,192.168.0.0/24
juju expose ubuntu --endpoints ubuntu # expose to the world
juju expose ubuntu-lite --to-cidrs 10.0.0.0/24,192.168.0.0/24
juju expose ubuntu-lite --endpoints ubuntu # expose to the world
# overwrite previous command
juju expose ubuntu --endpoints ubuntu --to-cidrs 10.42.0.0/16,2002:0:0:1234::/64
juju expose ubuntu-lite --endpoints ubuntu --to-cidrs 10.42.0.0/16,2002:0:0:1234::/64
sleep 2 # wait for firewall worker to detect and apply the changes

# Range 1337-1339 is opened for all endpoints. We expect it to be reachable
Expand Down Expand Up @@ -108,7 +108,7 @@ assert_export_bundle_output_includes_exposed_endpoints() {
cat <<-EOF
--- # overlay.yaml
applications:
ubuntu:
ubuntu-lite:
exposed-endpoints:
"":
expose-to-cidrs:
Expand Down
20 changes: 10 additions & 10 deletions tests/suites/hooks/reboot.sh
Expand Up @@ -10,8 +10,8 @@ run_start_hook_fires_after_reboot() {
# log level is WARNING.
juju model-config -m "${model_name}" logging-config="<root>=INFO;unit=DEBUG"

juju deploy ubuntu --revision 19 --series focal --channel stable
wait_for "ubuntu" "$(idle_condition "ubuntu")"
juju deploy jameinel-ubuntu-lite --revision 9 --channel stable
wait_for "ubuntu-lite" "$(idle_condition "ubuntu-lite")"

# Ensure that the implicit start hook after reboot detection does not
# fire for the initial charm deployment
Expand All @@ -28,9 +28,9 @@ run_start_hook_fires_after_reboot() {
# does not fire. In juju 2.9+, we use a unified agent so we need to restart
# the machine agent.
echo "[+] ensuring that implicit start hook does not fire after restarting the (unified) unit agent"
juju ssh ubuntu/0 'sudo service jujud-machine-0 restart'
juju ssh ubuntu-lite/0 'sudo service jujud-machine-0 restart'
echo
wait_for "ubuntu" "$(charm_rev "ubuntu" 19)"
wait_for "ubuntu-lite" "$(charm_rev "ubuntu-lite" 9)"
logs=$(juju debug-log --include-module juju.worker.uniter --replay --no-tail | grep -n "reboot detected" || true)
echo "$logs" | sed 's/^/ | /g'
if [ -n "$logs" ]; then
Expand All @@ -39,13 +39,13 @@ run_start_hook_fires_after_reboot() {
exit 1
fi
sleep 1
wait_for "ubuntu" "$(idle_condition "ubuntu")"
wait_for "ubuntu-lite" "$(idle_condition "ubuntu-lite")"

# Ensure that the implicit start hook does not fire after upgrading the unit
juju upgrade-charm ubuntu --revision 20
juju upgrade-charm ubuntu-lite --revision 10
echo
sleep 1
wait_for "ubuntu" "$(charm_rev "ubuntu" 20)"
wait_for "ubuntu-lite" "$(charm_rev "ubuntu-lite" 10)"
logs=$(juju debug-log --include-module juju.worker.uniter --replay --no-tail | grep -n "reboot detected" || true)
echo "$logs" | sed 's/^/ | /g'
if [ -n "$logs" ]; then
Expand All @@ -55,13 +55,13 @@ run_start_hook_fires_after_reboot() {
fi

sleep 1
wait_for "ubuntu" "$(idle_condition "ubuntu")"
wait_for "ubuntu-lite" "$(idle_condition "ubuntu-lite")"

# Trigger a reboot and verify that the implicit start hook fires
echo "[+] ensuring that implicit start hook fires after a machine reboot"
juju ssh ubuntu/0 'sudo reboot now' || true
juju ssh ubuntu-lite/0 'sudo reboot now' || true
sleep 1
wait_for "ubuntu" "$(idle_condition "ubuntu")"
wait_for "ubuntu-lite" "$(idle_condition "ubuntu-lite")"
echo
logs=$(juju debug-log --include-module juju.worker.uniter --replay --no-tail | grep -n "reboot detected" || true)
echo "$logs" | sed 's/^/ | /g'
Expand Down

0 comments on commit a20759e

Please sign in to comment.