-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Unit Test For Defunct Processes Metric #5161
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
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,26 @@ | ||
| package process_test | ||
|
|
||
| import ( | ||
| "testing" | ||
|
|
||
| . "github.com/cri-o/cri-o/test/framework" | ||
| . "github.com/onsi/ginkgo" | ||
| . "github.com/onsi/gomega" | ||
| ) | ||
|
|
||
| // TestProcess runs the created specs | ||
| func TestProcess(t *testing.T) { | ||
| RegisterFailHandler(Fail) | ||
| RunFrameworkSpecs(t, "Process") | ||
| } | ||
|
|
||
| var t *TestFramework | ||
|
|
||
| var _ = BeforeSuite(func() { | ||
| t = NewTestFramework(NilFunc, NilFunc) | ||
| t.Setup() | ||
| }) | ||
|
|
||
| var _ = AfterSuite(func() { | ||
| t.Teardown() | ||
| }) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,58 @@ | ||
| package process_test | ||
|
|
||
| import ( | ||
| "fmt" | ||
|
|
||
| . "github.com/onsi/ginkgo" | ||
| . "github.com/onsi/gomega" | ||
|
|
||
| "github.com/cri-o/cri-o/internal/process" | ||
| ) | ||
|
|
||
| // The actual test suite | ||
| var _ = t.Describe("Process", func() { | ||
| t.Describe("DefunctProcessesForPath", func() { | ||
| Context("Should succeed", func() { | ||
| It("when given a valid path name and there are defunct processes", func() { | ||
| defunctCount, err := process.DefunctProcessesForPath("./testing/proc_success_1") | ||
|
|
||
| Expect(err).To(BeNil()) | ||
| Expect(defunctCount).To(Equal(uint(7))) | ||
| }) | ||
| It("when given a valid path name but there are no defunct processes", func() { | ||
| defunctCount, err := process.DefunctProcessesForPath("./testing/proc_success_2") | ||
|
|
||
| Expect(err).To(BeNil()) | ||
| Expect(defunctCount).To(Equal(uint(0))) | ||
| }) | ||
| It("when given a valid path name but there are no processes", func() { | ||
| defunctCount, err := process.DefunctProcessesForPath("./testing/proc_success_3") | ||
|
|
||
| Expect(err).To(BeNil()) | ||
| Expect(defunctCount).To(Equal(uint(0))) | ||
| }) | ||
| It("when given a valid path name but there are no directories", func() { | ||
| defunctCount, err := process.DefunctProcessesForPath("./testing/proc_success_4") | ||
|
|
||
| Expect(err).To(BeNil()) | ||
| Expect(defunctCount).To(Equal(uint(0))) | ||
| }) | ||
| }) | ||
| Context("Should fail", func() { | ||
| It("when given an invalid path name", func() { | ||
| defunctCount, err := process.DefunctProcessesForPath("./test/proc") | ||
| formattedErr := fmt.Sprintf("%v", err) | ||
|
|
||
| Expect(formattedErr).To(Equal("open ./test/proc: no such file or directory")) | ||
| Expect(defunctCount).To(Equal(uint(0))) | ||
| }) | ||
| It("when the given path name does not belong to a directory", func() { | ||
| defunctCount, err := process.DefunctProcessesForPath("./testing/proc_fail") | ||
| formattedErr := fmt.Sprintf("%v", err) | ||
|
|
||
| Expect(formattedErr).To(Equal("readdirent ./testing/proc_fail: not a directory")) | ||
| Expect(defunctCount).To(Equal(uint(0))) | ||
| }) | ||
| }) | ||
| }) | ||
| }) |
Empty file.
Empty file.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| 1 (systemd) S 0 1 1 0 -1 4194560 26808 283533 44 586 41 78 514 255 20 0 1 0 36 180686848 4263 18446744073709551615 1 1 0 0 0 0 671173123 4096 1260 0 0 0 17 0 0 0 12 0 0 0 0 0 0 0 0 0 0 |
Empty file.
Empty file.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| 10 (hello world) Z 2 0 0 0 -1 2129984 0 0 0 0 0 0 0 0 20 0 1 0 36 0 0 18446744073709551615 0 0 0 0 0 0 0 2147483647 0 0 0 0 17 0 0 0 0 0 0 0 0 0 0 0 0 0 0 |
Empty file.
Empty file.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| 102 (kworker/u16:1-events_unbound) I 2 0 0 0 -1 69238880 0 4350 0 0 0 170 0 1 20 0 1 0 65 0 0 18446744073709551615 0 0 0 0 0 0 0 2147483647 0 0 0 0 17 6 0 0 38 0 0 0 0 0 0 0 0 0 0 |
Empty file.
Empty file.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| 1037 ( 2 gdm 5 ) Z 1 1037 1037 0 -1 4194560 1093 2034 2 2 2 2 1 1 20 0 3 0 1139 480079872 2246 18446744073709551615 1 1 0 0 0 0 512 4096 81923 0 0 0 17 4 0 0 0 0 0 0 0 0 0 0 0 0 0 |
Empty file.
Empty file.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| 2096 (gsd-disk-utilit) Z 1725 1725 1725 0 -1 4194304 624 91 0 0 0 0 0 0 20 0 3 0 3902 238149632 1479 18446744073709551615 94315514339328 94315514343973 140734996731264 0 0 0 0 4096 0 0 0 0 17 0 0 0 0 0 0 94315514354600 94315514355716 94315541213184 140734996732406 140734996732443 140734996732443 140734996733907 0 |
Empty file.
Empty file.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| 215 (hello world 2) Z 2 0 0 0 -1 69238880 0 0 0 0 0 0 0 0 0 -20 1 0 133 0 0 18446744073709551615 0 0 0 0 0 0 0 2147483647 0 0 0 0 17 6 0 0 0 0 0 0 0 0 0 0 0 0 0 |
Empty file.
Empty file.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| 3 (rcu_gp) I 2 0 0 0 -1 69238880 0 0 0 0 0 0 0 0 0 -20 1 0 36 0 0 18446744073709551615 0 0 0 0 0 0 0 2147483647 0 0 0 0 17 0 0 0 0 0 0 0 0 0 0 0 0 0 0 |
Empty file.
Empty file.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| 4010 (chrome) Z 2628 1759 1759 0 -1 1077936192 4246 0 0 0 23 7 0 0 20 0 13 0 96262 22110556160 22471 18446744073709551615 93992801384832 93992937871968 140735240563200 0 0 0 0 4098 1098993405 0 0 0 17 5 0 0 0 0 0 93992945617536 93992946127616 93992964468736 140735240566968 140735240567080 140735240567080 140735240568798 0 |
Empty file.
Empty file.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| 423 ((address) (program)) Z 1631 1759 1759 0 -1 4194560 103744 10166 13 3 12356 4231 136 4 20 0 28 0 3796 5462523904 57718 18446744073709551615 1 1 0 0 0 0 0 16781312 83192 0 0 0 17 1 0 0 7 0 0 0 0 0 0 0 0 0 0 |
Empty file.
Empty file.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| 809 ((chronyd)) Z 1 808 808 0 -1 4194624 219 0 2 0 1 4 0 0 20 0 1 0 402 97402880 1023 18446744073709551615 1 1 0 0 0 0 0 4096 16391 0 0 0 17 0 0 0 0 0 0 0 0 0 0 0 0 0 0 |
Empty file.
Empty file.
Empty file.
Empty file.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| 1 (systemd) S 0 1 1 0 -1 4194560 26808 283533 44 586 41 78 514 255 20 0 1 0 36 180686848 4263 18446744073709551615 1 1 0 0 0 0 671173123 4096 1260 0 0 0 17 0 0 0 12 0 0 0 0 0 0 0 0 0 0 |
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
G304: Potential file inclusion via variable
(at-me in a reply with
helporignore)