start e2e tests with helm (#102)

* use helm for e2e test

* wait for pods

* update action
This commit is contained in:
Marc Brugger 2022-10-06 20:58:11 +02:00 committed by GitHub
parent 630d9c8eef
commit 31d91adb42
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
17 changed files with 335 additions and 229 deletions

View file

@ -85,32 +85,24 @@ jobs:
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}'=Succeeded pod/adguardhome-sync --timeout=30s
- name: Install Hel Chart
run: helm install agh-e2e testdata/e2e/agh-e2e -n agh-e2e --create-namespace
- name: Show origin Logs
run: |
echo adguardhome-origin
echo Pod adguardhome-origin logs
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";
for pod in $(kubectl get pods -l bakito.net/adguardhome-sync=replica -o name); do
echo Pod "${pod} logs"
kubectl logs ${pod}
ERRORS=$(kubectl logs ${pod} | grep '\[error\]' | wc -l)
echo "Found ${ERRORS} error(s) in log"
echo "----------------------------------------------"
done
- name: Show Sync Logs
run: |
echo adguardhome-sync
echo Pod adguardhome-sync logs
kubectl logs adguardhome-sync
ERRORS=$(kubectl logs adguardhome-sync | grep Error | wc -l)
echo "Found ${ERRORS} error(s) in log";

View file

@ -64,13 +64,5 @@ kind-create:
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
helm delete agh-e2e -n agh-e2e
helm install agh-e2e testdata/e2e/agh-e2e -n agh-e2e --create-namespace

View file

@ -1,167 +0,0 @@
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

23
testdata/e2e/agh-e2e/.helmignore vendored Normal file
View file

@ -0,0 +1,23 @@
# Patterns to ignore when building packages.
# This supports shell glob matching, relative path matching, and
# negation (prefixed with !). Only one pattern per line.
.DS_Store
# Common VCS dirs
.git/
.gitignore
.bzr/
.bzrignore
.hg/
.hgignore
.svn/
# Common backup files
*.swp
*.bak
*.tmp
*.orig
*~
# Various IDEs
.project
.idea/
*.tmproj
.vscode/

8
testdata/e2e/agh-e2e/Chart.yaml vendored Normal file
View file

@ -0,0 +1,8 @@
apiVersion: v2
name: agh-e2e
description: adguardhome sync test charts
type: application
version: 0.1.0
appVersion: "1.16.0"

View file

@ -0,0 +1,174 @@
apiVersion: v1
kind: ConfigMap
metadata:
name: origin-conf
namespace: {{ .Release.Namespace }}
data:
AdGuardHome.yaml: |
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,17 @@
apiVersion: v1
kind: ConfigMap
metadata:
name: sync-conf
namespace: {{ .Release.Namespace }}
data:
API_PORT: "0"
LOG_LEVEL: info
ORIGIN_URL: http://service-origin.{{ $.Release.Namespace }}.svc.cluster.local:3000
ORIGIN_PASSWORD: password
ORIGIN_USERNAME: username
{{ range $i,$_ := .Values.replica.versions }}
REPLICA{{ $i }}_AUTOSETUP: "true"
REPLICA{{ $i }}_URL: http://service-replica-{{ $i }}.{{ $.Release.Namespace }}.svc.cluster.local:3000
REPLICA{{ $i }}_PASSWORD: password
REPLICA{{ $i }}_USERNAME: username
{{- end }}

View file

@ -2,8 +2,10 @@ apiVersion: v1
kind: Pod
metadata:
name: adguardhome-origin
namespace: {{ $.Release.Namespace }}
labels:
app.kubernetes.io/name: adguardhome-origin
bakito.net/adguardhome-sync: origin
spec:
volumes:
- name: configmap

View file

@ -0,0 +1,17 @@
{{ range $i, $version := .Values.replica.versions }}
apiVersion: v1
kind: Pod
metadata:
name: adguardhome-replica-{{ $i }}
namespace: {{ $.Release.Namespace }}
labels:
app.kubernetes.io/name: adguardhome-replica-{{ $i }}
bakito.net/adguardhome-sync: replica
spec:
containers:
- name: adguardhome
image: "adguard/adguardhome:{{ $version }}"
ports:
- containerPort: 3000
---
{{- end }}

View file

@ -0,0 +1,29 @@
apiVersion: v1
kind: Pod
metadata:
name: adguardhome-sync
namespace: {{ $.Release.Namespace }}
spec:
serviceAccountName: agh-e2e
initContainers:
- name: wait-for-others
image: bitnami/kubectl:1.24
command:
- /bin/bash
- -c
- |
#!/bin/bash
echo "wait for adguardhome pods"
for pod in $(kubectl get pods -l bakito.net/adguardhome-sync -o name); do
kubectl wait --for condition=Ready ${pod} --timeout=30s
done
containers:
- name: adguardhome-sync
image: ghcr.io/bakito/adguardhome-sync:main
command:
- /opt/go/adguardhome-sync
- run
envFrom:
- configMapRef:
name: sync-conf
restartPolicy: Never

View file

@ -0,0 +1,32 @@
apiVersion: v1
kind: ServiceAccount
metadata:
name: agh-e2e
namespace: {{ .Release.Namespace }}
---
apiVersion: rbac.authorization.k8s.io/v1
kind: Role
metadata:
name: agh-e2e
namespace: {{ .Release.Namespace }}
rules:
- apiGroups: [ "" ]
resources: [ "pods" ]
verbs: [ "get", "watch", "list" ]
---
apiVersion: rbac.authorization.k8s.io/v1
kind: RoleBinding
metadata:
name: agh-e2e
namespace: {{ .Release.Namespace }}
subjects:
- kind: ServiceAccount
name: agh-e2e
roleRef:
kind: Role
name: agh-e2e
apiGroup: rbac.authorization.k8s.io

View file

@ -2,6 +2,7 @@ apiVersion: v1
kind: Service
metadata:
name: service-origin
namespace: {{ $.Release.Namespace }}
spec:
selector:
app.kubernetes.io/name: adguardhome-origin

View file

@ -0,0 +1,14 @@
{{ range $i ,$_ := .Values.replica.versions }}
apiVersion: v1
kind: Service
metadata:
name: service-replica-{{ $i }}
spec:
selector:
app.kubernetes.io/name: adguardhome-replica-{{ $i }}
ports:
- protocol: TCP
port: 3000
targetPort: 3000
---
{{- end }}

5
testdata/e2e/agh-e2e/values.yaml vendored Normal file
View file

@ -0,0 +1,5 @@
replica:
versions:
- latest
- v0.107.13
- v0.107.15

View file

@ -1,12 +0,0 @@
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

View file

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

View file

@ -1,10 +0,0 @@
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