Skip to content

Commit ce4d946

Browse files
author
Juan Tirado
committed
Add proxy to controller in testing.
1 parent 1c617c4 commit ce4d946

1 file changed

Lines changed: 26 additions & 0 deletions

File tree

.github/workflows/test.yaml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,32 @@ jobs:
4242
with:
4343
provider: lxd
4444
juju-channel: 3.0/stable
45+
- name: Set proxy in controller
46+
run: |
47+
set -euxo pipefail
48+
# build a squid config file
49+
CONTROLLER_IP=$(juju list-controllers --format yaml | yq '.controllers[.current-controller].recent-server' | awk -F '[:]' '{print $1}');
50+
echo "Controller IP is: $CONTROLLER_IP"
51+
PROXY=$CONTROLLER_IP:3128
52+
echo "Proxy address is: $PROXY"
53+
echo "acl all src all" > /tmp/squid.conf
54+
echo "http_access allow all" >> /tmp/squid.conf
55+
echo "http_port $PROXY" >> /tmp/squid.conf
56+
cat /tmp/squid.conf
57+
# copy to the controller and reconfigure it
58+
juju status -m controller
59+
juju switch controller
60+
juju ssh 0 "sudo apt-get install squid -y"
61+
juju scp /tmp/squid.conf 0:/tmp/squid.conf
62+
juju ssh 0 "sudo mv /tmp/squid.conf /etc/squid/squid.conf"
63+
juju ssh 0 "sudo squid -k reconfigure"
64+
# Test curl after waiting
65+
sleep 10
66+
echo "Test proxy access"
67+
curl -s -o /dev/null -w "%{http_code}" --proxy http://$PROXY https://charmhub.io
68+
# set model defaults
69+
juju model-defaults localhost apt-http-proxy=$PROXY apt-https-proxy=$PROXY juju-http-proxy=$PROXY juju-https-proxy=$PROXY snap-http-proxy=$PROXY snap-https-proxy=$PROXY
70+
juju model-defaults localhost
4571
- name: Setup Python
4672
uses: actions/setup-python@v4
4773
with:

0 commit comments

Comments
 (0)