Skip to content

Commit

Permalink
Add log validator to integration tests (letsencrypt#4782)
Browse files Browse the repository at this point in the history
For now this mainly provides an example config and confirms that
log-validator can start up and shut down cleanly, as well as provide a
stat indicating how many log lines it has handled.

This introduces a syslog config to the boulder-tools image that will write
logs to /var/log/program.log. It also tweaks the various .json config
files so they have non-default syslogLevel, to ensure they actually
write something for log-validator to verify.
  • Loading branch information
jsha authored Apr 20, 2020
1 parent 8259925 commit 87fb602
Show file tree
Hide file tree
Showing 41 changed files with 114 additions and 45 deletions.
14 changes: 8 additions & 6 deletions cmd/log-validator/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -127,11 +127,11 @@ func main() {
cmd.FailOnError(err, "failed to parse config file")

stats, logger := cmd.StatsAndLogging(config.Syslog, config.DebugAddr)
badLineCounter := prometheus.NewCounterVec(prometheus.CounterOpts{
Name: "bad_log_lines",
Help: "A counter of corrupt log lines",
}, []string{"filename"})
stats.MustRegister(badLineCounter)
lineCounter := prometheus.NewCounterVec(prometheus.CounterOpts{
Name: "log_lines",
Help: "A counter of log lines processed, with status",
}, []string{"filename", "status"})
stats.MustRegister(lineCounter)

var tailers []*tail.Tail
for _, filename := range config.Files {
Expand All @@ -151,8 +151,10 @@ func main() {
continue
}
if err := lineValid(line.Text); err != nil {
badLineCounter.WithLabelValues(t.Filename).Inc()
lineCounter.WithLabelValues(t.Filename, "bad").Inc()
logger.Errf("%s: %s %q", t.Filename, err, line.Text)
} else {
lineCounter.WithLabelValues(t.Filename, "ok").Inc()
}
}
}()
Expand Down
6 changes: 3 additions & 3 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ version: '3'
services:
boulder:
# To minimize fetching this should be the same version used below
image: letsencrypt/boulder-tools-go${TRAVIS_GO_VERSION:-1.14.1}:2020-04-08
image: letsencrypt/boulder-tools-go${TRAVIS_GO_VERSION:-1.14.1}:2020-04-16
environment:
FAKE_DNS: 10.77.77.77
PKCS11_PROXY_SOCKET: tcp://boulder-hsm:5657
Expand Down Expand Up @@ -65,7 +65,7 @@ services:
hard: -1
bhsm:
# To minimize fetching this should be the same version used above
image: letsencrypt/boulder-tools-go${TRAVIS_GO_VERSION:-1.14.1}:2020-04-08
image: letsencrypt/boulder-tools-go${TRAVIS_GO_VERSION:-1.14.1}:2020-04-16
environment:
PKCS11_DAEMON_SOCKET: tcp://0.0.0.0:5657
command: /usr/local/bin/pkcs11-daemon /usr/lib/softhsm/libsofthsm2.so
Expand All @@ -92,7 +92,7 @@ services:
logging:
driver: none
netaccess:
image: letsencrypt/boulder-tools-go${TRAVIS_GO_VERSION:-1.14.1}:2020-04-08
image: letsencrypt/boulder-tools-go${TRAVIS_GO_VERSION:-1.14.1}:2020-04-16
environment:
GO111MODULE: "on"
GOFLAGS: "-mod=vendor"
Expand Down
5 changes: 3 additions & 2 deletions test/boulder-tools/Dockerfile.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ RUN mkdir -p "$GOPATH/src" "$GOPATH/bin" && chmod -R 777 "$GOPATH"
WORKDIR $GOPATH

RUN wget -O go.tgz "https://dl.google.com/go/go${GO_VERSION_TO_INSTALL}.linux-amd64.tar.gz" && tar -C /usr/local -xzf go.tgz && rm go.tgz;
ADD requirements.txt /tmp/requirements.txt
ADD build.sh /tmp/build.sh
COPY requirements.txt /tmp/requirements.txt
COPY boulder.rsyslog.conf /etc/rsyslog.d/
COPY build.sh /tmp/build.sh
RUN /tmp/build.sh
18 changes: 18 additions & 0 deletions test/boulder-tools/boulder.rsyslog.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
module( load="builtin:omfile" template="LELogFormat" )

template( name="LELogFormat" type="list" ) {
property(name="timereported" dateFormat="rfc3339")
constant(value=" ")
property(name="hostname" field.delimiter="46" field.number="1")
constant(value=" datacenter ")
property(name="syslogseverity")
constant(value=" ")
property(name="syslogtag")
property(name="msg" spifno1stsp="on" )
property(name="msg" droplastlf="on" )
constant(value="\n")
}

template( name="TmplAll" type="string" string="/var/log/%PROGRAMNAME%.log" )

action( type="omfile" dynaFile="TmplAll" )
2 changes: 1 addition & 1 deletion test/config-next/admin-revoker.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,6 @@

"syslog": {
"stdoutlevel": 6,
"sysloglevel": 4
"sysloglevel": 6
}
}
4 changes: 2 additions & 2 deletions test/config-next/akamai-purger.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,11 @@

