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: labels:
app: proxy app: proxy
spec: spec:
volumes:
- name: log-dir
emptyDir: {}
containers: containers:
- name: proxy - name: proxy
image: docker.io/getpinniped/test-forward-proxy image: docker.io/getpinniped/test-forward-proxy
@ -34,6 +37,9 @@ spec:
limits: limits:
cpu: "10m" cpu: "10m"
memory: "64Mi" memory: "64Mi"
volumeMounts:
- name: log-dir
mountPath: "/var/log/squid/"
readinessProbe: readinessProbe:
tcpSocket: tcpSocket:
port: http port: http
@ -41,6 +47,16 @@ spec:
timeoutSeconds: 5 timeoutSeconds: 5
periodSeconds: 5 periodSeconds: 5
failureThreshold: 2 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 apiVersion: v1
kind: Service kind: Service

View File

@ -35,7 +35,8 @@ func TestSupervisorLogin(t *testing.T) {
env := library.IntegrationEnv(t) env := library.IntegrationEnv(t)
// If anything in this test crashes, dump out the supervisor pod logs. // 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) ctx, cancel := context.WithTimeout(context.Background(), 5*time.Minute)
defer cancel() 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. // 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. // Only trigger on failed tests.
if !t.Failed() { if !t.Failed() {
return return
@ -26,7 +26,7 @@ func DumpLogs(t *testing.T, namespace string) {
defer cancel() defer cancel()
logTailLines := int64(40) 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) require.NoError(t, err)
for _, pod := range pods.Items { for _, pod := range pods.Items {