@@ -1019,6 +1019,7 @@ func (s *ResolverTestSuite) TestIntentsToApiServerDNS() {
10191019 Destinations : []test_gql_client.Destination {
10201020 {
10211021 Destination : fmt .Sprintf ("%s.%s.svc.cluster.local" , service .GetName (), service .GetNamespace ()),
1022+ LastSeen : time .Now ().Add (time .Minute ),
10221023 },
10231024 },
10241025 },
@@ -1070,7 +1071,7 @@ func (s *ResolverTestSuite) TestIntentsToApiServerSocketScan() {
10701071 Destinations : []test_gql_client.Destination {
10711072 {
10721073 Destination : service .Spec .ClusterIP ,
1073- LastSeen : time .Now (),
1074+ LastSeen : time .Now (). Add ( time . Minute ) ,
10741075 },
10751076 },
10761077 },
@@ -1365,6 +1366,60 @@ func (s *ResolverTestSuite) TestTCPResultsFromExternalToLoadBalancerServiceUsing
13651366 s .Require ().Equal ("8.8.8.8" , intents [0 ].Intent .IP )
13661367}
13671368
1369+ func (s * ResolverTestSuite ) TestResolveOtterizeIdentityFilterSrcDestinationsByCreationTimestamp () {
1370+ podIP := "1.1.1.3"
1371+ pod := s .AddPod ("pod3" , podIP , nil , nil )
1372+ s .Require ().True (s .Mgr .GetCache ().WaitForCacheSync (context .Background ()))
1373+ recorededDestinationForSrc := & model.RecordedDestinationsForSrc {
1374+ SrcIP : podIP ,
1375+ Destinations : []model.Destination {
1376+ {
1377+ Destination : "target-on-time" ,
1378+ LastSeen : pod .CreationTimestamp .Add (time .Minute ),
1379+ },
1380+ {
1381+ Destination : "target-before-time" ,
1382+ LastSeen : pod .CreationTimestamp .Add (- time .Minute ),
1383+ },
1384+ },
1385+ }
1386+ srcIdentity , err := s .resolver .discoverInternalSrcIdentity (context .Background (), recorededDestinationForSrc )
1387+ s .Require ().NoError (err )
1388+ s .Require ().Equal ("pod3" , srcIdentity .Name )
1389+
1390+ s .Require ().Len (recorededDestinationForSrc .Destinations , 1 )
1391+ s .Require ().Equal ("target-on-time" , recorededDestinationForSrc .Destinations [0 ].Destination )
1392+
1393+ }
1394+
1395+ func (s * ResolverTestSuite ) TestPoop () {
1396+ //serviceIP := "10.0.0.10"
1397+ podIP := "1.1.1.3"
1398+
1399+ pod3 := s .AddPod ("pod3" , podIP , nil , nil )
1400+ //s.AddService(serviceName, map[string]string{"app": "test"}, serviceIP, []*v1.Pod{pod3})
1401+ s .Require ().True (s .Mgr .GetCache ().WaitForCacheSync (context .Background ()))
1402+
1403+ pod := & v1.Pod {}
1404+ err := s .Mgr .GetClient ().Get (context .Background (), types.NamespacedName {Name : pod3 .Name , Namespace : pod3 .Namespace }, pod )
1405+ s .Require ().NoError (err )
1406+ podlist1 := & v1.PodList {}
1407+ err = s .Mgr .GetClient ().List (context .Background (), podlist1 , client.MatchingFields {"ip" : pod .Status .PodIP })
1408+ s .Require ().NoError (err )
1409+ s .Require ().Len (podlist1 .Items , 1 )
1410+
1411+ err = s .Mgr .GetClient ().Delete (context .Background (), pod )
1412+ s .Require ().NoError (err )
1413+
1414+ s .Require ().True (s .Mgr .GetCache ().WaitForCacheSync (context .Background ()))
1415+
1416+ podlist := & v1.PodList {}
1417+ err = s .Mgr .GetClient ().List (context .Background (), podlist , client.MatchingFields {"ip" : pod .Status .PodIP })
1418+ s .Require ().NoError (err )
1419+ s .Require ().Empty (podlist .Items )
1420+
1421+ }
1422+
13681423func TestRunSuite (t * testing.T ) {
13691424 suite .Run (t , new (ResolverTestSuite ))
13701425}
0 commit comments