"syslog": {
"stdoutlevel": 6,
"sysloglevel": 4
"sysloglevel": 6
},

"common": {
"issuerCert": "test/test-ca2.pem"
}
}


2 changes: 1 addition & 1 deletion test/config-next/ca-a.json
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,6 @@

"syslog": {
"stdoutlevel": 6,
"sysloglevel": 4
"sysloglevel": 6
}
}
2 changes: 1 addition & 1 deletion test/config-next/ca-b.json
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,6 @@

"syslog": {
"stdoutlevel": 6,
"sysloglevel": 4
"sysloglevel": 6
}
}
2 changes: 1 addition & 1 deletion test/config-next/cert-checker.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,6 @@

"syslog": {
"stdoutlevel": 6,
"sysloglevel": 4
"sysloglevel": 6
}
}
2 changes: 1 addition & 1 deletion test/config-next/expiration-mailer.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,6 @@

"syslog": {
"stdoutlevel": 6,
"sysloglevel": 4
"sysloglevel": 6
}
}
19 changes: 19 additions & 0 deletions test/config-next/log-validator.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"syslog": {
"stdoutLevel": 7
},
"debugAddr": ":8016",
"files": [
"/var/log/akamai-purger.log",
"/var/log/boulder-ca.log",
"/var/log/boulder-publisher.log",
"/var/log/boulder-ra.log",
"/var/log/boulder-sa.log",
"/var/log/boulder-va.log",
"/var/log/boulder-wfe2.log",
"/var/log/boulder-wfe.log",
"/var/log/nonce-service.log",
"/var/log/ocsp-responder.log",
"/var/log/ocsp-updater.log"
]
}
3 changes: 2 additions & 1 deletion test/config-next/nonce.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
"maxUsed": 131072,
"noncePrefix": "taro",
"syslog": {
"stdoutLevel": 6
"stdoutLevel": 6,
"syslogLevel": 6
},
"debugAddr": ":8111",
"grpc": {
Expand Down
6 changes: 5 additions & 1 deletion test/config-next/notify-mailer.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,9 @@
"passwordFile": "test/secrets/smtp_password",
"dbConnectFile": "test/secrets/mailer_dburl",
"maxDBConns": 10
}
},
"syslog": {
"stdoutLevel": 7,
"syslogLevel": 7
}
}
2 changes: 1 addition & 1 deletion test/config-next/ocsp-responder.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

"syslog": {
"stdoutlevel": 6,
"sysloglevel": 4
"sysloglevel": 6
},

