Skip to content

Commit e17d88b

Browse files
authored
chore(make): re-create test targets (aquasecurity#1559)
Instead of grouping tests by tracee-ebpf and tracee-rules we will group them by scope, i.e. unit, integration, and end-to-end tests. . / \\ / \ \ / E2E \' \ / TESTS \'' \ /---------\ ' '\ / \'' \ / INTEGRATION \ ' ' \ / TESTS \ '' \ /-----------------\' ' ' ' \ / \' ' ' ' \ / \' ' ' ' \ / UNIT TESTS \ ' ' / / \ ' / / \' / /_____________________________\/ NB There are still some tests that do not fall into category of unit, integration, nor end-to-end tests, but fixing them is out of scope of this patch. Resolves: aquasecurity#1522 Signed-off-by: Daniel Pacak <[email protected]>
1 parent 794a55e commit e17d88b

File tree

16 files changed

+114
-168
lines changed

16 files changed

+114
-168
lines changed

.github/workflows/pr.yaml

Lines changed: 18 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,9 @@ jobs:
3232
gofmt -s -d .
3333
exit 1
3434
fi
35-
verify-tracee-ebpf:
36-
name: Verify tracee-ebpf
37-
needs:
38-
- verify-code
35+
36+
run-unit-tests:
37+
name: "Run Unit Tests"
3938
runs-on: ubuntu-20.04
4039
steps:
4140
- name: Checkout Code
@@ -47,16 +46,15 @@ jobs:
4746
with:
4847
go-version: ${{ env.GO_VERSION }}
4948
opa-version: ${{ env.OPA_VERSION }}
50-
- name: Build tracee-ebpf
51-
run: |
52-
make tracee-ebpf
53-
- name: Test tracee-ebpf
49+
- name: Run Unit Tests
5450
run: |
55-
make test-tracee-ebpf
56-
verify-tracee-rules:
57-
name: Verify tracee-rules
51+
make test-unit
52+
53+
run-integration-tests:
54+
name: "Run Integration Tests"
5855
needs:
5956
- verify-code
57+
- run-unit-tests
6058
runs-on: ubuntu-20.04
6159
steps:
6260
- name: Checkout Code
@@ -68,16 +66,15 @@ jobs:
6866
with:
6967
go-version: ${{ env.GO_VERSION }}
7068
opa-version: ${{ env.OPA_VERSION }}
71-
- name: Build tracee-rules
72-
run: |
73-
make tracee-rules
74-
- name: Test tracee-rules
69+
- name: Run Integration Tests
7570
run: |
76-
make test-tracee-rules
71+
make test-integration
72+
7773
verify-signatures:
7874
name: Verify Signatures
7975
needs:
8076
- verify-code
77+
- run-unit-tests
8178
runs-on: ubuntu-20.04
8279
steps:
8380
- name: Checkout Code
@@ -98,8 +95,7 @@ jobs:
9895
release-snapshot:
9996
name: Release Snapshot
10097
needs:
101-
- verify-tracee-ebpf
102-
- verify-tracee-rules
98+
- run-integration-tests
10399
- verify-signatures
104100
runs-on: ubuntu-20.04
105101
steps:
@@ -137,8 +133,7 @@ jobs:
137133
smoke-test-noncore:
138134
name: "[Smoke] Test non CO-RE"
139135
needs:
140-
- verify-tracee-ebpf
141-
- verify-tracee-rules
136+
- run-integration-tests
142137
- verify-signatures
143138
runs-on: ubuntu-20.04
144139
steps:
@@ -160,7 +155,7 @@ jobs:
160155
- name: Run tests
161156
run: |
162157
docker image pull aquasec/tracee-tester:latest
163-
go test -v -run "TestTraceeSignatures" ./tests/tracee_test.go \
158+
go test -v -run "TestTraceeSignatures" ./tests/e2e/e2e_test.go \
164159
-tracee-image-ref "tracee:full" \
165160
-tracee-tester-image-ref "aquasec/tracee-tester:latest" \
166161
-tracee-signatures "TRC-2"
@@ -171,8 +166,7 @@ jobs:
171166
smoke-test-core:
172167
name: "[Smoke] Test CO-RE"
173168
needs:
174-
- verify-tracee-ebpf
175-
- verify-tracee-rules
169+
- run-integration-tests
176170
- verify-signatures
177171
runs-on: ubuntu-20.04
178172
steps:
@@ -194,7 +188,7 @@ jobs:
194188
- name: Run tests
195189
run: |
196190
docker image pull aquasec/tracee-tester:latest
197-
go test -v -run "TestTraceeSignatures" ./tests/tracee_test.go \
191+
go test -v -run "TestTraceeSignatures" ./tests/e2e/e2e_test.go \
198192
-tracee-image-ref "tracee:latest" \
199193
-tracee-tester-image-ref "aquasec/tracee-tester:latest" \
200194
-tracee-signatures "TRC-2"

.github/workflows/scheduled-signatures-test.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,6 @@ jobs:
3333
- name: Run tests
3434
run: |
3535
docker image pull aquasec/tracee-tester:latest
36-
go test -v -run "TestTraceeSignatures" ./tests/tracee_test.go \
36+
go test -v -run "TestTraceeSignatures" ./tests/e2e/e2e_test.go \
3737
-tracee-image-ref "tracee:latest" \
3838
-tracee-tester-image-ref "aquasec/tracee-tester:latest"

Makefile

Lines changed: 38 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -234,9 +234,9 @@ help:
234234
@echo ""
235235
@echo "# test"
236236
@echo ""
237-
@echo " $$ make test # run all go & opa tests"
238-
@echo " $$ make test-tracee-ebpf # go test tracee-ebpf"
239-
@echo " $$ make test-tracee-rules # go test tracee-rules"
237+
@echo " $$ make test-types # run unit tests for types module"
238+
@echo " $$ make test-unit # run unit tests"
239+
@echo " $$ make test-integration # run integration tests"
240240
@echo " $$ make test-rules # opa test (tracee-rules)"
241241
@echo ""
242242
@echo "# flags"
@@ -488,18 +488,6 @@ clean-tracee-ebpf:
488488
$(CMD_RM) -rf $(OUTPUT_DIR)/tracee-ebpf
489489
$(CMD_RM) -rf .*.md5
490490

491-
.PHONY: test-tracee-ebpf
492-
test-tracee-ebpf: \
493-
.checkver_$(CMD_GO) \
494-
$(OUTPUT_DIR)/tracee.bpf.core.o
495-
#
496-
$(MAKE) $(OUTPUT_DIR)/btfhub
497-
$(GO_ENV_EBPF) $(CMD_GO) test \
498-
-tags $(GO_TAGS_EBPF) \
499-
-v \
500-
./cmd/tracee-ebpf/... \
501-
./pkg/...
502-
503491
#
504492
# btfhub (expensive: only run if core obj changed)
505493
#
@@ -567,17 +555,44 @@ clean-tracee-rules:
567555
#
568556
$(CMD_RM) -rf $(OUTPUT_DIR)/tracee-rules
569557

570-
.PHONY: test-tracee-rules
571-
test-tracee-rules: \
558+
.PHONY: test-unit
559+
test-unit: \
560+
.checkver_$(CMD_GO) \
561+
tracee-ebpf \
562+
test-types
563+
#
564+
$(GO_ENV_EBPF) \
565+
$(CMD_GO) test \
566+
-tags ebpf \
567+
-short \
568+
-v \
569+
-coverprofile=coverage.txt \
570+
./...
571+
572+
.PHONY: test-types
573+
test-types: \
572574
.checkver_$(CMD_GO)
573575
#
574-
$(GO_ENV_RULES) $(CMD_GO) test \
575-
-tags $(GO_TAGS_RULES) \
576+
# Note that we must changed the directory here because types is a standalone Go module.
577+
cd ./types && $(CMD_GO) test \
578+
-short \
579+
-race \
580+
-v \
581+
-coverprofile=coverage.txt \
582+
./...
583+
584+
.PHONY: test-integration
585+
test-integration: \
586+
.checkver_$(CMD_GO) \
587+
tracee-ebpf
588+
#
589+
TRC_BIN=$(abspath $(OUTPUT_DIR)/tracee-ebpf) \
590+
$(GO_ENV_EBPF) \
591+
$(CMD_GO) test \
592+
-tags ebpf,integration \
576593
-v \
577-
./cmd/tracee-rules/... \
578-
./pkg/rules/...
579-
cd ./types; $(CMD_GO) test -v ./...
580-
cd ..
594+
-run "Test_Events" ./tests/integration/...
595+
581596
#
582597
# rules
583598
#
@@ -626,13 +641,6 @@ test-rules: \
626641
#
627642
$(CMD_OPA) test $(REGO_SIGNATURES_DIR) --verbose
628643

629-
#
630-
# test
631-
#
632-
633-
.PHONY: test
634-
test: test-tracee-ebpf test-tracee-rules test-rules
635-
636644
#
637645
# clean
638646
#

Vagrantfile

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22
# vi: set ft=ruby :
33

44
Vagrant.configure("2") do |config|
5-
# config.vm.box = "ubuntu/focal64" # Ubuntu 20.04 Focal Fossa (no CORE)
6-
# config.vm.box = "ubuntu/hirsute64" # Ubuntu 21.04 Hirsute Hippo (CORE)
7-
config.vm.box = "ubuntu/impish64" # Ubuntu 21.10 Impish Indri (CORE)
5+
# config.vm.box = "ubuntu/focal64" # Ubuntu 20.04 Focal Fossa (non CO-RE)
6+
# config.vm.box = "ubuntu/hirsute64" # Ubuntu 21.04 Hirsute Hippo (CO-RE)
7+
config.vm.box = "ubuntu/impish64" # Ubuntu 21.10 Impish Indri (CO-RE)
88

99
config.vm.provider "virtualbox" do |vb|
1010
vb.gui = false

cmd/tracee-rules/output_test.go

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -251,14 +251,14 @@ HostName: foobar.local
251251
}
252252
}
253253

