Skip to content

[chore] Fix typo in test file names #3335

[chore] Fix typo in test file names

[chore] Fix typo in test file names #3335

Workflow file for this run

name: splunk-ta-otel-build/packaging/technical-addon
on:
push:
branches:
- main
pull_request:
paths:
- '.github/workflows/splunk-ta-otel.yml'
- 'packaging/technical-addon/**'
- 'cmd/**'
- 'internal/**'
- 'pkg/**'
- 'tests/**'
- '!**.md'
workflow_dispatch:
inputs:
splunk_uf_version:
description: 'Splunk UF version'
required: false
default: '9.4.0'
splunk_uf_build_hash:
description: 'Splunk UF build hash'
required: false
default: '6b4ebe426ca6'
concurrency:
group: splunk-technical-addon-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
env:
GO_VERSION: 1.24.6
ADDONS_SOURCE_DIR: "${{github.workspace}}/packaging/technical-addon"
BUILD_DIR: "${{github.workspace}}/build"
# Provide default values for non-manually triggered executions
splunk_uf_version: ${{ github.event.inputs.splunk_uf_version || '9.4.0' }}
splunk_uf_build_hash: ${{ github.event.inputs.splunk_uf_build_hash || '6b4ebe426ca6' }}
jobs:
check_changes:
runs-on: ubuntu-24.04
outputs:
ta_packaging_change: ${{ steps.filter.outputs.ta_packaging_change }}
ta_workflow_change: ${{ steps.filter.outputs.ta_workflow_change }}
steps:
- uses: actions/checkout@v5
with:
fetch-depth: 0 # Fetch all history for all branches and tags
- name: Get changed files
id: changed-files
run: |
if [ "${{ github.event_name }}" == "pull_request" ]; then
echo "files=$(git diff --name-only origin/${{ github.base_ref }} ${{ github.sha }} | tr '\n' ' ')" >> "$GITHUB_OUTPUT"
else
echo "files=$(git diff --name-only ${{ github.event.before }} ${{ github.sha }} | tr '\n' ' ')" >> "$GITHUB_OUTPUT"
fi
- name: Filter paths
id: filter
run: |
files="${{ steps.changed-files.outputs.files }}"
if echo "$files" | grep -qE "packaging/technical-addon"; then
echo "ta_packaging_change=true" >> "$GITHUB_OUTPUT"
else
echo "ta_packaging_change=false" >> "$GITHUB_OUTPUT"
fi
if echo "$files" | grep -qE ".github/workflows/splunk-ta-otel.yml"; then
echo "ta_workflow_change=true" >> "$GITHUB_OUTPUT"
else
echo "ta_workflow_change=false" >> "$GITHUB_OUTPUT"
fi
test:
name: test
runs-on: ubuntu-24.04
strategy:
matrix:
# see https://hub.docker.com/r/splunk/splunk/tags
SPLUNK_VERSION: ["10.0", "9.4", "8.2"]
defaults:
run:
working-directory: ${{github.workspace}}/packaging/technical-addon
steps:
- uses: actions/checkout@v5
- uses: ./.github/actions/setup-environment
- name: Build & Package TA
run: |
set -o pipefail
pushd ${{github.workspace}}
make -e bundle.d otelcol
popd
make -e generate-technical-addon copy-local-build-to-ta package-ta
make -e smoketest-ta
test-generator:
needs: [check_changes]
name: test-modinput-config-generator
runs-on: ubuntu-24.04
if: needs.check_changes.outputs.ta_packaging_change == 'true' || needs.check_changes.outputs.ta_workflow_change == 'true'
defaults:
run:
working-directory: ${{github.workspace}}/packaging/technical-addon
steps:
- uses: actions/checkout@v5
- uses: ./.github/actions/setup-environment
- name: Test addon generator
run: |
set -o pipefail
make -e test-ta-build-tools
- name: Ensure license
run: |
set -o pipefail
make -e addlicense
- name: Ensure lint
run: |
set -o pipefail
make -e lint
test-ta-linux-autoinstrumentation:
name: test-ta-linux-autoinstrumentation
runs-on: ubuntu-24.04
needs: [check_changes, test]
if: needs.check_changes.outputs.ta_packaging_change == 'true' || needs.check_changes.outputs.ta_workflow_change == 'true'
defaults:
run:
working-directory: ${{github.workspace}}/packaging/technical-addon
steps:
- name: Free up disk space for next step
uses: jlumbroso/[email protected]
- uses: actions/checkout@v5
- uses: ./.github/actions/setup-environment
- name: Test normal go code
run: |
pushd ${{github.workspace}}/instrumentation
make -e dist
popd
make -e test-ta-build-tools build-tas test
distribute-ta:
name: "distribute-ta" # what gets run to package in gitlab
runs-on: ubuntu-24.04
needs: [check_changes]
if: needs.check_changes.outputs.ta_packaging_change == 'true' || needs.check_changes.outputs.ta_workflow_change == 'true'
defaults:
run:
working-directory: ${{github.workspace}}/packaging/technical-addon
steps:
- name: Check out the codebase.
uses: actions/checkout@v5
- uses: ./.github/actions/setup-environment
- name: Build & Package TA
run: |
set -o pipefail
PLATFORM="all" make -e distribute-ta
- name: Upload Collector TA
uses: actions/upload-artifact@v4
with:
name: Splunk_TA_otel
path: ${{github.workspace}}/build/out/distribution/Splunk_TA_otel.tgz
smoke-test-linux:
runs-on: ubuntu-24.04
needs: [distribute-ta]
steps:
- name: Download Collector TA
uses: actions/download-artifact@v5
with:
name: Splunk_TA_otel
path: ${{github.workspace}}/build/out/distribution
- name: Uncompress the Collector TA and prepare local configuration
run: |
mkdir -p "${{github.workspace}}/build/out/splunk_ta_otel"
tar -xzf "${{github.workspace}}/build/out/distribution/Splunk_TA_otel.tgz" -C "${{github.workspace}}/build/out/splunk_ta_otel"
cd "${{github.workspace}}/build/out/splunk_ta_otel/Splunk_TA_otel"
mkdir local
echo "FaKeAcCeSsToKeN" > local/access_token
- name: Launch Splunk container
run: |
mkdir -p "${{github.workspace}}/var/log/splunk"
docker run -d --name splunk \
-e SPLUNK_START_ARGS="--accept-license" -e SPLUNK_PASSWORD="$(uuidgen)" \
-v "${{github.workspace}}/build/out/splunk_ta_otel/Splunk_TA_otel":/opt/splunk/etc/apps/Splunk_TA_otel \
-v "${{github.workspace}}/var/log/splunk":/opt/splunk/var/log/splunk \
"splunk/splunk:${{env.splunk_uf_version}}"
- name: Wait for Collector launch attempt
run: |
cd "${{github.workspace}}/var/log/splunk"
logFile="Splunk_TA_otel.log"
found=false
timeout=360
elapsed=0
while [ "$found" = false ] && [ "$elapsed" -lt "$timeout" ]; do
if [ -f "$logFile" ]; then
if sudo grep -q "INFO SPLUNK_HOME=/opt/splunk" "$logFile"; then
found=true
fi
fi
if [ "$found" = false ]; then
sleep 1
elapsed=$((elapsed + 1))
fi
done
if [ "$found" = true ]; then
echo "Collector was launched after $elapsed seconds"
else
echo "Timeout reached. Collector was not launched after $elapsed seconds"
exit 1
fi
- name: Get otelcol_linux_amd64 PID from Splunk container
id: get_pid
run: |
docker exec splunk sudo ps -aux | grep otelcol_linux_amd64
otelcol_pid="$(docker exec splunk sudo ps -aux | grep otelcol_linux_amd64 | awk '{print $2}')"
echo "otelcol_linux_amd64 PID $otelcol_pid"
echo "otelcol_pid=$otelcol_pid" >> "$GITHUB_OUTPUT"
- name: Collect log files
if: always()
run: |
cd "${{github.workspace}}/var/log/splunk"
ls -l
echo -e "\n======= otel.log contents ======="
sudo cat otel.log || echo 'otel.log not found'
echo -e "\n======= Splunk_TA_otel.log contents ======="
sudo cat Splunk_TA_otel.log || echo 'Splunk_TA_otel.log not found'
echo -e "\n======= splunkd.log contents ======="
sudo cat splunkd.log || echo 'splunkd.log not found'
- name: Check if otelcol_linux_amd64 process is alive
run: |
otelcol_pid="${{ steps.get_pid.outputs.otelcol_pid }}"
if docker exec splunk sudo ps "$otelcol_pid"; then
echo "otelcol_linux_amd64 process ($otelcol_pid) was still running."
else
echo "otelcol_linux_amd64 process ($otelcol_pid) was not running!"
exit 1
fi
- name: Check that no otel.log was generated with default config
run: |
cd "${{github.workspace}}/var/log/splunk"
if [ -f "otel.log" ]; then
echo "Error: otel.log exists"
exit 1
fi
smoke-test-windows:
runs-on: otel-windows
needs: [distribute-ta]
steps:
- name: Download the Splunk UF MSI
shell: bash
run: |
curl https://download.splunk.com/products/universalforwarder/releases/${{ env.splunk_uf_version }}/windows/splunkforwarder-${{ env.splunk_uf_version }}-${{ env.splunk_uf_build_hash }}-windows-x64.msi -o splunkforwarder.msi
- name: Install Splunk UF
run: msiexec.exe /i "$PWD\splunkforwarder.msi" /qn /l*v install-log.txt AGREETOLICENSE=Yes
- name: Download Collector TA
uses: actions/download-artifact@v5
with:
name: Splunk_TA_otel
path: ${{github.workspace}}/build/out/distribution
- name: Stop Splunk UF
# workaround for actionlint not recognizing that "otel-windows" is a windows runner
shell: pwsh
run: |
cd "${Env:ProgramFiles}\SplunkUniversalForwarder\bin"
.\splunk.exe stop
- name: Install Splunk_TA_otel on the local Splunk UF
run: |
tar -xzf "${{github.workspace}}/build/out/distribution/Splunk_TA_otel.tgz" -C "${Env:ProgramFiles}\SplunkUniversalForwarder\etc\apps"
dir "${Env:ProgramFiles}\SplunkUniversalForwarder\etc\apps"
cd "${Env:ProgramFiles}\SplunkUniversalForwarder\etc\apps\Splunk_TA_otel"
mkdir local
Set-Content -Path local/access_token -Value "FaKeAcCeSsToKeN"
- name: Start Splunk UF
# workaround for actionlint not recognizing that "otel-windows" is a windows runner
shell: pwsh
run: |
cd "${Env:ProgramFiles}\SplunkUniversalForwarder\bin"
.\splunk.exe status
.\splunk.exe start
- name: Wait for Collector launch attempt
# workaround for actionlint not recognizing that "otel-windows" is a windows runner
shell: pwsh
run: |
cd "${Env:ProgramFiles}\SplunkUniversalForwarder\var\log\splunk"
$logFile = "Splunk_TA_otel.log"
$found = $false
$timeout = 360
$elapsed = 0
while (-not $found -and $elapsed -lt $timeout) {
if (Test-Path $logFile) {
$found = Select-String -Path $logFile -Pattern "Monitoring collector process with" -Quiet
}
if (-not $found) {
Start-Sleep -Seconds 1
$elapsed++
}
}
if ($found) {
Write-Host "Collector was launched after $elapsed seconds"
} else {
Write-Host "Timeout reached. Collector was not launched after $elapsed seconds"
exit 1
}
- name: Get otelcol_windows_amd64 PID
id: get_pid
# workaround for actionlint not recognizing that "otel-windows" is a windows runner
shell: pwsh
run: |
Get-Process
$otelcol_pid = (Get-Process -Name otelcol_windows_amd64).Id
Write-Host "otelcol_windows_amd64 PID $otelcol_pid"
"otelcol_pid=$otelcol_pid" | Out-File -FilePath $env:GITHUB_OUTPUT -Encoding utf8 -Append
- name: Collect Windows event logs
if: always()
# workaround for actionlint not recognizing that "otel-windows" is a windows runner
shell: pwsh
run: |
Write-Host "Last 50 Application log events:"
Get-WinEvent -Log Application -MaxEvents 50 | Format-List TimeCreated, ProviderName, Message
Write-Host "Last 50 System log events:"
Get-WinEvent -Log System -MaxEvents 50 | Format-List TimeCreated, ProviderName, Message
- name: Collect log files
if: always()
# workaround for actionlint not recognizing that "otel-windows" is a windows runner
shell: pwsh
run: |
cd "${Env:ProgramFiles}\SplunkUniversalForwarder\var\log\splunk"
dir
Write-Host "`n======= otel.log contents ======="
Get-Content otel.log -ErrorAction SilentlyContinue
Write-Host "`n======= Splunk_TA_otel.log contents ======="
Get-Content Splunk_TA_otel.log -ErrorAction SilentlyContinue
Write-Host "`n======= splunkd.log contents ======="
Get-Content splunkd.log -ErrorAction SilentlyContinue
- name: Check if otelcol_windows_amd64 process is alive
# workaround for actionlint not recognizing that "otel-windows" is a windows runner
shell: pwsh
run: |
$prev_otelcol_pid = ${{ steps.get_pid.outputs.otelcol_pid }}
$otelcol_pid = (Get-Process -Id $prev_otelcol_pid).Id
if ($otelcol_pid) {
Write-Host "otelcol_windows_amd64 process ($prev_otelcol_pid) was still running."
} else {
Write-Host "otelcol_windows_amd64 process ($prev_otelcol_pid) was not running!"
exit 1
}
- name: Check that no otel.log was generated with default config
shell: pwsh
run: |
cd "${Env:ProgramFiles}\SplunkUniversalForwarder\var\log\splunk"
if (Test-Path "otel.log") {
Write-Host "Error: otel.log exists"
exit 1
}
test-discovery:
name: test-discovery
runs-on: ubuntu-24.04
needs: [test]
defaults:
run:
working-directory: ${{github.workspace}}/packaging/technical-addon
strategy:
matrix:
PLATFORM: ["all"]
steps:
- name: Check out the codebase.
uses: actions/checkout@v5
- uses: ./.github/actions/setup-environment
- name: Build & Package TA
run: |
set -o pipefail
pushd ${{github.workspace}}
make -e bundle.d otelcol
popd
make -e generate-technical-addon copy-local-build-to-ta package-ta
make -e discovery-test-ta
test-envvars:
name: test-envvars
runs-on: ubuntu-24.04
needs: [test]
defaults:
run:
working-directory: ${{github.workspace}}/packaging/technical-addon
strategy:
matrix:
PLATFORM: ["all"]
steps:
- name: Check out the codebase.
uses: actions/checkout@v5
- uses: ./.github/actions/setup-environment
- name: Build & Package TA
run: |
set -o pipefail
pushd ${{github.workspace}}
make -e bundle.d otelcol
popd
make -e generate-technical-addon copy-local-build-to-ta package-ta
make -e envvar-test-ta
spell-check:
name: spell-check
runs-on: ubuntu-latest
steps:
- name: Check out the codebase.
uses: actions/checkout@v5
- uses: ./.github/actions/setup-environment
- uses: streetsidesoftware/cspell-action@v7
with:
config: ${{github.workspace}}/packaging/technical-addon/packaging-scripts/cspell/cspell.json
root: ${{github.workspace}}/packaging/technical-addon/Splunk_TA_otel
files: |
!**/agent-bundle/**