Dump out proxy access logs in TestSupervisorLogin.

Signed-off-by: Matt Moyer <moyerm@vmware.com>
This commit is contained in:
Matt Moyer 2020-12-03 11:28:48 -06:00
parent 954591d2db
commit cb5e494815
No known key found for this signature in database
GPG Key ID: EAE88AD172C5AE2D
3 changed files with 20 additions and 3 deletions

View File

@ -20,6 +20,9 @@ spec:
labels:
app: proxy
spec:
volumes:
- name: log-dir
emptyDir: {}
containers:
- name: proxy
image: docker.io/getpinniped/test-forward-proxy
@ -34,6 +37,9 @@ spec:
limits:
cpu: "10m"
memory: "64Mi"
volumeMounts:
- name: log-dir
mountPath: "/var/log/squid/"
readinessProbe:
tcpSocket:
port: http
@ -41,6 +47,16 @@ spec:
timeoutSeconds: 5
periodSeconds: 5
failureThreshold: 2
- name: accesslogs
image: debian:10.6-slim
command:
- "/bin/sh"
- "-c"
args:
- tail -F /var/log/squid/access.log
volumeMounts:
- name: log-dir
mountPath: "/var/log/squid/"
---
apiVersion: v1
kind: Service

View File

@ -35,7 +35,8 @@ func TestSupervisorLogin(t *testing.T) {
env := library.IntegrationEnv(t)
// If anything in this test crashes, dump out the supervisor pod logs.
defer library.DumpLogs(t, env.SupervisorNamespace)
defer library.DumpLogs(t, env.SupervisorNamespace, "")
defer library.DumpLogs(t, "dex", "app=proxy")
ctx, cancel := context.WithTimeout(context.Background(), 5*time.Minute)
defer cancel()

View File

@ -15,7 +15,7 @@ import (
)
// DumpLogs is meant to be called in a `defer` to dump the logs of components in the cluster on a test failure.
func DumpLogs(t *testing.T, namespace string) {
func DumpLogs(t *testing.T, namespace string, labelSelector string) {
// Only trigger on failed tests.
if !t.Failed() {
return
@ -26,7 +26,7 @@ func DumpLogs(t *testing.T, namespace string) {
defer cancel()
logTailLines := int64(40)
pods, err := kubeClient.CoreV1().Pods(namespace).List(ctx, metav1.ListOptions{})
pods, err := kubeClient.CoreV1().Pods(namespace).List(ctx, metav1.ListOptions{LabelSelector: labelSelector})
require.NoError(t, err)
for _, pod := range pods.Items {