Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP: OTEL branch CI #394

Draft
wants to merge 96 commits into
base: updated-fields
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
96 commits
Select commit Hold shift + click to select a range
eb196af
install latest collector release from source
Feb 12, 2022
b6cd7e9
try log lib token
Feb 12, 2022
0e491ce
fix branch
Feb 12, 2022
5cf0d53
Fetch tags
Feb 12, 2022
06a208c
install goreleaser directly to speed up build
Feb 12, 2022
9fea86e
fix bin path
Feb 12, 2022
1b27811
attempt to cache collector build
Feb 12, 2022
6f126e1
do not let goreleaser install golang, it is already installed outside…
Feb 12, 2022
c117928
reset cache, I think I cached go 1.13 modules :)
Feb 12, 2022
270b402
build image with tzdata, collector, and plugins. check for 'Failed to…
Feb 12, 2022
a0afe52
fix apt
Feb 12, 2022
0a4eaf7
check for empty output file
Feb 12, 2022
32bfea4
get output
Feb 12, 2022
c250034
fix condition
Feb 12, 2022
ecf618b
start building re-usable action
Feb 12, 2022
66ac55e
fix quote
Feb 12, 2022
01f326f
call build container image
Feb 12, 2022
a4b5773
chmod +x
Feb 12, 2022
45cfe53
Add remaining to test plugin action
Feb 12, 2022
dcc4b54
move codeigniter to action
Feb 12, 2022
fa2e53b
seconds
Feb 12, 2022
62e9eed
move over more plugins
Feb 12, 2022
fc6005f
move all plugins to new action except for k8s
Feb 12, 2022
0516e71
this should work?
Feb 12, 2022
bd1ff9f
make pause seconds optional default to 10s. start on k8s
Feb 12, 2022
f769cb6
add args to action. continue on k8s
Feb 12, 2022
798e696
continue on minikube
Feb 12, 2022
b4b9ee3
try k8s
Feb 12, 2022
614430b
remove s from pause
Feb 12, 2022
1c67aa0
remove offset db directory
Feb 12, 2022
8b6f698
remove unsupported k8s versions
Feb 12, 2022
c9470a7
polish output messages
Feb 12, 2022
2f54b5c
fix k8s manifest
Feb 12, 2022
4d07901
Remove command from k8s manifest, it is set in the dockerfile
Feb 12, 2022
dea21db
unify output directory and output file handling
Feb 12, 2022
b2aac70
copy input directory to build image, unify docker and k8s deployments
Feb 12, 2022
e6a60ec
fix input dir
Feb 12, 2022
7c8de98
fix config path
Feb 12, 2022
87621b9
Add status badges back
Feb 12, 2022
14d854c
Add 'latest' to minikube version matrix
Feb 12, 2022
702f470
capture stdout / stderr from kubectl logs
Feb 12, 2022
acd9002
ignore k8s_metadata_decorator failures because it cannot lookup metad…
Feb 13, 2022
ead52d5
detect agent pod
Feb 13, 2022
e09a64a
add namespace to kubectl cp command
Feb 13, 2022
d5271a7
spelling
Feb 13, 2022
a3e76a2
awk
Feb 13, 2022
c48292a
fix apache_common, removed proto parser as it is not needed
Feb 13, 2022
4e9831e
use noop operator instead of {{ output }}, works around a bug where {…
Feb 13, 2022
dd7ee8b
disable query_parameter_move for now
Feb 13, 2022
dfb9481
use noop operator instead of {{ output }}, works around a bug where {…
Feb 13, 2022
89951d5
fix id
Feb 13, 2022
7a6cc84
fix access_protocol_parser parse from field
Feb 13, 2022
a86b91e
fix access_protocol_parser parse from field
Feb 13, 2022
fe18c2f
use noop operator instead of {{ output }}, works around a bug where {…
Feb 13, 2022
2bb4a06
use noop operator instead of {{ output }}, works around a bug where {…
Feb 13, 2022
332a24b
add noop output to all plugins currently being tested
Feb 13, 2022
e03601c
test mysql
Feb 13, 2022
2e3bbbc
add more cases to mysql
Feb 13, 2022
127c554
use noop for mysql .output values
Feb 13, 2022
7e6f498
test microsoft_iis
Feb 13, 2022
f3e1d59
iis
Feb 13, 2022
acade77
use noop for output
Feb 13, 2022
2591bce
test mariadb
Feb 13, 2022
9eeb644
use noop for output
Feb 13, 2022
e849138
add cases
Feb 13, 2022
aa1644a
check for expression errors
Feb 14, 2022
5e443aa
test elasticsearch
Feb 14, 2022
78e1354
elasticsearch badge
Feb 14, 2022
f81bb4f
use noop output
Feb 14, 2022
1189d76
mongodb testing
Feb 14, 2022
acb3293
mongodb pod name is not a required param
Feb 14, 2022
9af791e
mongodb badge
Feb 14, 2022
8dc3b91
test postgresql
Feb 14, 2022
b25c586
postgresql badge
Feb 14, 2022
1b28160
use America/Detroit for EDT to run correctly
Feb 14, 2022
9609eca
test pgbouncer
Feb 15, 2022
b997155
use noop output
Feb 15, 2022
f2e6afa
test tomcat and use noop
Feb 15, 2022
d174c9b
tomcat badge
Feb 15, 2022
9bcf6e6
pod name is not required
Feb 15, 2022
c780868
fix parse from for oiq format
Feb 15, 2022
096c59e
fix tomcat badge
Feb 15, 2022
5a625c1
fix and test hbase
Feb 15, 2022
0e9dce4
break up tests into master, region, zookeeper
Feb 15, 2022
10331b3
test kafka
Feb 15, 2022
ca2cf9c
add kafka output
Feb 15, 2022
ab5ae52
fix kafka badge
Feb 15, 2022
30cad51
add ibm db2 testing
Feb 15, 2022
89beb99
test jboss
Feb 15, 2022
f3bd49f
test uwsgi
Feb 15, 2022
4b52307
test json
Feb 15, 2022
8a89002
test couchbase
Feb 15, 2022
c0d1c59
fix bouchbase badge
Feb 15, 2022
708ff9a
Test csv
Feb 15, 2022
0ad7cdd
fix csv badge
Feb 15, 2022
7ce5cdc
fix uwsgi badge
Feb 15, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
storage/
output/
18 changes: 18 additions & 0 deletions .github/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
FROM ubuntu:20.04

ARG input_dir

ARG DEBIAN_FRONTEND=noninteractive
ENV TZ=America/Detroit
RUN \
apt-get update -qq && \
apt-get install -qq -y tzdata

COPY . /repo
RUN cp -r "/repo/${input_dir}" /input

COPY observiq-collector/dist/collector_linux_amd64 /collector
COPY plugins /plugins
RUN mkdir /storage /output

ENTRYPOINT [ "/collector", "--config", "/input/config/collector.yaml" ]
31 changes: 31 additions & 0 deletions .github/actions/test-plugin/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: "Test Plugin"
description: "Tests a stanza / otel plugin"
inputs:
workflow:
description: 'The name of the workflow'
required: true
workflow_case:
description: 'The workflow case (default, observiq, etc)'
required: true
pause_time:
description: 'How long to wait for agent to parse logs, in seconds'
required: false
default: "10s"
k8s:
description: 'Set to "true" if plugin requires minikube'
required: false
default: "false"
k8s_version:
description: 'Minikube Version'
required: false
default: "v1.23.0"
k8s_runtime:
description: 'Minkube runtime'
required: false
default: "docker"
runs:
using: "composite"
steps:
- id: test-plugin
run: ${{ github.action_path }}/test-plugin.sh "${{ inputs.workflow }}" "${{ inputs.workflow_case }}" "${{ inputs.pause_time }}" "${{ inputs.k8s }}" "${{ inputs.k8s_version }}" "${{ inputs.k8s_runtime }}"
shell: bash
235 changes: 235 additions & 0 deletions .github/actions/test-plugin/test-plugin.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,235 @@
#!/bin/bash
# Assumes pwd == git root

set -e

workflow="$1"
workflow_case="$2"
pause_time="$3"
k8s="$4"
k8s_version="$5"
k8s_runtime="$6"

minikube_install() {
sudo apt-get update -qq
sudo apt-get install -qq -y conntrack
curl -s -LO https://storage.googleapis.com/minikube/releases/latest/minikube-linux-amd64
sudo install minikube-linux-amd64 /usr/local/bin/minikube
}

minikube_start() {
minikube start \
--driver=docker \
--kubernetes-version="$k8s_version" \
--container-runtime="$k8s_runtime"
}

minikube_wait() {
node=$(kubectl get node | grep -v NAME | awk '{print $1}')
bash ./.github/scripts/k8s_wait_for_node.sh "$node"
}

minikube_load_image() {
minikube image load agent:latest
}

minikube_create_configmap() {
# TODO(jsirianni): Configmap should be dynamic, right now we are hardcoding the input files
kubectl create configmap logs \
--from-file="log-library/cases/${workflow}/${workflow_case}/logs/adservice-5657f795f5-ql97m_default_server-2180fc6125cb444bd32be19cfa73e71a25e5d6c98b59b5191ee51fc6ff6c6723.log" \
--from-file="log-library/cases/${workflow}/${workflow_case}/logs/example-json-logger-6b49dd876-xmr2j_default_logger-ebd483078a72e8c029757f27d872b238ac26e1d0c8c7d842415790c33cc24451.log" \
--from-file="log-library/cases/${workflow}/${workflow_case}/logs/productcatalogservice-7cdd54f7c7-nbsgt_default_server-0a3bc17f1a059f850fc35b8b947fcb2f1a7a726b2574f48c973015e49df47e59.log"
}

minikube_generate_manifest() {
# TODO(jsirianni): Configmap should be dynamic, right now we are hardcoding the input files
cat <<- EOF > deploy.yaml
---
kind: ServiceAccount
apiVersion: v1
metadata:
name: stanza-metadata
namespace: default
---
kind: ClusterRole
apiVersion: rbac.authorization.k8s.io/v1
metadata:
name: stanza-metadata
namespace: default
rules:
- apiGroups: ["", "apps", "batch"]
resources: ["pods", "namespaces", "replicasets", "jobs"]
verbs: ["get", "list"]
---
kind: ClusterRoleBinding
apiVersion: rbac.authorization.k8s.io/v1
metadata:
name: stanza-metadata
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: ClusterRole
name: stanza-metadata
subjects:
- kind: ServiceAccount
name: stanza-metadata
namespace: default
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: agent
labels:
app: agent
spec:
replicas: 1
selector:
matchLabels:
app: agent
template:
metadata:
labels:
app: agent
spec:
serviceAccountName: stanza-metadata
containers:
- name: agent
image: agent:latest
imagePullPolicy: IfNotPresent
volumeMounts:
- name: logs
mountPath: /var/log/containers/adservice-5657f795f5-ql97m_default_server-2180fc6125cb444bd32be19cfa73e71a25e5d6c98b59b5191ee51fc6ff6c6723.log
subPath: adservice-5657f795f5-ql97m_default_server-2180fc6125cb444bd32be19cfa73e71a25e5d6c98b59b5191ee51fc6ff6c6723.log
- name: logs
mountPath: /var/log/containers/example-json-logger-6b49dd876-xmr2j_default_logger-ebd483078a72e8c029757f27d872b238ac26e1d0c8c7d842415790c33cc24451.log
subPath: example-json-logger-6b49dd876-xmr2j_default_logger-ebd483078a72e8c029757f27d872b238ac26e1d0c8c7d842415790c33cc24451.log
- name: logs
mountPath: /var/log/containers/productcatalogservice-7cdd54f7c7-nbsgt_default_server-0a3bc17f1a059f850fc35b8b947fcb2f1a7a726b2574f48c973015e49df47e59.log
subPath: productcatalogservice-7cdd54f7c7-nbsgt_default_server-0a3bc17f1a059f850fc35b8b947fcb2f1a7a726b2574f48c973015e49df47e59.log
volumes:
- name: logs
configMap:
name: logs
EOF
}

install_build_tools() {
echo 'deb [trusted=yes] https://repo.goreleaser.com/apt/ /' | sudo tee /etc/apt/sources.list.d/goreleaser.list
sudo apt-get update -qq
sudo apt-get --no-install-recommends install -qq -y goreleaser
}

build_collector() {
cd observiq-collector
make collector
cd ../
}

build_agent_image() {
docker build . \
--build-arg input_dir="log-library/cases/${workflow}/${workflow_case}" \
-t agent:latest \
-f .github/Dockerfile
}

run_agent() {
if "$k8s"; then
kubectl apply -f deploy.yaml
sleep 10 && kubectl get pods
pod=$(kubectl get pods | grep agent | awk '{print $1}')
kubectl describe pod "${pod}"
kubectl logs "${pod}"
kubectl rollout status -w deployment/agent --timeout=60s

else
docker run -d --name agent agent:latest
sleep 1 && docker logs agent

fi
}

# pause to let agent parse logs
pause_for_logs() {
sleep "$pause_time"
}

stop_agent() {
if "$k8s"; then
# We cannot stop the agent because we need its log output
echo "skipping stop agent, running in k8s"
else
docker kill agent
fi
}

dump_agent_logs() {
if "$k8s"; then
kubectl logs deploy/agent > agent.out 2>&1
else
docker logs agent > agent.out 2>&1
fi

cat agent.out
}

test_failed_process_entry() {
# TODO(jsirianni): Handle k8s metadata or disable it via config?
# It will always cause failures when looking up pods that do not exist, this is okay
# for now.
if grep -v 'k8s_metadata_decorator' agent.out | grep -i 'Failed to process entry'; then
echo "Failed check: Ensure no 'Failed to process entry' in agent log"
exit 1
else
echo "Passed check: Ensure no 'Failed to process entry' in agent log"
fi
}

test_expression_errors() {
if grep -i 'Running expression returned an error' agent.out; then
echo "Failed check: Ensure no 'Running expression returned an error' in agent log"
exit 1
else
echo "Passed check: Ensure no 'Running expression returned an error' in agent log"
fi

}

test_empty_output() {
mkdir -p output
if "$k8s"; then
pod=$(kubectl get pods | grep agent | awk '{print $1}')
kubectl cp "default/${pod}:/output/out" output/out
else
docker cp agent:/output/out output/out
fi

if [ -s output/out ]; then
lines=$(wc -l output/out)
echo "Passed check: Ensure output file is not empty. Number of lines: ${lines}"
else
echo "Failed check: Ensure output file is not empty."
exit 1
fi
}

### Main ###

install_build_tools
build_collector
build_agent_image

if "$k8s"; then
minikube_install
minikube_start
minikube_wait
minikube_load_image
minikube_create_configmap
minikube_generate_manifest
fi

run_agent
pause_for_logs
stop_agent
dump_agent_logs
test_failed_process_entry
test_expression_errors
test_empty_output
58 changes: 23 additions & 35 deletions .github/workflows/plugin_aerospike.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,44 +27,32 @@ jobs:
- name: Create Output Directory
run: mkdir output

- name: Create Offset Database Directory
run: mkdir -p storage
- name: Clone Collector
uses: actions/checkout@v2
with:
repository: 'observIQ/observiq-collector'
path: observiq-collector
token: ${{ secrets.LOG_LIBRARY_ACCESS_TOKEN }}
fetch-depth: 0

- name: Install Collector
run: |
mkdir -p collector
curl -s -o collector/collector https://storage.googleapis.com/observiq-cloud/observiq-collector/0.0.10/collector_linux_amd64
chmod +x collector/collector
- name: Set up Go 1.17
uses: actions/setup-go@v2
with:
go-version: 1.17

- name: Run Agent
- name: Fetch Go Cache Paths
id: go-cache-paths
run: |
docker run -d \
--name agent \
-v $(pwd)/collector:/collector \
-v $(pwd)/log-library/cases/${GITHUB_WORKFLOW}/${{ matrix.format }}:/input \
-v $(pwd)/output:/output \
-v $(pwd)/plugins:/plugins \
-v $(pwd)/storage:/storage \
--entrypoint sh \
ubuntu:20.04 \
-c '/collector/collector --config /input/config/collector.yaml'

sleep 1 && docker logs agent
echo "::set-output name=go-mod::$(go env GOMODCACHE)"

- name: Pause
run: sleep 10

- name: Stop Stanza
run: docker kill agent

- name: Dump Stanza Logs
run: docker logs agent

- name: Get Output
- name: Checkout Latest Collector Release
run: |
sudo cat output/out
latestTag=$(git describe --tags `git rev-list --tags --max-count=1`)
git checkout $latestTag
working-directory: observiq-collector

- name: Get Expected Output
run: |
sudo cp log-library/cases/${GITHUB_WORKFLOW}/${{ matrix.format }}/expect/expect.json output/expect
sudo cat output/expect
- name: Test Plugin
uses: ./.github/actions/test-plugin
with:
workflow: ${GITHUB_WORKFLOW}
workflow_case: ${{ matrix.format }}
Loading