254-
func TestJsonTemplateV1(t *testing.T) {
254+
func TestOutputTemplates(t *testing.T) {
255255
testCases := []struct {
256256
testName string
257257
finding detect.Finding
258258
expectedJson string
259259
}{
260260
{
261-
testName: "convert finding to v1",
261+
testName: "Should output finding as raw JSON",
262262
finding: detect.Finding{
263263
Data: map[string]interface{}{
264264
"a": 123,
@@ -303,15 +303,13 @@ func TestJsonTemplateV1(t *testing.T) {
303303
}
304304

305305
jsonTemplate, err := setupTemplate("templates/rawjson.tmpl")
306-
307306
require.NoError(t, err)
308307

309308
for _, tc := range testCases {
310309
t.Run(tc.testName, func(t *testing.T) {
311-
//pass finding through template and compare to a v1 json
312310
var buf bytes.Buffer
313-
jsonTemplate.Execute(&buf, tc.finding)
314-
311+
err := jsonTemplate.Execute(&buf, tc.finding)
312+
require.NoError(t, err)
315313
assert.JSONEq(t, tc.expectedJson, buf.String())
316314
})
317315
}

go.mod

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ require (
88
github.com/aquasecurity/tracee/types v0.0.0-20220228102148-dffb469aed94
99
github.com/google/gopacket v1.1.19
1010
github.com/hashicorp/golang-lru v0.5.4
11-
github.com/kelseyhightower/envconfig v1.4.0
1211
github.com/mitchellh/go-ps v1.0.0
1312
github.com/onsi/gomega v1.17.0
1413
github.com/open-policy-agent/opa v0.35.0

go.sum

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -481,8 +481,6 @@ github.com/jstemmer/go-junit-report v0.9.1/go.mod h1:Brl9GWCQeLvo8nXZwPNNblvFj/X
481481
github.com/jtolds/gls v4.20.0+incompatible/go.mod h1:QJZ7F/aHp+rZTRtaJ1ow/lLfFfVYBRgL+9YlvaHOwJU=
482482
github.com/julienschmidt/httprouter v1.2.0/go.mod h1:SYymIcj16QtmaHHD7aYtjjsJG7VTCxuUUipMqKk8s4w=
483483
github.com/julienschmidt/httprouter v1.3.0/go.mod h1:JR6WtHb+2LUe8TCKY3cZOxFyyO8IZAc4RVcycCCAKdM=
484-
github.com/kelseyhightower/envconfig v1.4.0 h1:Im6hONhd3pLkfDFsbRgu68RDNkGF1r3dvMUtDTo2cv8=
485-
github.com/kelseyhightower/envconfig v1.4.0/go.mod h1:cccZRl6mQpaq41TPp5QxidR+Sa3axMbJDNb//FQX6Gg=
486484
github.com/kisielk/errcheck v1.1.0/go.mod h1:EZBBE59ingxPouuu3KfxchcWSUPOHkagtvWXihfKN4Q=
487485
github.com/kisielk/errcheck v1.2.0/go.mod h1:/BMXB+zMLi60iA8Vv6Ksmxu/1UDYcXs4uQLJ+jE2L00=
488486
github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8=

pkg/test/gob/Readme.md

Lines changed: 0 additions & 5 deletions
This file was deleted.

pkg/test/gob/gob.go

Lines changed: 0 additions & 56 deletions
This file was deleted.

pkg/test/loader.sh

Lines changed: 0 additions & 17 deletions
This file was deleted.

0 commit comments

Comments
 (0)