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

     1  run_hook_dispatching_script() {
     2  	echo
     3  
     4  	model_name="test-hook-dispatching"
     5  	file="${TEST_DIR}/${model_name}.log"
     6  
     7  	ensure "${model_name}" "${file}"
     8  
     9  	# the log messages the test looks for do not appear if root
    10  	# log level is WARNING.
    11  	juju model-config logging-config="<root>=INFO"
    12  
    13  	juju deploy ./testcharms/charms/ubuntu-plus
    14  	wait_for "ubuntu-plus" "$(idle_condition "ubuntu-plus")"
    15  
    16  	juju debug-log --include unit-ubuntu-plus-0 | grep -q "via hook dispatching script: dispatch" || true
    17  
    18  	juju run ubuntu-plus/0 no-dispatch filename=test-dispatch
    19  
    20  	# wait for update-status
    21  	wait_for "Hello from update-status" "$(workload_status ubuntu-plus 0).message"
    22  
    23  	# check it was not via dispatch
    24  	juju debug-log --include unit-ubuntu-plus-0 | grep -q 'ran "update-status" hook (via explicit, bespoke hook script)' || true
    25  
    26  	destroy_model "${model_name}"
    27  }
    28  
    29  test_dispatching_script() {
    30  	if [ "$(skip 'test_dispatching_script')" ]; then
    31  		echo "==> TEST SKIPPED: dispatch"
    32  		return
    33  	fi
    34  
    35  	(
    36  		set_verbosity
    37  
    38  		cd .. || exit
    39  
    40  		run "run_hook_dispatching_script"
    41  	)
    42  }