github.com/juju/juju@v0.0.0-20240430160146-1752b71fcf00/tests/suites/refresh/switch.sh (about)

     1  run_refresh_switch_local_to_ch_channel() {
     2  	# Test juju refresh from a local charm to a charm hub charm with a specific channel
     3  	echo
     4  
     5  	model_name="test-refresh-local-switch-ch"
     6  	file="${TEST_DIR}/${model_name}.log"
     7  	charm_name="${TEST_DIR}/ubuntu.charm"
     8  
     9  	ensure "${model_name}" "${file}"
    10  
    11  	juju download ubuntu --no-progress - >"${charm_name}"
    12  	juju deploy "${charm_name}" ubuntu
    13  	wait_for "ubuntu" "$(idle_condition "ubuntu")"
    14  
    15  	OUT=$(juju refresh ubuntu --switch ch:ubuntu --channel edge 2>&1 || true)
    16  	if echo "${OUT}" | grep -E -vq "Added charm-hub charm"; then
    17  		# shellcheck disable=SC2046
    18  		echo $(red "failed refreshing charm: ${OUT}")
    19  		exit 5
    20  	fi
    21  	# shellcheck disable=SC2059
    22  	printf "${OUT}\n"
    23  
    24  	# format: Added charm-store charm "ubuntu", revision 21 in channel stable, to the model
    25  	revision=$(echo "${OUT}" | awk 'BEGIN{FS=","} {print $2}' | awk 'BEGIN{FS=" "} {print $2}')
    26  
    27  	wait_for "ubuntu" "$(charm_rev "ubuntu" "${revision}")"
    28  	wait_for "ubuntu" "$(charm_channel "ubuntu" "latest/edge")"
    29  	wait_for "ubuntu" "$(idle_condition "ubuntu")"
    30  
    31  	destroy_model "${model_name}"
    32  }
    33  
    34  test_switch() {
    35  	if [ "$(skip 'test_switch')" ]; then
    36  		echo "==> TEST SKIPPED: refresh switch"
    37  		return
    38  	fi
    39  
    40  	(
    41  		set_verbosity
    42  
    43  		cd .. || exit
    44  
    45  		run "run_refresh_switch_local_to_ch_channel"
    46  	)
    47  }