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

Verify logs in Splunk local in e2e tests #74

Open
ningziwen opened this issue Sep 21, 2023 · 0 comments
Open

Verify logs in Splunk local in e2e tests #74

ningziwen opened this issue Sep 21, 2023 · 0 comments

Comments

@ningziwen
Copy link
Member

Draft code which can get a long xml but without the log sent by e2e tests. Need to investigate how to search the results. Opened the issue in splunk repo: splunk/docker-splunk#625

func validateTestLogsInSplunk(url string, token string, testLog string) {
	// Use REST API to retrieve the logs. https://docs.splunk.com/Documentation/Splunk/9.1.1/RESTREF/RESTsearch#search.2Fjobs
	tr := &http.Transport{
		TLSClientConfig: &tls.Config{InsecureSkipVerify: true},
	}
	client := &http.Client{Transport: tr}
	searchQuery := "search *" // Get the latest of all the log events.
	req, err := http.NewRequest("POST", fmt.Sprintf("%s/services/search/jobs", url), bytes.NewBufferString(searchQuery))
	gomega.Expect(err).ShouldNot(gomega.HaveOccurred())
	req.Header.Set("Content-Type", "application/x-www-form-urlencoded")
	req.Header.Set("Authorization", fmt.Sprintf("Splunk %s", token)) // https://docs.splunk.com/Documentation/Splunk/9.1.1/Security/UseAuthTokens
	resp, err := client.Do(req)
	gomega.Expect(err).ShouldNot(gomega.HaveOccurred())
	defer resp.Body.Close()
	body, err := io.ReadAll(resp.Body)
	gomega.Expect(err).ShouldNot(gomega.HaveOccurred())
	fmt.Println(string(body))
}
ningziwen added a commit that referenced this issue Sep 21, 2023
*Description of changes:*

The test is not perfect but can be used for basic validation because the
containerd task is ran successfully with the Splunk shim logger. It is
nice to validate the logs in Splunk after it. It is not straightforward
to do that so opened issue to track it.
#74

By submitting this pull request, I confirm that you can use, modify,
copy, and redistribute this contribution, under the terms of your
choice.

Signed-off-by: Ziwen Ning <[email protected]>
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

No branches or pull requests

1 participant