@@ -22,7 +22,6 @@ import (
2222 "path/filepath"
2323 "runtime"
2424 "slices"
25- "strconv"
2625 "strings"
2726 "testing"
2827 "time"
@@ -1805,7 +1804,8 @@ type certificatePaths struct {
18051804// TestPolicyReassignWithTamperProtectedEndpoint creates a policy with Elastic Defend (i.e. Endpoint)
18061805// in it, making sure it has tamper protection enabled, and enrolls an Agent to this policy. A second
18071806// policy, also with Elastic Defend and tamper protection enabled is created, and the Agent is reassigned
1808- // to this policy. Endpoint should not be uninstalled and reinstalled as a result of this policy reassignment.
1807+ // to this policy. Endpoint should not be uninstalled and reinstalled as a result of this policy reassignment
1808+ // but should be running the new policy.
18091809func TestPolicyReassignWithTamperProtectedEndpoint (t * testing.T ) {
18101810 info := define .Require (t , define.Requirements {
18111811 Group : integration .FleetEndpointSecurity ,
@@ -1880,10 +1880,6 @@ func TestPolicyReassignWithTamperProtectedEndpoint(t *testing.T) {
18801880 // Get Endpoint's policy ID
18811881 firstEndpointPolicyID := getEndpointPolicyID (t , ctx )
18821882
1883- // Get Endpoint process ID before policy reassignment
1884- firstPID := getEndpointPID (t )
1885- require .NotZero (t , firstPID )
1886-
18871883 t .Log ("Creating the second policy" )
18881884 secondPolicy := createBasicPolicy ()
18891885 policyResp , _ = createPolicyAndEnrollmentToken (ctx , t , info .KibanaClient , secondPolicy )
@@ -1937,42 +1933,6 @@ func TestPolicyReassignWithTamperProtectedEndpoint(t *testing.T) {
19371933 time .Second ,
19381934 "Endpoint is not running a different policy after policy reassignment" ,
19391935 )
1940-
1941- // Get Endpoint process ID after policy reassignment
1942- secondPID := getEndpointPID (t )
1943- require .NotZero (t , secondPID )
1944-
1945- // Assert that endpoint process IDs haven't changed across policy reassignment
1946- t .Log ("Ensuring that Endpoint has not restarted" )
1947- require .Equal (t , firstPID , secondPID )
1948- }
1949-
1950- func getEndpointPID (t * testing.T ) int {
1951- entries , err := os .ReadDir ("/proc" )
1952- require .NoError (t , err )
1953-
1954- for _ , entry := range entries {
1955- if ! entry .IsDir () {
1956- continue
1957- }
1958-
1959- currPID , err := strconv .Atoi (entry .Name ())
1960- if err != nil {
1961- continue // not a PID directory
1962- }
1963-
1964- exePath := filepath .Join ("/proc" , entry .Name (), "exe" )
1965- resolvedExePath , err := os .Readlink (exePath )
1966- if err != nil {
1967- continue // permission denied or process exited
1968- }
1969-
1970- if resolvedExePath == "/opt/Elastic/Endpoint/elastic-endpoint" {
1971- return currPID
1972- }
1973- }
1974-
1975- return 0
19761936}
19771937
19781938func getEndpointPolicyID (t * testing.T , ctx context.Context ) string {
0 commit comments