Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add UT for route agent health checker #3152

Merged

Conversation

aswinsuryan
Copy link
Contributor

Add UT for route agent health checker

@submariner-bot
Copy link
Contributor

🤖 Created branch: z_pr3152/aswinsuryan/route-agent-health-checker-ut
🚀 Full E2E won't run until the "ready-to-test" label is applied. I will add it automatically once the PR has 2 approvals, or you can add it manually.

@aswinsuryan aswinsuryan force-pushed the route-agent-health-checker-ut branch 8 times, most recently from 3cef4f7 to e118bf2 Compare September 5, 2024 12:02
@tpantelis
Copy link
Contributor

I think we should structure the test specs as follows:

var _ = Describe("RouteAgent syncing", func() {
    It("should create a RouteAgent resource", func() {
         // await the RouteAgent - no RemoteEndpoint info expected
    })

    When("a remote Endpoint is created", func() {
        It("should add its RemoteEndpoint information to the RouteAgent resource", func() {
            // await the RemoteEndpoint and verify the Spec
        })
    })

    When("a remote Endpoint is updated", func() {
        It("should update its RemoteEndpoint information in the RouteAgent resource", ...)

    When("a remote Endpoint is deleted", func() {
        It("should remove its RemoteEndpoint information from the RouteAgent resource", ...)
})

var _ = Describe("RemoteEndpoint latency info", func() {
    When("a remote Endpoint is created", func() {
        It("should start a pinger and correctly update the RemoteEndpoint Status and LatencyInfo", func() {
            // await the RemoteEndpoint and verify the LatencyInfo and Status
        })

        Context("with no HealthCheckIP", func() {
		It("should not start a pinger and should set the RemoteEndpoint Status to None", ...)
	})

        Context("with health check not enabled", func() {
		It("should not start a pinger and should set the RemoteEndpoint Status to None", ...)
	})

        When("on the gateway", func() {
		It("should not start a pinger and should set the RemoteEndpoint Status to None", ...)
                 // Call ControllerSupport.CreateLocalHostEndpoint() before creating the remote EP
	})
    })

    When("a remote Endpoint is updated", func() {
        Context("and the HealthCheckIP was changed", func() {
            It("should stop the pinger and start a new one", ...)
        })

        Context("and the HealthCheckIP did not change", func() {
            It("should not start a new pinger", ...)
        })
    })

    When("a remote Endpoint is deleted", func() {
        It("should stop the pinger", ...)
})

@aswinsuryan aswinsuryan force-pushed the route-agent-health-checker-ut branch 2 times, most recently from ef8bf81 to 6964392 Compare September 6, 2024 21:07
@aswinsuryan
Copy link
Contributor Author

I think we should structure the test specs as follows:

var _ = Describe("RouteAgent syncing", func() {
    It("should create a RouteAgent resource", func() {
         // await the RouteAgent - no RemoteEndpoint info expected
    })

    When("a remote Endpoint is created", func() {
        It("should add its RemoteEndpoint information to the RouteAgent resource", func() {
            // await the RemoteEndpoint and verify the Spec
        })
    })

    When("a remote Endpoint is updated", func() {
        It("should update its RemoteEndpoint information in the RouteAgent resource", ...)

    When("a remote Endpoint is deleted", func() {
        It("should remove its RemoteEndpoint information from the RouteAgent resource", ...)
})

var _ = Describe("RemoteEndpoint latency info", func() {
    When("a remote Endpoint is created", func() {
        It("should start a pinger and correctly update the RemoteEndpoint Status and LatencyInfo", func() {
            // await the RemoteEndpoint and verify the LatencyInfo and Status
        })

        Context("with no HealthCheckIP", func() {
		It("should not start a pinger and should set the RemoteEndpoint Status to None", ...)
	})

        Context("with health check not enabled", func() {
		It("should not start a pinger and should set the RemoteEndpoint Status to None", ...)
	})

        When("on the gateway", func() {
		It("should not start a pinger and should set the RemoteEndpoint Status to None", ...)
                 // Call ControllerSupport.CreateLocalHostEndpoint() before creating the remote EP
	})
    })

    When("a remote Endpoint is updated", func() {
        Context("and the HealthCheckIP was changed", func() {
            It("should stop the pinger and start a new one", ...)
        })

        Context("and the HealthCheckIP did not change", func() {
            It("should not start a new pinger", ...)
        })
    })

    When("a remote Endpoint is deleted", func() {
        It("should stop the pinger", ...)
})

Thanks for the suggestion . I updated the structure .

@aswinsuryan aswinsuryan force-pushed the route-agent-health-checker-ut branch 4 times, most recently from 1088968 to 72edf1a Compare September 6, 2024 22:19
@aswinsuryan aswinsuryan force-pushed the route-agent-health-checker-ut branch 4 times, most recently from 5bdc520 to 1f06c7b Compare September 10, 2024 20:50
@aswinsuryan
Copy link
Contributor Author

@tpantelis there is a race condition being reported in the set state method, where do you think we need to fix it ? some of the test infra ? Or do you think it is the code itself?

WARNING: DATA RACE
Read at 0x00c0000e3860 by goroutine 21:
github.com/submariner-io/submariner/pkg/event.(*HandlerBase).State()
/go/src/github.com/submariner-io/submariner/pkg/event/handler.go:116 +0x30c
github.com/submariner-io/submariner/pkg/routeagent_driver/handlers/healthchecker.(*controller).syncRouteAgentStatus()

@tpantelis
Copy link
Contributor

@tpantelis there is a race condition being reported in the set state method, where do you think we need to fix it ? some of the test infra ? Or do you think it is the code itself?

I pushed 8a30449 to address it.

@tpantelis
Copy link
Contributor

I had additional minor adjustments that I just pushed in another commit rather then adding comments (thought it would be easier).

aswinsuryan and others added 3 commits September 11, 2024 14:53
Signed-off-by: Aswin Suryanarayanan <asuryana@redhat.com>
...to avoid a race condition if State is called before SetState.

Signed-off-by: Tom Pantelis <tompantelis@gmail.com>
- Refactor code to await the RouteAgent resource to funntions
  to avoid duplication

- Add spec to test pinger connection error

- Other minor changes

Signed-off-by: Tom Pantelis <tompantelis@gmail.com>
@submariner-bot submariner-bot added the ready-to-test When a PR is ready for full E2E testing label Sep 12, 2024
@tpantelis tpantelis enabled auto-merge (rebase) September 12, 2024 13:47
@tpantelis tpantelis merged commit 2a5f109 into submariner-io:devel Sep 12, 2024
41 checks passed
@submariner-bot
Copy link
Contributor

🤖 Closed branches: [z_pr3152/aswinsuryan/route-agent-health-checker-ut]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ready-to-test When a PR is ready for full E2E testing
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants