Commit Graph

15 Commits

Author SHA1 Message Date
Patrick Ohly
fe59e091eb dependencies: ginkgo v2.9.1, gomega v1.27.4
They contain some nice-to-have improvements (for example, better printing of
errors with gomega/format.Object) but nothing that is critical right now.

"go mod tidy" was run manually in
staging/src/k8s.io/kms/internal/plugins/mock (https://github.com/kubernetes/kubernetes/pull/116613
not merged yet).
2023-03-14 22:26:27 +01:00
Patrick Ohly
766e7e07da e2e framework: verify JUnit result, not the in-memory structs
The old tests were no longer passing with Ginkgo v2.5.0. Instead of keeping the
old approach of checking recorded spec results, now the tests actually cover
what we care about most: the results recorded in JUnit.

This also gets rid of having to repeat the stack backtrace twice (once as part
of the output, once for the separate backtrace field).
2022-12-21 07:55:07 +01:00
Patrick Ohly
16f05373f4 e2e framework internal: normalize anonymous functions with parameters
This will become relevant for

   ginkgo.BeforeEach(func(ctx context.Context) { ... })
2022-12-10 21:47:17 +01:00
Patrick Ohly
2a7f9723ec e2e framework: fix incorrect backtrace in Failf
Commit 99e9096034 was only supposed to remove the
FailfWithOffset function, but it also changed the behavior by skipping one
additional stack frame. That makes no sense and is inconsistent with Fail, which
also logs the direct caller.
2022-10-27 12:24:00 +02:00
Patrick Ohly
96e9a93a6b e2e: disable double printing of errors
We don't want klog to print to anything other than GinkgoWriter, but it still
used os.Stderr in addition to GinkgoWriter when printing log entries with
severity >= error. Changing "stderrthreshold" fixes that.

The unit test for framework output handling didn't test klog behavior. Now it
does:
- os.Stderr is redirected, should be empty
- a new test invokes klog
2022-08-22 17:04:26 +02:00
Dave Chen
f792256954 e2e: adapt output tests to Ginkgo v2 and Gomega 1.19
Full stack traces are on by default. The approach for collecting results is
different. Tests run in their own goroutine, therefore runTests is no longer
part of their callstack. To cover stack traces with more than one entry, a new
test case gets added with a separate helper function.

Gomega object formatting now includes the type.

This removes the last remaining reference to Ginkgo v1.

Co-authored-by: Patrick Ohly <patrick.ohly@intel.com>
Signed-off-by: Dave Chen <dave.chen@arm.com>
2022-07-08 10:46:11 +08:00
Dave Chen
857458cfa5 update ginkgo from v1 to v2 and gomega to 1.19.0
- update all the import statements
- run hack/pin-dependency.sh to change pinned dependency versions
- run hack/update-vendor.sh to update go.mod files and the vendor directory
- update the method signatures for custom reporters

Signed-off-by: Dave Chen <dave.chen@arm.com>
2022-07-08 10:44:46 +08:00
Patrick Ohly
8e79f4ce27 e2e: make failure message for unexpected errors more readable
The failure message from Gomega was hard to read because explanation and error
text were separated by the error dump. In many cases, that error dump doesn't
add any relevant information.

Now the error is dumped first as info message (just in case that it is
relevant) and then a shorter failure message is created from explanation and
error text.
2022-06-03 13:41:02 +02:00
Patrick Ohly
0e0e51d792 e2e: refactor Ginkgo output testing
The helper code will be useful for testing other parts of the e2e framework.
2022-06-03 10:25:23 +02:00
Patrick Ohly
2ad1fc5f8f e2e: include expected line number in output test
This makes it easier to see when comment lines must be added or removed.
2022-06-03 10:04:40 +02:00
Patrick Ohly
38348532a3 e2e: reformat log test
Using multi-line strings makes the test source code easier to read.
2022-05-11 11:29:56 +02:00
Patrick Ohly
228640ffab e2e: fix logs unit test
The test had two problems:
- the expected line was off by one (probably modified import statements)
- when Gomega failed in TestFailureOutput, Ginkgo panicked because
  its fail handler was called outside of a Ginkgo node

Now github.com/stretchr/testify/assert is used for comparing the output because
it works in a unit test without further customization and because the failure
messages are more useful.
2022-05-11 10:50:51 +02:00
Kenichi Omichi
99e9096034 Remove unused FailfWithOffset()
The function has been unused from outside of e2e framework at all
since 30b3472f89 which added the function.
This removes it for code cleanup.
2020-10-01 21:04:12 +00:00
clarklee92
7ce12844d2 Use framework.ExpectEqual() in unit test
Signed-off-by: clarklee92 <clarklee1992@hotmail.com>
2019-11-07 10:31:31 +08:00
Patrick Ohly
4620d0b2b8 e2e log: move back to framework, part II
This continues the work in
https://github.com/kubernetes/kubernetes/pull/81426 by also moving the
logger_test.go, moving the log helper code from util.go to log.go (a
more logical place, as it is only used there) and updating comments.
2019-10-01 21:30:12 +02:00