Skip to content

Commit

Permalink
Fixed component test
Browse files Browse the repository at this point in the history
Signed-off-by: Afek Berger <[email protected]>
  • Loading branch information
afek854 committed Nov 17, 2024
1 parent b14a3b2 commit e1583de
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
7 changes: 6 additions & 1 deletion .github/workflows/component-tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ jobs:
Test_11_EndpointTest,
Test_12_MergingProfilesTest,
Test_13_MergingNetworkNeighborhoodTest,
Test_14_RulePoliciesTest,
]
steps:
- name: Checkout code
Expand Down Expand Up @@ -97,9 +98,13 @@ jobs:
- name: Run test
run: |
cd tests && go test -v ./... -run ${{ matrix.test }} --timeout=20m --tags=component
- name: Print storage logs
- name: Print node agent & storage logs
if: always()
run: |
echo "Node agent logs"
kubectl logs $(kubectl get pods -n kubescape -o name | grep node-agent) -n kubescape
echo "-----------------------------------------"
echo "Storage logs"
kubectl logs $(kubectl get pods -n kubescape -o name | grep storage) -n kubescape
# - name: Upload plot images
Expand Down
8 changes: 5 additions & 3 deletions tests/component_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1170,7 +1170,7 @@ func Test_14_RulePoliciesTest(t *testing.T) {

fmt.Println("After completed")

time.Sleep(30 * time.Second)
time.Sleep(60 * time.Second)

// generate hardlink alert
_, _, err = endpointTraffic.ExecIntoPod([]string{"ln", "/etc/shadow", "/tmp/a"}, "")
Expand All @@ -1183,14 +1183,16 @@ func Test_14_RulePoliciesTest(t *testing.T) {
assert.NoError(t, err)

// Wait for the alert to be signaled
time.Sleep(30 * time.Second)
time.Sleep(60 * time.Second)

alerts, err := testutils.GetAlerts(endpointTraffic.Namespace)
if err != nil {
t.Errorf("Error getting alerts: %v", err)
}

assert.Equal(t, 1, len(alerts), "Expected 1 alert to be generated, but got %d alerts", len(alerts))
testutils.AssertContains(t, alerts, "Hardlink Created Over Sensitive File", "ln", "endpoint-traffic")
testutils.AssertNotContains(t, alerts, "Symlink Created Over Sensitive File", "ln", "endpoint-traffic")

}

func ptr(i int32) *int32 {
Expand Down

0 comments on commit e1583de

Please sign in to comment.