Run e2e container tests in action (#101)

*
This commit is contained in:
Marc Brugger 2022-10-05 18:15:07 +02:00 committed by GitHub
parent ff104f543d
commit 0206e6173f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
9 changed files with 320 additions and 2 deletions

View file

@ -74,3 +74,44 @@ jobs:
- name: Image digest
run: echo ${{ steps.docker_build.outputs.digest }}
test:
needs: images
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Create kind cluster
uses: helm/kind-action@v1.3.0
with:
version: v0.14.0
kubectl_version: v1.24.0
- name: Start adguardhome instances
run: |
kubectl create namespace agh
kubectl config set-context --current --namespace=agh
kubectl create configmap origin-conf -n agh --from-file testdata/e2e/AdGuardHome.yaml
kubectl apply -f testdata/e2e/agh
kubectl wait --for condition=Ready pod/adguardhome-origin --timeout=30s
kubectl wait --for condition=Ready pod/adguardhome-replica --timeout=30s
- name: Start adguardhome-sync
run: |
kubectl create configmap sync-conf --from-env-file=testdata/e2e/sync-conf.properties
kubectl apply -f testdata/e2e/pod-adguardhome-sync.yaml
kubectl wait --for=jsonpath='{.status.phase}'=Running pod/adguardhome-sync --timeout=30s
- name: Show origin Logs
run: |
echo adguardhome-origin
kubectl logs adguardhome-origin
- name: Show Replica Logs
run: |
echo adguardhome-replica
kubectl logs adguardhome-replica
ERRORS=$(kubectl logs adguardhome-replica | grep '\[error\]' | wc -l)
echo "Found ${ERRORS} error(s) in log";
- name: Show Sync Logs
run: |
echo adguardhome-sync
kubectl logs adguardhome-sync
ERRORS=$(kubectl logs adguardhome-sync | grep Error | wc -l)
echo "Found ${ERRORS} error(s) in log";
if [[ "${ERRORS}" != "0" ]]; then exit 1; fi

View file

@ -45,8 +45,8 @@ ifeq (, $(shell which deepcopy-gen))
endif
start-replica:
podman run --pull always --rm -it -p 9090:80 -p 9091:3000 adguard/adguardhome
# podman run --pull always --rm -it -p 9090:80 -p 9091:3000 adguard/adguardhome:v0.107.13
podman run --pull always --name adguardhome-replica -p 9090:80 -p 9091:3000 --rm adguard/adguardhome
# podman run --pull always --name adguardhome-replica -p 9090:80 -p 9091:3000 --rm adguard/adguardhome:v0.107.13
check_defined = \
$(strip $(foreach 1,$1, \
@ -58,3 +58,19 @@ __check_defined = \
build-image:
$(call check_defined, AGH_SYNC_VERSION)
podman build --build-arg VERSION=${AGH_SYNC_VERSION} --build-arg BUILD=$(shell date -u +'%Y-%m-%dT%H:%M:%S.%3NZ') --name adgardhome-replica -t ghcr.io/bakito/adguardhome-sync:${AGH_SYNC_VERSION} .
kind-create:
kind delete cluster
kind create cluster
kind-test:
kubectl create namespace agh
kubectl config set-context --current --namespace=agh
kubectl create configmap origin-conf --from-file testdata/e2e/AdGuardHome.yaml
kubectl apply -f testdata/e2e/agh
kubectl wait --for condition=Ready pod/adguardhome-origin --timeout=30s
kubectl wait --for condition=Ready pod/adguardhome-replica --timeout=30s
kubectl create configmap sync-conf --from-env-file=testdata/e2e/sync-conf.properties
kubectl apply -f testdata/e2e/pod-adguardhome-sync.yaml
kubectl wait --for=jsonpath='{.status.phase}'=Running pod/adguardhome-sync --timeout=30s

167
testdata/e2e/AdGuardHome.yaml vendored Normal file
View file

@ -0,0 +1,167 @@
bind_host: 0.0.0.0
bind_port: 3000
beta_bind_port: 0
users:
- name: username
password: $2a$10$yrrX.EvDpUUnZxr74u6euOMeF6dPFd/mEyohDq1LkpH76JyeObPBm
auth_attempts: 5
block_auth_min: 15
http_proxy: ""
language: en
debug_pprof: false
web_session_ttl: 720
dns:
bind_hosts:
- 0.0.0.0
port: 53
statistics_interval: 1
querylog_enabled: true
querylog_file_enabled: true
querylog_interval: 6h
querylog_size_memory: 1000
anonymize_client_ip: false
protection_enabled: true
blocking_mode: default
blocking_ipv4: ""
blocking_ipv6: ""
blocked_response_ttl: 10
parental_block_host: family-block.dns.adguard.com
safebrowsing_block_host: standard-block.dns.adguard.com
ratelimit: 20
ratelimit_whitelist: []
refuse_any: true
upstream_dns:
- https://dns10.quad9.net/dns-query
upstream_dns_file: ""
bootstrap_dns:
- 1.1.1.1:53
all_servers: false
fastest_addr: false
fastest_timeout: 1s
allowed_clients: []
disallowed_clients: []
blocked_hosts:
- version.bind
- id.server
- hostname.bind
trusted_proxies:
- 127.0.0.0/8
- ::1/128
cache_size: 4194304
cache_ttl_min: 0
cache_ttl_max: 0
cache_optimistic: true
bogus_nxdomain: []
aaaa_disabled: false
enable_dnssec: false
edns_client_subnet: false
max_goroutines: 300
handle_ddr: true
ipset: []
ipset_file: ""
filtering_enabled: true
filters_update_interval: 12
parental_enabled: true
safesearch_enabled: true
safebrowsing_enabled: true
safebrowsing_cache_size: 1048576
safesearch_cache_size: 1048576
parental_cache_size: 1048576
cache_time: 30
rewrites:
- domain: foo.bar.com
answer: 1.2.3.4
blocked_services:
- 9gag
- dailymotion
upstream_timeout: 10s
private_networks: []
use_private_ptr_resolvers: true
local_ptr_upstreams: []
serve_http3: false
use_http3_upstreams: false
tls:
enabled: false
server_name: ""
force_https: false
port_https: 443
port_dns_over_tls: 853
port_dns_over_quic: 853
port_dnscrypt: 0
dnscrypt_config_file: ""
allow_unencrypted_doh: false
strict_sni_check: false
certificate_chain: ""
private_key: ""
certificate_path: ""
private_key_path: ""
filters:
- enabled: true
url: https://adguardteam.github.io/AdGuardSDNSFilter/Filters/filter.txt
name: AdGuard DNS filter
id: 1
- enabled: true
url: https://adaway.org/hosts.txt
name: AdAway Default Blocklist
id: 2
whitelist_filters: []
user_rules:
- '||metrics2.data.hicloud.com^$important'
- '||www.curiouscorrespondence.com^$important'
- '||bluewizard.com^$important'
- '||facebook.com^$important'
dhcp:
enabled: false
interface_name: eth0
local_domain_name: lan
dhcpv4:
gateway_ip: 1.2.3.4
subnet_mask: 255.255.0.0
range_start: 1.2.3.5
range_end: 1.2.3.56
lease_duration: 86400
icmp_timeout_msec: 1000
options: []
dhcpv6:
range_start: ""
lease_duration: 86400
ra_slaac_only: false
ra_allow_slaac: false
clients:
runtime_sources:
whois: true
arp: true
rdns: true
dhcp: true
hosts: true
persistent:
- name: Device 1
tags:
- device_1
ids:
- 2.2.2.2
blocked_services:
- facebook
- ok
- vk
- mail_ru
- qq
upstreams: []
use_global_settings: true
filtering_enabled: false
parental_enabled: false
safesearch_enabled: false
safebrowsing_enabled: false
use_global_blocked_services: false
log_file: ""
log_max_backups: 0
log_max_size: 100
log_max_age: 3
log_compress: false
log_localtime: false
verbose: false
os:
group: ""
user: ""
rlimit_nofile: 0
schema_version: 14

View file

@ -0,0 +1,35 @@
apiVersion: v1
kind: Pod
metadata:
name: adguardhome-origin
labels:
app.kubernetes.io/name: adguardhome-origin
spec:
volumes:
- name: configmap
configMap:
name: origin-conf
- name: conf
emptyDir: { }
initContainers:
- name: init
image: busybox
volumeMounts:
- mountPath: /opt/adguardhome/configmap
name: configmap
- mountPath: /opt/adguardhome/conf
name: conf
command:
- cp
- /opt/adguardhome/configmap/AdGuardHome.yaml
- /opt/adguardhome/conf
containers:
- name: adguardhome
image: adguard/adguardhome:latest
volumeMounts:
- mountPath: /opt/adguardhome/conf
name: conf
ports:
- containerPort: 3000

View file

@ -0,0 +1,12 @@
apiVersion: v1
kind: Pod
metadata:
name: adguardhome-replica
labels:
app.kubernetes.io/name: adguardhome-replica
spec:
containers:
- name: adguardhome
image: adguard/adguardhome:latest
ports:
- containerPort: 3000

11
testdata/e2e/agh/service-origin.yaml vendored Normal file
View file

@ -0,0 +1,11 @@
apiVersion: v1
kind: Service
metadata:
name: service-origin
spec:
selector:
app.kubernetes.io/name: adguardhome-origin
ports:
- protocol: TCP
port: 3000
targetPort: 3000

11
testdata/e2e/agh/service-replica.yaml vendored Normal file
View file

@ -0,0 +1,11 @@
apiVersion: v1
kind: Service
metadata:
name: service-replica
spec:
selector:
app.kubernetes.io/name: adguardhome-replica
ports:
- protocol: TCP
port: 3000
targetPort: 3000

15
testdata/e2e/pod-adguardhome-sync.yaml vendored Normal file
View file

@ -0,0 +1,15 @@
apiVersion: v1
kind: Pod
metadata:
name: adguardhome-sync
spec:
containers:
- name: adguardhome-sync
image: ghcr.io/bakito/adguardhome-sync:main
command:
- /opt/go/adguardhome-sync
- run
envFrom:
- configMapRef:
name: sync-conf
restartPolicy: Never

10
testdata/e2e/sync-conf.properties vendored Normal file
View file

@ -0,0 +1,10 @@
API_PORT=0
LOG_LEVEL=info
ORIGIN_URL=http://service-origin.agh.svc.cluster.local:3000
ORIGIN_PASSWORD=password
ORIGIN_USERNAME=username
REPLICA1_AUTOSETUP=true
REPLICA1_URL=http://service-replica.agh.svc.cluster.local:3000
REPLICA1_INTERFACWENAME=foo
REPLICA1_PASSWORD=password
REPLICA1_USERNAME=username