"common": {
Expand Down
2 changes: 1 addition & 1 deletion test/config-next/ocsp-updater.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@

"syslog": {
"stdoutlevel": 6,
"sysloglevel": 4
"sysloglevel": 6
},

"common": {
Expand Down
1 change: 1 addition & 0 deletions test/config-next/orphan-finder.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"backdate": "1h",

"syslog": {
"stdoutlevel": 7,
"stdoutlevel": 7
},

Expand Down
2 changes: 1 addition & 1 deletion test/config-next/publisher.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@

"syslog": {
"stdoutlevel": 6,
"sysloglevel": 4
"sysloglevel": 6
},

"common": {
Expand Down
2 changes: 1 addition & 1 deletion test/config-next/ra.json
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,6 @@

"syslog": {
"stdoutlevel": 6,
"sysloglevel": 4
"sysloglevel": 6
}
}
2 changes: 1 addition & 1 deletion test/config-next/sa.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,6 @@

"syslog": {
"stdoutlevel": 6,
"sysloglevel": 4
"sysloglevel": 6
}
}
2 changes: 1 addition & 1 deletion test/config-next/va.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@

"syslog": {
"stdoutlevel": 6,
"sysloglevel": 4
"sysloglevel": 6
},

"common": {
Expand Down
2 changes: 1 addition & 1 deletion test/config-next/wfe.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@

"syslog": {
"stdoutlevel": 4,
"sysloglevel": 4
"sysloglevel": 6
},

"common": {
Expand Down
2 changes: 1 addition & 1 deletion test/config-next/wfe2.json
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@

"syslog": {
"stdoutlevel": 4,
"sysloglevel": 4
"sysloglevel": 6
},

"common": {
Expand Down
2 changes: 1 addition & 1 deletion test/config/admin-revoker.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,6 @@

"syslog": {
"stdoutlevel": 6,
"sysloglevel": 4
"sysloglevel": 6
}
}
4 changes: 2 additions & 2 deletions test/config/akamai-purger.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,11 @@

"syslog": {
"stdoutlevel": 6,
"sysloglevel": 4
"sysloglevel": 6
},

"common": {
"issuerCert": "test/test-ca2.pem"
}
}


2 changes: 1 addition & 1 deletion test/config/ca-a.json
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,6 @@

"syslog": {
"stdoutlevel": 6,
"sysloglevel": 4
"sysloglevel": 6
}
}
2 changes: 1 addition & 1 deletion test/config/ca-b.json
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,6 @@

"syslog": {
"stdoutlevel": 6,
"sysloglevel": 4
"sysloglevel": 6
}
}
2 changes: 1 addition & 1 deletion test/config/cert-checker.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,6 @@

"syslog": {
"stdoutlevel": 6,
"sysloglevel": 4
"sysloglevel": 6
}
}
2 changes: 1 addition & 1 deletion test/config/expiration-mailer.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,6 @@

"syslog": {
"stdoutlevel": 6,
"sysloglevel": 4
"sysloglevel": 6
}
}
19 changes: 19 additions & 0 deletions test/config/log-validator.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"syslog": {
"stdoutLevel": 7
},
"debugAddr": ":8016",
"files": [
"/var/log/akamai-purger.log",
"/var/log/boulder-ca.log",
"/var/log/boulder-publisher.log",
"/var/log/boulder-ra.log",
"/var/log/boulder-sa.log",
"/var/log/boulder-va.log",
"/var/log/boulder-wfe2.log",
"/var/log/boulder-wfe.log",
"/var/log/nonce-service.log",
"/var/log/ocsp-responder.log",
"/var/log/ocsp-updater.log"
]
}
3 changes: 2 additions & 1 deletion test/config/nonce.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
"maxUsed": 131072,
"noncePrefix": "taro",
"syslog": {
"stdoutLevel": 6
"stdoutLevel": 6,
"syslogLevel": 6
},
"debugAddr": ":8111",
"grpc": {
Expand Down
3 changes: 2 additions & 1 deletion test/config/notify-mailer.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
"maxDBConns": 10
},
"syslog": {
"stdoutLevel": 7
"stdoutLevel": 7,
"syslogLevel": 7
}
}
2 changes: 1 addition & 1 deletion test/config/ocsp-responder.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

"syslog": {
"stdoutlevel": 6,
"sysloglevel": 4
"sysloglevel": 6
},

"common": {
Expand Down
2 changes: 1 addition & 1 deletion test/config/ocsp-updater.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@

"syslog": {
"stdoutlevel": 6,
"sysloglevel": 4
"sysloglevel": 6
},

"common": {
Expand Down
1 change: 1 addition & 0 deletions test/config/orphan-finder.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"backdate": "1h",

"syslog": {
"stdoutlevel": 7,
"stdoutlevel": 7
},

Expand Down
2 changes: 1 addition & 1 deletion test/config/publisher.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@

"syslog": {
"stdoutlevel": 6,
"sysloglevel": 4
"sysloglevel": 6
},

"common": {
Expand Down
2 changes: 1 addition & 1 deletion test/config/ra.json
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,6 @@

"syslog": {
"stdoutlevel": 6,
"sysloglevel": 4
"sysloglevel": 6
}
}
Loading

0 comments on commit 87fb602

Please sign in to comment.