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

feat: SSAPI Unit Tests (BPS-272) #1982

Merged
merged 8 commits into from
Nov 26, 2024
Merged

Conversation

Caleb-Hurshman
Copy link

@Caleb-Hurshman Caleb-Hurshman commented Nov 20, 2024

Proposed Change

Add more unit tests for the Splunk Search API Receiver.

Checklist
  • Changes are tested
  • CI has passed

@Caleb-Hurshman Caleb-Hurshman requested review from dpaasman00 and a team as code owners November 20, 2024 19:57
@Caleb-Hurshman Caleb-Hurshman requested review from schmikei and removed request for a team and dpaasman00 November 20, 2024 19:57
@Caleb-Hurshman Caleb-Hurshman changed the title feat: SSAPI Unit Tests feat: SSAPI Unit Tests (BPS-272) Nov 20, 2024
require.False(t, done)
}

func TestInitCheckpoint(t *testing.T) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are these supposed to be implemented?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Somehow those changes didn't get added in my last commit. Should be good now.

Type string `xml:"type,attr"`
Dict Dict `xml:"dict"`
} `xml:"content"`
type SearchStatusResponse struct {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
type SearchStatusResponse struct {
type SearchJobStatusResponse struct {

nit: I think this is more indicative of a name. not required just something I think makes it more readable

}

// Content struct to represent <content> elements
type Content struct {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
type Content struct {
type SearchJobContent struct {

Along similar veins

</s:key>
</s:dict>
</content>
</entry>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
</entry>
</entry>

nit

@@ -11,6 +11,7 @@ require (
go.opentelemetry.io/collector/extension/experimental/storage v0.113.0
go.opentelemetry.io/collector/pdata v1.19.0
go.opentelemetry.io/collector/receiver v0.113.0
go.opentelemetry.io/collector/receiver/receivertest v0.113.0
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did this not rmake any go.sum changes? I'd imagine it would. Would you mind re-running go mod tidy to just double check?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Apparently not 🤷‍♂️

)

var (
server = newMockServer()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit I think I'd like to see these defined within the test functions themselves so other test files can use the names server and testClient without worrying about variable shadowing.

<s:key name="cursorTime">1969-12-31T16:00:00.000-08:00</s:key>
<s:key name="delegate"></s:key>
<s:key name="diskUsage">2174976</s:key>
<s:key name="dispatchState">DONE</s:key>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think having a dispatchState as not done will be another important test for any future changes.

@@ -60,6 +61,10 @@ func newSplunkSearchAPIClient(ctx context.Context, settings component.TelemetryS
func (c defaultSplunkSearchAPIClient) CreateSearchJob(search string) (CreateJobResponse, error) {
endpoint := fmt.Sprintf("%s/services/search/jobs", c.endpoint)

if !strings.Contains(search, "starttime=") || !strings.Contains(search, "endtime=") || !strings.Contains(search, "timeformat=") {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Might be overkill but in splunk, are these case-insensitive? I.e. I believe you can do Starttime="<whatever> and its still valid

For the sake of correctness I'm curious if we need to make these error checks non case-sensitive?

I know that we're inputting these parameters so its not too big of a deal, so maybe a comment would suffice in this situation

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch, I didn't know that about Splunk.

@Caleb-Hurshman Caleb-Hurshman merged commit 44f73b2 into feat/ssapi-receiver Nov 26, 2024
14 checks passed
@Caleb-Hurshman Caleb-Hurshman deleted the feat/ssapi-tests branch November 26, 2024 14:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants