forked from signalfx/splunk-otel-collector
-
Notifications
You must be signed in to change notification settings - Fork 0
838 lines (729 loc) · 29.6 KB
/
build-and-test.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
name: build-and-test
on:
push:
branches:
- main
pull_request:
paths:
- '.github/workflows/build-and-test.yml'
- '.github/workflows/scripts/**'
- 'cmd/**'
- 'internal/**'
- 'pkg/**'
- 'tests/**'
- 'Makefile'
- 'Makefile.common'
- 'go.mod'
- 'go.sum'
- '!**.md'
- '!internal/buildscripts/packaging/tests/deployments/**'
- '!internal/buildscripts/packaging/release/**'
concurrency:
group: build-and-test-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
env:
PYTHON_VERSION: '3.10'
PIP_VERSION: '22.0.4'
REQUIREMENTS_PATH: "internal/buildscripts/packaging/tests/requirements.txt"
RESULT_PATH: "~/testresults"
GO_VERSION: 1.19.6
jobs:
setup-environment:
name: setup-environment
# Use 20.04.5 until https://github.com/open-telemetry/opentelemetry-collector-contrib/issues/16450 is resolved
runs-on: ubuntu-20.04
steps:
- name: Check out the codebase.
uses: actions/checkout@v3
- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: ${{ env.GO_VERSION }}
cache-dependency-path: '**/go.sum'
- name: Installing dependency
run: |
make install-tools
gofmt:
name: gofmt
# Use 20.04.5 until https://github.com/open-telemetry/opentelemetry-collector-contrib/issues/16450 is resolved
runs-on: ubuntu-20.04
needs: [setup-environment]
steps:
- name: Check out the codebase.
uses: actions/checkout@v3
- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: ${{ env.GO_VERSION }}
cache-dependency-path: '**/go.sum'
- name: gofmt
run: |
make install-tools
make fmt
if ! git diff --exit-code; then
echo "One or more Go files are not formatted correctly. Run 'make fmt' and push the changes."
exit 1
fi
generate-metrics:
name: generate-metrics
# Use 20.04.5 until https://github.com/open-telemetry/opentelemetry-collector-contrib/issues/16450 is resolved
runs-on: ubuntu-20.04
needs: [setup-environment]
steps:
- name: Check out the codebase.
uses: actions/checkout@v3
- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: ${{ env.GO_VERSION }}
cache-dependency-path: '**/go.sum'
- name: install-tools
run: make install-tools
- name: generate-metrics
run: |
make generate-metrics
if ! git diff --exit-code; then
echo "Generated code is out of date. Run 'make generate-metrics' and push the changes."
exit 1
fi
lint:
name: lint
# Use 20.04.5 until https://github.com/open-telemetry/opentelemetry-collector-contrib/issues/16450 is resolved
runs-on: ubuntu-20.04
needs: [setup-environment]
steps:
- name: Check out the codebase.
uses: actions/checkout@v3
- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: ${{ env.GO_VERSION }}
cache-dependency-path: '**/go.sum'
- run: echo "GOLANGCI_LINT_CACHE=${HOME}/.cache/golangci-lint" >> $GITHUB_ENV
- uses: actions/cache@v3
with:
path: ${{ env.GOLANGCI_LINT_CACHE }}
key: golangci-lint-${{ hashFiles('**/.golangci.yml', '**/*.go', '**/go.sum') }}
- name: Lint
run: |
make install-tools
make for-all CMD="make lint"
test:
name: test
# Use 20.04.5 until https://github.com/open-telemetry/opentelemetry-collector-contrib/issues/16450 is resolved
runs-on: ubuntu-20.04
needs: [setup-environment]
steps:
- name: Check out the codebase.
uses: actions/checkout@v3
- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: ${{ env.GO_VERSION }}
cache-dependency-path: '**/go.sum'
- name: Unit tests
run: |
make install-tools
mkdir -p unit-test-results/junit
trap "go-junit-report -set-exit-code < unit-test-results/go-unit-tests.out > unit-test-results/junit/results.xml" EXIT
make for-all CMD="make test" | tee unit-test-results/go-unit-tests.out
- name: Uploading artifacts
uses: actions/upload-artifact@v3
with:
name: unit-test-results
path: ./unit-test-results
coverage:
name: coverage
# Use 20.04.5 until https://github.com/open-telemetry/opentelemetry-collector-contrib/issues/16450 is resolved
runs-on: ubuntu-20.04
needs: [setup-environment]
steps:
- name: Check out the codebase.
uses: actions/checkout@v3
- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: ${{ env.GO_VERSION }}
cache-dependency-path: '**/go.sum'
- name: Coverage tests
run: |
make install-tools
make test-with-cover
- name: Uploading artifacts
uses: actions/upload-artifact@v3
with:
name: coverage-results
path: ./coverage.html
# DISABLE CODECOV UNTIL THE SCRIPT IS AUDITED AND WE ARE CERTAIN IT IS OK TO TO EXECUTE IT.
# - name: Code coverage
# run: |
# bash <(curl -s https://codecov.io/bash)
cross-compile:
name: cross-compile
# Use 20.04.5 until https://github.com/open-telemetry/opentelemetry-collector-contrib/issues/16450 is resolved
runs-on: ubuntu-20.04
needs: [setup-environment]
strategy:
matrix:
SYS_BINARIES: [ "binaries-darwin_amd64", "binaries-linux_amd64", "binaries-linux_arm64", "binaries-windows_amd64", "binaries-linux_ppc64le" ]
steps:
- name: Check out the codebase.
uses: actions/checkout@v3
- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: ${{ env.GO_VERSION }}
cache-dependency-path: '**/go.sum'
- name: Build Collector
run: |
make ${{ matrix.SYS_BINARIES }}
- name: Uploading binaries
uses: actions/upload-artifact@v3
with:
name: ${{ matrix.SYS_BINARIES }}
path: |
./bin/*
agent-bundle-linux:
runs-on: ubuntu-20.04
strategy:
matrix:
ARCH: ["amd64", "arm64"]
fail-fast: false
steps:
- uses: actions/checkout@v3
- uses: actions/cache@v3
with:
path: .cache/buildx/agent-bundle-${{ matrix.ARCH }}
key: agent-bundle-buildx-${{ matrix.ARCH }}-${{ hashFiles('pkg/signalfx-agent/bundle/**') }}
- uses: docker/setup-qemu-action@v2
if: ${{ matrix.ARCH != 'amd64' }}
with:
platforms: ${{ matrix.ARCH }}
- run: make -C pkg/signalfx-agent/bundle agent-bundle-linux ARCH=${{ matrix.ARCH }}
- uses: actions/upload-artifact@v3
with:
name: agent-bundle-linux-${{ matrix.ARCH }}
path: ./dist/agent-bundle_linux_${{ matrix.ARCH }}.tar.gz
agent-bundle-windows:
runs-on: windows-2019
env:
PIP_CACHE_DIR: ${{ github.workspace }}/.cache/pip
steps:
- uses: actions/checkout@v3
- uses: actions/cache@v3
with:
path: ${{ env.PIP_CACHE_DIR }}
key: agent-bundle-windows-pip-${{ hashFiles('pkg/signalfx-agent/bundle/collectd-plugins.yaml', 'pkg/signalfx-agent/bundle/scripts/requirements.txt') }}
- run: ./pkg/signalfx-agent/bundle/scripts/windows/make.ps1 bundle
- uses: actions/upload-artifact@v3
with:
name: agent-bundle-windows
path: ./dist/agent-bundle_windows_amd64.zip
build-package:
name: build-package
# Use 20.04.5 until https://github.com/open-telemetry/opentelemetry-collector-contrib/issues/16450 is resolved
runs-on: ubuntu-20.04
needs: [cross-compile, agent-bundle-linux]
strategy:
matrix:
SYS_PACKAGE: [ "deb", "rpm", "tar" ]
ARCH: [ "amd64", "arm64" ]
fail-fast: false
steps:
- name: Check out the codebase.
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: ${{ env.GO_VERSION }}
cache-dependency-path: '**/go.sum'
- name: Downloading binaries-linux_${{ matrix.ARCH }}
uses: actions/download-artifact@v3
with:
name: binaries-linux_${{ matrix.ARCH }}
path: ./bin
- uses: actions/download-artifact@v3
with:
name: agent-bundle-linux-${{ matrix.ARCH }}
path: ./dist
- name: Build ${{ matrix.SYS_PACKAGE }} ${{ matrix.ARCH }} package
run: make ${{ matrix.SYS_PACKAGE }}-package SKIP_COMPILE=true SKIP_BUNDLE=true VERSION="" ARCH="${{ matrix.ARCH }}"
- name: Uploading ${{ matrix.SYS_PACKAGE }} ${{ matrix.ARCH }} package artifacts
uses: actions/upload-artifact@v3
with:
name: ${{ matrix.SYS_PACKAGE }}-${{ matrix.ARCH }}-package
path: ./dist/splunk-otel-collector*
test-package-matrix:
runs-on: ubuntu-20.04
steps:
- name: Check out code
uses: actions/checkout@v3
- name: Get matrix
id: get-matrix
run: |
# create test matrix for distro and arch
dockerfiles=$(find internal/buildscripts/packaging/tests/images/ -name "Dockerfile.*" | cut -d '.' -f2- | sort -u)
if [ -z "$dockerfiles" ]; then
echo "Failed to get dockerfiles from internal/buildscripts/packaging/tests/images!" >&2
exit 1
fi
distro=$(for d in $dockerfiles; do echo -n "\"$d\","; done)
arch="\"amd64\", \"arm64\""
matrix="{\"DISTRO\": [${distro%,}], \"ARCH\": [${arch}]}"
echo "$matrix" | jq
echo "matrix=${matrix}" >> $GITHUB_OUTPUT
outputs:
matrix: ${{ steps.get-matrix.outputs.matrix }}
test-package:
# Use 20.04.5 until https://github.com/open-telemetry/opentelemetry-collector-contrib/issues/16450 is resolved
runs-on: ubuntu-20.04
timeout-minutes: 20
needs: [build-package, test-package-matrix]
strategy:
matrix: ${{ fromJSON(needs.test-package-matrix.outputs.matrix) }}
fail-fast: false
steps:
- name: Check out the codebase.
uses: actions/checkout@v3
- name: Get package type for ${{ matrix.DISTRO }}
run: |
for pkg in "deb" "rpm" "tar"; do
if [[ -f "internal/buildscripts/packaging/tests/images/${pkg}/Dockerfile.${{ matrix.DISTRO }}" ]]; then
echo "SYS_PACKAGE=${pkg}" >> $GITHUB_ENV
exit 0
fi
done
echo "Unknown distro '${{ matrix.DISTRO }}'!"
exit 1
- uses: actions/download-artifact@v3
with:
name: ${{ env.SYS_PACKAGE }}-${{ matrix.ARCH }}-package
path: ./dist
- uses: docker/setup-qemu-action@v2
if: ${{ matrix.ARCH != 'amd64' }}
with:
platforms: ${{ matrix.ARCH }}
- name: Setup python
uses: actions/setup-python@v4
with:
python-version: ${{ env.PYTHON_VERSION }}
cache: 'pip'
cache-dependency-path: ${{ env.REQUIREMENTS_PATH }}
- name: Install pytest
run: |
if which pip; then
pip install --upgrade 'pip==${{ env.PIP_VERSION }}'
else
curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py
python get-pip.py 'pip==${{ env.PIP_VERSION }}'
fi
pip install -r "${{ env.REQUIREMENTS_PATH }}"
- name: Test ${{ env.SYS_PACKAGE }} on ${{ matrix.DISTRO }} ${{ matrix.ARCH }}
run: |
distro="${{ matrix.DISTRO }}"
if [[ "$distro" = "amazonlinux-2" ]]; then
# workaround for pytest substring matching
distro="amazonlinux-2 and not amazonlinux-2023"
fi
pytest -s --verbose -m "${{ env.SYS_PACKAGE }}" \
-k "$distro and ${{ matrix.ARCH }}" \
internal/buildscripts/packaging/tests/package_test.py
windows-msi:
name: windows-msi
# Use 20.04.5 until https://github.com/open-telemetry/opentelemetry-collector-contrib/issues/16450 is resolved
runs-on: ubuntu-20.04
needs: [cross-compile, agent-bundle-windows]
steps:
- name: Check out the codebase.
uses: actions/checkout@v3
- name: Downloading binaries-windows_amd64
uses: actions/download-artifact@v3
with:
name: binaries-windows_amd64
path: ./bin
- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: ${{ env.GO_VERSION }}
cache-dependency-path: '**/go.sum'
- id: latest
uses: pozetroninc/[email protected]
with:
repository: signalfx/splunk-otel-collector
excludes: prerelease, draft
token: ${{ secrets.GITHUB_TOKEN }}
- uses: actions/download-artifact@v3
with:
name: agent-bundle-windows
path: ./dist
- name: Build MSI
run: |
mkdir -p dist
VERSION_TAG="${TAG_NAME:-${{ steps.latest.outputs.release }}.${{ github.run_number }}}"
make msi SKIP_COMPILE=true VERSION="${VERSION_TAG#v}"
- name: Uploading msi build artifacts
uses: actions/upload-artifact@v3
with:
name: msi-build
path: ./dist/*.msi
windows-msi-validation:
name: windows-msi-validation
runs-on: ${{ matrix.OS }}
needs: [windows-msi]
strategy:
matrix:
OS: [ "windows-2019", "windows-2022" ]
MODE: [ "agent", "gateway" ]
WITH_FLUENTD: [ "true", "false" ]
steps:
- name: Check out the codebase.
uses: actions/checkout@v3
- name: Downloading msi build
uses: actions/download-artifact@v3
with:
name: msi-build
path: ./dist
- name: Installation test
env:
token: fake-token
realm: fake-realm
memory: "256"
run: |
$ErrorActionPreference = 'Stop'
Set-PSDebug -Trace 1
$msi_path = Resolve-Path .\dist\splunk-otel-collector*.msi
$env:VERIFY_ACCESS_TOKEN = "false"
.\internal\buildscripts\packaging\installer\install.ps1 -access_token "${{ env.token }}" -realm "${{ env.realm }}" -msi_path "$msi_path" -mode "${{ matrix.MODE }}" -memory "${{ env.memory }}" -with_fluentd $${{ matrix.WITH_FLUENTD }}
Start-Sleep -s 30
& ${{ github.workspace }}\.github\workflows\scripts\win-test-services.ps1 -mode "${{ matrix.MODE }}" -access_token "${{ env.token }}" -realm "${{ env.realm }}" -memory "${{ env.memory }}" -with_fluentd "${{ matrix.WITH_FLUENTD }}"
& ${{ github.workspace }}\.github\workflows\scripts\win-test-support-bundle.ps1 -mode "${{ matrix.MODE }}" -with_fluentd "${{ matrix.WITH_FLUENTD }}"
Test-Path -Path "$env:ProgramFiles\Splunk\OpenTelemetry Collector\agent-bundle\python\python.exe"
Test-Path -Path "$env:ProgramFiles\Splunk\OpenTelemetry Collector\agent-bundle\collectd-python"
- name: splunk-otel-collector logs
if: ${{ always() }}
run: Get-WinEvent -ProviderName splunk-otel-collector | Sort-Object -Property TimeCreated | Select-Object -Property Message | Format-List
- name: fluentd logs
if: ${{ always() && matrix.WITH_FLUENTD == 'true' }}
run: Get-Content -Path "${env:SYSTEMDRIVE}\opt\td-agent\td-agent.log"
windows-choco:
name: windows-choco
runs-on: windows-2019
needs: [windows-msi]
steps:
- name: Check out the codebase.
uses: actions/checkout@v3
- name: Downloading msi build
uses: actions/download-artifact@v3
with:
name: msi-build
path: ./dist
- name: Build Chocolatey
run: |
$ErrorActionPreference = 'Stop'
Set-PSDebug -Trace 1
$msi_file_path = Resolve-Path .\dist\splunk-otel-collector*.msi
$msi_file_name = Resolve-Path .\dist\splunk-otel-collector*.msi | Split-Path -leaf
$msi_file_name -match '(\d+\.)(\d+\.)+(\d*)'
$version = $matches[0]
write-host "Building choco package..."
.\internal\buildscripts\packaging\choco\make.ps1 build_choco -MSIFile $msi_file_path -Version $version | Tee-Object -file .\dist\build_logs.log
Test-Path -Path ".\dist\splunk-otel-collector.$version.nupkg"
- name: Test install without parameters
run: |
$ErrorActionPreference = 'Stop'
Set-PSDebug -Trace 1
choco install splunk-otel-collector -s=".\dist" -y
if ($LASTEXITCODE -ne 0) {
throw "choco install failed!"
}
# the collector service should not be running if installed without the SPLUNK_ACCESS_TOKEN parameter
if ((Get-CimInstance -ClassName win32_service -Filter "Name = 'splunk-otel-collector'" | Select Name, State).State -Eq "Running") {
throw "splunk-otel-collector is running"
}
- name: Uploading choco build artifacts
uses: actions/upload-artifact@v3
with:
name: choco-build
path: ./dist/*.nupkg
windows-choco-validation:
name: windows-choco-validation
runs-on: ${{ matrix.OS }}
needs: [windows-choco]
strategy:
matrix:
OS: [ "windows-2019", "windows-2022" ]
MODE: [ "agent", "gateway" ]
WITH_FLUENTD: [ "true", "false" ]
SCENARIO: [ "install", "upgrade" ]
fail-fast: false
steps:
- name: Check out the codebase.
uses: actions/checkout@v3
- name: Downloading choco build
uses: actions/download-artifact@v3
with:
name: choco-build
path: ./dist
- name: Chocolatey ${{ matrix.SCENARIO }} test
env:
token: fake-token
realm: fake-realm
memory: "256"
run: |
$ErrorActionPreference = 'Stop'
Set-PSDebug -Trace 1
$choco_file_name = Resolve-Path .\dist\splunk-otel-collector*.nupkg
$params = "/SPLUNK_ACCESS_TOKEN=${{ env.token }} /SPLUNK_REALM=${{ env.realm }} /SPLUNK_MEMORY_TOTAL_MIB=${{ env.memory }} /MODE:${{ matrix.MODE }} /WITH_FLUENTD:${{ matrix.WITH_FLUENTD }}"
if ("${{ matrix.SCENARIO }}" -eq "install") {
write-host "Installing $choco_file_name ..."
choco install splunk-otel-collector -s=".\dist" --params="'$params'" -y
if ($LASTEXITCODE -ne 0) {
throw "choco install failed!"
}
} else {
write-host "Installing splunk-otel-collector 0.74.0 ..."
choco feature enable -n=useRememberedArgumentsForUpgrades
choco install splunk-otel-collector --no-progress --version=0.74.0 --params="'$params'" -y
if ($LASTEXITCODE -ne 0) {
throw "choco install failed!"
}
Start-Sleep 30
write-host "Upgrading $choco_file_name ..."
choco upgrade splunk-otel-collector -s=".\dist" -y
if ($LASTEXITCODE -ne 0) {
throw "choco upgrade failed!"
}
}
Start-Sleep -s 30
& ${{ github.workspace }}\.github\workflows\scripts\win-test-services.ps1 -mode "${{ matrix.MODE }}" -access_token "${{ env.token }}" -realm "${{ env.realm }}" -memory "${{ env.memory }}" -with_fluentd "${{ matrix.WITH_FLUENTD }}"
& ${{ github.workspace }}\.github\workflows\scripts\win-test-support-bundle.ps1 -mode "${{ matrix.MODE }}" -with_fluentd "${{ matrix.WITH_FLUENTD }}"
- name: splunk-otel-collector logs
if: ${{ always() }}
run: Get-WinEvent -ProviderName splunk-otel-collector | Sort-Object -Property TimeCreated | Select-Object -Property Message | Format-List
- name: fluentd logs
if: ${{ always() && matrix.WITH_FLUENTD == 'true' }}
run: Get-Content -Path "${env:SYSTEMDRIVE}\opt\td-agent\td-agent.log"
- name: Uninstall test
run: |
choco uninstall splunk-otel-collector -y
if ($LASTEXITCODE -ne 0) {
throw "choco uninstall failed!"
}
Start-Sleep -s 30
if ((Get-CimInstance -ClassName win32_service -Filter "Name = 'splunk-otel-collector'" | Select Name, State).State -Eq "Running") {
throw "splunk-otel-collector service is still running"
}
windows-zeroconfig-sources:
runs-on: ubuntu-latest
# Required permissions
permissions:
pull-requests: read
# Set job outputs to values from filter step
outputs:
changed: ${{ steps.filter.outputs.changed }}
steps:
- name: Check out the codebase.
uses: actions/checkout@v3
- uses: dorny/paths-filter@v2
id: filter
with:
filters: |
changed:
- '.github/workflows/build-and-test.yml'
- 'internal/buildscripts/packaging/installer/install.ps1'
- 'internal/buildscripts/packaging/msi/**'
- 'pkg/signalfx-agent/bundle/**'
- 'tests/zeroconfig/windows/**'
windows-zeroconfig-e2e-test:
needs: [ windows-zeroconfig-sources, windows-msi ]
if: ${{ github.ref_name == 'main' || needs.windows-zeroconfig-sources.outputs.changed == 'true' }}
runs-on: windows-2022
steps:
- name: Check out the codebase.
uses: actions/checkout@v3
- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: ${{ env.GO_VERSION }}
cache-dependency-path: '**/go.sum'
- name: Setup NuGet
uses: nuget/[email protected]
- name: Add msbuild to PATH
uses: microsoft/[email protected]
- uses: actions/[email protected]
with:
dotnet-version: |
6.0.407
- name: Download Splunk OTel Collector msi
uses: actions/download-artifact@v3
with:
name: msi-build
path: ./tests/zeroconfig/windows/testdata/docker-setup/
- name: Run the test script
working-directory: tests/zeroconfig/windows/
run: |
.\run-tests.ps1
docker-otelcol:
name: docker-otelcol
# Use 20.04.5 until https://github.com/open-telemetry/opentelemetry-collector-contrib/issues/16450 is resolved
runs-on: ubuntu-20.04
needs: [cross-compile, agent-bundle-linux]
strategy:
matrix:
ARCH: [ "amd64", "arm64", "ppc64le" ]
steps:
- name: Check out the codebase.
uses: actions/checkout@v3
- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: ${{ env.GO_VERSION }}
cache-dependency-path: '**/go.sum'
- name: Set up QEMU
if: ${{ matrix.ARCH != 'amd64' }}
uses: docker/setup-qemu-action@v2
with:
platforms: ${{ matrix.ARCH }}
- name: Downloading binaries-linux_${{ matrix.ARCH }}
uses: actions/download-artifact@v3
with:
name: binaries-linux_${{ matrix.ARCH }}
path: ./bin
- uses: actions/download-artifact@v3
if: ${{ matrix.ARCH != 'ppc64le' }}
with:
name: agent-bundle-linux-${{ matrix.ARCH }}
path: ./dist
- name: Build ${{ matrix.ARCH }} docker image
run: |
make docker-otelcol SKIP_COMPILE=true SKIP_BUNDLE=true ARCH=${{ matrix.ARCH }}
- name: Check image arch
run: |
# ensure that the arch in the image manifest is correct
[ "$( docker inspect --format='{{.Architecture}}' otelcol:${{ matrix.ARCH }} )" = "${{ matrix.ARCH }}" ] || exit 1
- name: Run docker image
run: |
# ensure the collector can start with the default config file
docker run --platform linux/${{ matrix.ARCH }} -d -e SPLUNK_ACCESS_TOKEN=12345 -e SPLUNK_REALM=fake-realm --name otelcol otelcol:${{ matrix.ARCH }}
sleep 10
if [ -z "$( docker ps --filter=status=running --filter=name=otelcol -q )" ]; then
docker logs otelcol
echo "Failing job execution: fail to start otelcol docker container with the default config in 10 seconds."
exit 1
fi
# get all provided config files from the container
tmpdir=$(mktemp -d)
docker cp otelcol:/etc/otel/collector $tmpdir
docker rm -f otelcol
# ensure the collector can start with all provided config files
configs=$(ls ${tmpdir}/collector/ 2>/dev/null)
if [ -z "$configs" ]; then
echo "failed to get config files from otelcol:/etc/otel/collector"
exit 1
fi
for config in $configs; do
docker run --platform linux/${{ matrix.ARCH }} -d -e SPLUNK_CONFIG=/etc/otel/collector/${config} -e SPLUNK_ACCESS_TOKEN=12345 -e SPLUNK_REALM=fake-realm --name otelcol otelcol:${{ matrix.ARCH }}
sleep 10
if [ -z "$( docker ps --filter=status=running --filter=name=otelcol -q )" ]; then
docker logs otelcol
echo "Failing job execution: fail to start otelcol docker container with ${config} in 10 seconds."
exit 1
fi
docker rm -f otelcol
done
- name: Check journalctl
run: |
# ensure journalctl can run with the collected libraries
docker run --platform linux/${{ matrix.ARCH }} -d -e SPLUNK_ACCESS_TOKEN=12345 -e SPLUNK_REALM=fake-realm --name otelcol otelcol:${{ matrix.ARCH }}
docker exec otelcol /bin/journalctl
docker rm -f otelcol
- name: Check python and java
if: ${{ matrix.ARCH != 'ppc64le' }}
run: |
# ensure python and java can run with the collected libraries
docker run --platform linux/${{ matrix.ARCH }} -d -e SPLUNK_ACCESS_TOKEN=12345 -e SPLUNK_REALM=fake-realm --name otelcol otelcol:${{ matrix.ARCH }}
docker exec otelcol /usr/lib/splunk-otel-collector/agent-bundle/bin/python --version
docker exec otelcol /usr/lib/splunk-otel-collector/agent-bundle/jre/bin/java -version
# ensure collectd-python plugins were installed
docker exec otelcol bash -c 'test -d /usr/lib/splunk-otel-collector/agent-bundle/collectd-python/'
if [[ "$(docker exec otelcol ls /usr/lib/splunk-otel-collector/agent-bundle/collectd-python/ | wc -l)" -eq 0 ]]; then
echo "/usr/lib/splunk-otel-collector/agent-bundle/collectd-python/ is empty!" >&2
exit 1
fi
docker rm -f otelcol
docker-otelcol-windows:
name: docker-otelcol-windows
runs-on: windows-2019
needs: [cross-compile, agent-bundle-windows]
steps:
- name: Check out the codebase.
uses: actions/checkout@v3
- name: Downloading binaries-windows_amd64
uses: actions/download-artifact@v3
with:
name: binaries-windows_amd64
path: ./bin
- uses: actions/download-artifact@v3
with:
name: agent-bundle-windows
path: ./dist
- name: Build docker image
run: |
$ErrorActionPreference = 'Stop'
Copy-Item .\bin\otelcol_windows_amd64.exe .\cmd\otelcol\otelcol.exe
Copy-Item .\bin\translatesfx_windows_amd64.exe .\cmd\otelcol\translatesfx.exe
Copy-Item .\dist\agent-bundle_windows_amd64.zip .\cmd\otelcol\agent-bundle_windows_amd64.zip
docker build -t otelcol-windows --build-arg BASE_IMAGE=mcr.microsoft.com/windows/servercore:1809 -f .\cmd\otelcol\Dockerfile.windows .\cmd\otelcol\
Remove-Item .\cmd\otelcol\otelcol.exe
Remove-Item .\cmd\otelcol\translatesfx.exe
Remove-Item .\cmd\otelcol\agent-bundle_windows_amd64.zip
- name: Run docker image
run: |
$ErrorActionPreference = 'Stop'
docker run -d -e SPLUNK_ACCESS_TOKEN=12345 -e SPLUNK_REALM=fake-realm --name otelcol otelcol-windows:latest
Start-Sleep 10
$DockerOutput=$(docker ps --filter=status=running --filter=name=otelcol -q)
if ( $DockerOutput -eq $null ) {
docker logs otelcol
echo "Failing job execution: fail to start otelcol docker container in 10 seconds."
exit 1
}
docker-otelcol-windows-2022:
name: docker-otelcol-windows-2022
runs-on: windows-2022
needs: [cross-compile, agent-bundle-windows]
steps:
- name: Check out the codebase.
uses: actions/checkout@v3
- name: Downloading binaries-windows_amd64
uses: actions/download-artifact@v3
with:
name: binaries-windows_amd64
path: ./bin
- uses: actions/download-artifact@v3
with:
name: agent-bundle-windows
path: ./dist
- name: Build docker image
run: |
$ErrorActionPreference = 'Stop'
Copy-Item .\bin\otelcol_windows_amd64.exe .\cmd\otelcol\otelcol.exe
Copy-Item .\bin\translatesfx_windows_amd64.exe .\cmd\otelcol\translatesfx.exe
Copy-Item .\dist\agent-bundle_windows_amd64.zip .\cmd\otelcol\agent-bundle_windows_amd64.zip
docker build -t otelcol-windows --build-arg BASE_IMAGE=mcr.microsoft.com/windows/servercore:ltsc2022 -f .\cmd\otelcol\Dockerfile.windows .\cmd\otelcol\
Remove-Item .\cmd\otelcol\otelcol.exe
Remove-Item .\cmd\otelcol\translatesfx.exe
Remove-Item .\cmd\otelcol\agent-bundle_windows_amd64.zip
- name: Run docker image
run: |
$ErrorActionPreference = 'Stop'
docker run -d -e SPLUNK_ACCESS_TOKEN=12345 -e SPLUNK_REALM=fake-realm --name otelcol otelcol-windows:latest
Start-Sleep 10
$DockerOutput=$(docker ps --filter=status=running --filter=name=otelcol -q)
if ( $DockerOutput -eq $null ) {
docker logs otelcol
echo "Failing job execution: fail to start otelcol docker container in 10 seconds."
exit 1
}