Skip to content

Commit

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

Merge branch '2.9' into 2.9-into-develop

```
# Conflicts:
# go.mod
# go.sum
# state/charm_test.go
# tests/suites/hooks/dispatch.sh
# tests/
```

- #14540
- #14550
- #14546
- #14552
- #14553
- #14556
  • Loading branch information
jujubot committed Sep 2, 2022
2 parents fe7bac2 + 146db10 commit 0672ac5
Show file tree
Hide file tree
Showing 23 changed files with 106 additions and 102 deletions.
6 changes: 6 additions & 0 deletions cmd/juju/charmhub/doc.go
@@ -0,0 +1,6 @@
// Copyright 2022 Canonical Ltd.
// Licensed under the AGPLv3, see LICENCE file for details.

// Package charmhub implements the Charmhub-related CLI commands, such as
// "juju download", "juju find", and "juju info".
package charmhub
16 changes: 8 additions & 8 deletions cmd/juju/charmhub/infowriter.go
Expand Up @@ -107,13 +107,13 @@ func (iw infoWriter) writeClosedChannelToBuffer(w *UnicodeWriter, name string, h

type bundleInfoOutput struct {
Name string `yaml:"name,omitempty"`
ID string `yaml:"bundle-id,omitempty"`
Summary string `yaml:"summary,omitempty"`
Publisher string `yaml:"publisher,omitempty"`
Summary string `yaml:"summary,omitempty"`
Description string `yaml:"description,omitempty"`
StoreURL string `yaml:"store-url,omitempty"`
ID string `yaml:"bundle-id,omitempty"`
Supports string `yaml:"supports,omitempty"`
Tags string `yaml:"tags,omitempty"`
StoreURL string `yaml:"store-url,omitempty"`
Description string `yaml:"description,omitempty"`
Charms string `yaml:"charms,omitempty"`
Channels string `yaml:"channels,omitempty"`
Installed string `yaml:"installed,omitempty"`
Expand All @@ -138,14 +138,14 @@ func (b bundleInfoWriter) Print() error {

type charmInfoOutput struct {
Name string `yaml:"name,omitempty"`
ID string `yaml:"charm-id,omitempty"`
Summary string `yaml:"summary,omitempty"`
Publisher string `yaml:"publisher,omitempty"`
Summary string `yaml:"summary,omitempty"`
Description string `yaml:"description,omitempty"`
StoreURL string `yaml:"store-url,omitempty"`
ID string `yaml:"charm-id,omitempty"`
Supports string `yaml:"supports,omitempty"`
Tags string `yaml:"tags,omitempty"`
Subordinate bool `yaml:"subordinate"`
StoreURL string `yaml:"store-url,omitempty"`
Description string `yaml:"description,omitempty"`
Relations relationOutput `yaml:"relations,omitempty"`
Channels string `yaml:"channels,omitempty"`
Installed string `yaml:"installed,omitempty"`
Expand Down
26 changes: 13 additions & 13 deletions cmd/juju/charmhub/infowriter_test.go
Expand Up @@ -27,16 +27,16 @@ func (s *printInfoSuite) TestCharmPrintInfo(c *gc.C) {

obtained := ctx.Stdout.(*bytes.Buffer).String()
expected := `name: wordpress
charm-id: charmCHARMcharmCHARMcharmCHARM01
summary: WordPress is a full featured web blogging tool, this charm deploys it.
publisher: Wordress Charmers
supports: bionic, xenial
tags: app, seven
subordinate: true
summary: WordPress is a full featured web blogging tool, this charm deploys it.
description: |-
This will install and setup WordPress optimized to run in the cloud.
By default it will place Ngnix and php-fpm configured to scale horizontally with
Nginx's reverse proxy.
charm-id: charmCHARMcharmCHARMcharmCHARM01
supports: bionic, xenial
tags: app, seven
subordinate: true
relations:
provides:
one: two
Expand All @@ -61,16 +61,16 @@ func (s *printInfoSuite) TestCharmPrintInfoWithConfig(c *gc.C) {

obtained := ctx.Stdout.(*bytes.Buffer).String()
expected := `name: wordpress
charm-id: charmCHARMcharmCHARMcharmCHARM01
summary: WordPress is a full featured web blogging tool, this charm deploys it.
publisher: Wordress Charmers
supports: bionic, xenial
tags: app, seven
subordinate: true
summary: WordPress is a full featured web blogging tool, this charm deploys it.
description: |-
This will install and setup WordPress optimized to run in the cloud.
By default it will place Ngnix and php-fpm configured to scale horizontally with
Nginx's reverse proxy.
charm-id: charmCHARMcharmCHARMcharmCHARM01
supports: bionic, xenial
tags: app, seven
subordinate: true
relations:
provides:
one: two
Expand Down Expand Up @@ -149,11 +149,11 @@ func (s *printInfoSuite) TestBundlePrintInfo(c *gc.C) {

obtained := ctx.Stdout.(*bytes.Buffer).String()
expected := `name: osm
bundle-id: bundleBUNDLEbundleBUNDLEbundle01
summary: A bundle by charmed-osm.
publisher: charmed-osm
tags: networking
summary: A bundle by charmed-osm.
description: Single instance OSM bundle.
bundle-id: bundleBUNDLEbundleBUNDLEbundle01
tags: networking
channels: |
latest/stable: 1.0.3 2019-12-16 (16) 12MB
latest/candidate: 1.0.3 2019-12-16 (17) 12MB
Expand Down
5 changes: 2 additions & 3 deletions state/charm_test.go
Expand Up @@ -815,10 +815,9 @@ actions:
`

func (s *CharmTestHelperSuite) TestActionsCharm(c *gc.C) {
actions, err := charm.ReadActionsYaml("somecharm", bytes.NewBuffer([]byte(actionsYaml)))
c.Assert(err, jc.ErrorIsNil)

forEachStandardCharm(c, func(name string) {
actions, err := charm.ReadActionsYaml(name, bytes.NewBuffer([]byte(actionsYaml)))
c.Assert(err, jc.ErrorIsNil)
ch := s.AddActionsCharm(c, name, actionsYaml, 123)
c.Assert(ch.Actions(), gc.DeepEquals, actions)
})
Expand Down
4 changes: 4 additions & 0 deletions testcharms/charm-hub/bundles/juju-qa-bundle-test/README.md
Expand Up @@ -4,6 +4,10 @@

A bundle to use in testing juju.

In the latest/stable channel:
* Revision 2 has a default series of bionic, and uses focal too.
* Revision 3 has a default series of jammy, and uses focal too.

## Usage

Basic deploy: <br>
Expand Down
81 changes: 22 additions & 59 deletions testcharms/charm-hub/bundles/juju-qa-bundle-test/bundle.yaml
@@ -1,74 +1,37 @@
name: juju-qa-bundle-test
series: bionic
series: jammy
applications:
easyrsa:
charm: containers-easyrsa
channel: stable
num_units: 1
to:
- lxd:0
annotations:
gui-x: "450"
gui-y: "550"
etcd:
charm: etcd
channel: stable
num_units: 1
to:
- "0"
options:
channel: 3.2/stable
annotations:
gui-x: "800"
gui-y: "550"
flannel:
charm: containers-flannel
channel: stable
juju-qa-test:
charm: juju-qa-test
channel: 2.0/stable
kubernetes-master:
charm: containers-kubernetes-master
channel: stable
num_units: 1
to:
- "0"
expose: true
options:
channel: 1.12/stable
kubernetes-worker:
charm: containers-kubernetes-worker
channel: stable
constraints: arch=amd64
juju-qa-test-focal:
charm: juju-qa-test
channel: latest/candidate
num_units: 1
series: focal
to:
- "1"
expose: true
options:
channel: 1.12/stable
proxy-extra-args: proxy-mode=userspace
constraints: arch=amd64
ntp:
charm: ntp
channel: stable
ntp-focal:
charm: ntp
channel: stable
series: focal
machines:
"0":
constraints: arch=amd64 cores=2 mem=4G root-disk=16G
series: bionic
constraints: arch=amd64
series: jammy
"1":
constraints: arch=amd64 cores=4 mem=8G root-disk=20G
series: bionic
constraints: arch=amd64
series: focal
relations:
- - flannel:cni
- kubernetes-worker:cni
- - flannel:cni
- kubernetes-master:cni
- - kubernetes-worker:certificates
- easyrsa:client
- - etcd:certificates
- easyrsa:client
- - kubernetes-master:certificates
- easyrsa:client
- - kubernetes-master:kube-control
- kubernetes-worker:kube-control
- - kubernetes-master:kube-api-endpoint
- kubernetes-worker:kube-api-endpoint
- - flannel:etcd
- etcd:db
- - kubernetes-master:etcd
- etcd:db
- - ntp:juju-info
- juju-qa-test:juju-info
- - ntp-focal:juju-info
- juju-qa-test-focal:juju-info
Expand Up @@ -3,5 +3,5 @@ parts:
bundle:
prime: ["bundle.yaml", "README.md"]
charmhub:
api_url: https://api.charmhub.io
storage_url: https://storage.snapcraftcontent.com
api-url: https://api.charmhub.io
storage-url: https://storage.snapcraftcontent.com
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Expand Up @@ -7,4 +7,4 @@ series:
- focal
- bionic
- xenial
- quantal
- jammy
File renamed without changes.
File renamed without changes.
12 changes: 12 additions & 0 deletions tests/suites/ck/ck.sh
Expand Up @@ -29,6 +29,18 @@ run_deploy_ck() {
storage_path="./tests/suites/ck/storage/${BOOTSTRAP_PROVIDER}.yaml"
kubectl create -f "${storage_path}"
kubectl get sc -o yaml

# The model teardown could take too long time, so we decided to kill controller to speed up test run time.
# But this will not give the chance for integrator charm to do proper cleanup:
# - https://github.com/juju-solutions/charm-aws-integrator/blob/master/lib/charms/layer/aws.py#L616
# - especially the tag cleanup: https://github.com/juju-solutions/charm-aws-integrator/blob/master/lib/charms/layer/aws.py#L616
# This will leave the tags created by the integrater charm on subnets forever.
# And on AWS, the maximum number of tags per resource is 50.
# Then we will get `Error while granting requests (TagLimitExceeded); check credentials and debug-log` error in next test run.
# So we purge the subnet tags here in advance as a workaround.
integrator_app_name=$(cat "$overlay_path" | yq '.applications | keys | .[] | select(.== "*integrator")')
juju --show-log run-action "$integrator_app_name/leader" --wait=10m purge-subnet-tags
# juju --show-log run "$integrator_app_name/leader"--wait=10m purge-subnet-tags # 3.0
}

# Ensure that a CAAS workload (mariadb+mediawiki) deploys successfully,
Expand Down
4 changes: 1 addition & 3 deletions tests/suites/hooks/dispatch.sh
Expand Up @@ -10,9 +10,7 @@ run_hook_dispatching_script() {
# log level is WARNING.
juju model-config logging-config="<root>=INFO"

# TODO - upgrade the charm to support focal
juju deploy juju-qa-ubuntu-plus --channel=beta --series focal --force

juju deploy ./testcharms/charms/ubuntu-plus
wait_for "ubuntu-plus" "$(idle_condition "ubuntu-plus")"

juju debug-log --include unit-ubuntu-plus-0 | grep -q "via hook dispatching script: dispatch" || true
Expand Down
48 changes: 35 additions & 13 deletions tests/suites/model/migration.sh
Expand Up @@ -54,6 +54,9 @@ run_model_migration() {
# - Migrates from stable -> devel controller
# - Asserts the deployed application continues to work
run_model_migration_version() {
# Record the current value then restore later once this run done.
SHORT_GIT_COMMIT_VALUE="$SHORT_GIT_COMMIT"
JUJU_VERSION_VALUE="$JUJU_VERSION"
# Reset JUJU_VERSION and SHORT_GIT_COMMIT for stable bootstrap
unset SHORT_GIT_COMMIT
juju_version_without_build_number=$(echo "$JUJU_VERSION" | sed "s/.$JUJU_BUILD_NUMBER//")
Expand All @@ -73,8 +76,6 @@ run_model_migration_version() {
fi
export JUJU_VERSION=$stable_version

# Unset to re-generate from the new agent-version.
unset BOOTSTRAP_ADDITIONAL_ARGS
# Ensure we have another controller available.
bootstrap_alt_controller "alt-model-migration-version-stable"
juju --show-log switch "alt-model-migration-version-stable"
Expand Down Expand Up @@ -127,13 +128,17 @@ run_model_migration_version() {
wait_for "active" "$(workload_status "etcd" 3).current"
wait_for "active" "$(workload_status "etcd" 4).current"

# juju --show-log run etcd/0 etcd/1 etcd/2 etcd/3 etcd/4 --wait=50m health # 3.0
juju --show-log run-action etcd/0 etcd/1 etcd/2 etcd/3 etcd/4 --wait=50m health # 2.9
# juju --show-log run etcd/0 etcd/1 etcd/2 etcd/3 etcd/4 --wait=10m health # 3.0
juju --show-log run-action etcd/0 etcd/1 etcd/2 etcd/3 etcd/4 --wait=10m health # 2.9

# Clean up.
destroy_controller "alt-model-migration-version-stable"

destroy_model "model-migration-version-stable"

# Restore these two environment variables for the rest of the tests.
export SHORT_GIT_COMMIT="$SHORT_GIT_COMMIT_VALUE"
export JUJU_VERSION="$JUJU_VERSION_VALUE"
}

# Migrating a model that is the offerer of a cross-model relation
Expand Down Expand Up @@ -161,13 +166,19 @@ run_model_migration_saas_common() {

wait_for "dummy-sink" "$(idle_condition "dummy-sink")"

juju consume "${BOOTSTRAPPED_JUJU_CTRL_NAME}:admin/model-migration-saas.dummy-source"
juju relate dummy-sink dummy-source
juju --show-log consume "${BOOTSTRAPPED_JUJU_CTRL_NAME}:admin/model-migration-saas.dummy-source"
juju --show-log relate dummy-sink dummy-source
# wait for relation joined before migrate.
# work around for fixing:
# ERROR source prechecks failed: unit dummy-source/0 hasn't joined relation "dummy-source:sink remote-abaa4396b3ae409981ad83d1d04af21f:source" yet
wait_for "dummy-source" '.applications["dummy-sink"] | .relations.source[0]'
sleep 30

juju switch "model-migration-saas"
wait_for "1" '.offers["dummy-source"]["active-connected-count"]'

juju migrate "model-migration-saas" "alt-model-migration-saas"
juju --show-log migrate "model-migration-saas" "alt-model-migration-saas"
sleep 5
juju switch "alt-model-migration-saas"

# Wait for the new model migration to appear in the alt controller.
Expand Down Expand Up @@ -224,13 +235,17 @@ run_model_migration_saas_external() {

wait_for "dummy-sink" "$(idle_condition "dummy-sink")"

juju consume "${BOOTSTRAPPED_JUJU_CTRL_NAME}:admin/model-migration-saas.dummy-source"
juju relate dummy-sink dummy-source
juju --show-log consume "${BOOTSTRAPPED_JUJU_CTRL_NAME}:admin/model-migration-saas.dummy-source"
juju --show-log relate dummy-sink dummy-source
# wait for relation joined before migrate.
wait_for "dummy-source" '.applications["dummy-sink"] | .relations.source[0]'
sleep 30

juju switch "${BOOTSTRAPPED_JUJU_CTRL_NAME}"
wait_for "1" '.offers["dummy-source"]["active-connected-count"]'

juju migrate "model-migration-saas" "model-migration-saas-target"
juju --show-log migrate "model-migration-saas" "model-migration-saas-target"
sleep 5
juju switch "model-migration-saas-target"

# Wait for the new model migration to appear in the target controller.
Expand Down Expand Up @@ -288,15 +303,19 @@ run_model_migration_saas_consumer() {

wait_for "dummy-sink" "$(idle_condition "dummy-sink")"

juju consume "${BOOTSTRAPPED_JUJU_CTRL_NAME}:admin/model-migration-saas.dummy-source"
juju relate dummy-sink dummy-source
juju --show-log consume "${BOOTSTRAPPED_JUJU_CTRL_NAME}:admin/model-migration-saas.dummy-source"
juju --show-log relate dummy-sink dummy-source
# wait for relation joined before migrate.
wait_for "dummy-source" '.applications["dummy-sink"] | .relations.source[0]'
sleep 30

juju switch "${BOOTSTRAPPED_JUJU_CTRL_NAME}"
juju config dummy-source token=wait-for-it
juju switch "model-migration-saas-consume"
wait_for "wait-for-it" "$(workload_status "dummy-sink" 0).message"

juju migrate "model-migration-consumer" "model-migration-saas-target"
juju --show-log migrate "model-migration-consumer" "model-migration-saas-target"
sleep 5
juju switch "model-migration-saas-target"

# Wait for the new model migration to appear in the target controller.
Expand Down Expand Up @@ -355,6 +374,9 @@ bootstrap_alt_controller() {
START_TIME=$(date +%s)
echo "====> Bootstrapping ${name}"

# Unset to re-generate from the new agent-version.
unset BOOTSTRAP_ADDITIONAL_ARGS

file="${TEST_DIR}/${name}.log"
juju_bootstrap "${BOOTSTRAP_CLOUD}" "${name}" "misc" "${file}"

Expand Down

0 comments on commit 0672ac5

Please sign in to comment.