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

reconciler: Add test case for the example #31

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

joamaki
Copy link
Contributor

@joamaki joamaki commented May 31, 2024

Add a simple test-case for the reconciler example to make sure it doesn't accidentally break in the future.

Add a simple test-case for the reconciler example to
make sure it doesn't accidentally break in the future.

Signed-off-by: Jussi Maki <[email protected]>
@joamaki joamaki requested a review from bimmlerd May 31, 2024 10:10
Copy link

$ make test
go: downloading github.com/fsnotify/fsnotify v1.7.0
go: downloading github.com/sagikazarmark/slog-shim v0.1.0
go: downloading github.com/spf13/afero v1.11.0
go: downloading github.com/spf13/cast v1.6.0
go: downloading golang.org/x/sys v0.17.0
go: downloading github.com/subosito/gotenv v1.6.0
go: downloading github.com/hashicorp/hcl v1.0.0
go: downloading gopkg.in/ini.v1 v1.67.0
go: downloading github.com/magiconair/properties v1.8.7
go: downloading github.com/pelletier/go-toml/v2 v2.1.0
go: downloading golang.org/x/text v0.14.0
	github.com/cilium/statedb/reconciler/benchmark		coverage: 0.0% of statements
	github.com/cilium/statedb/reconciler/example		coverage: 0.0% of statements
ok  	github.com/cilium/statedb	5.182s	coverage: 88.0% of statements
ok  	github.com/cilium/statedb/index	0.005s	coverage: 25.5% of statements
ok  	github.com/cilium/statedb/internal	0.015s	coverage: 93.3% of statements
ok  	github.com/cilium/statedb/part	1.842s	coverage: 81.9% of statements
ok  	github.com/cilium/statedb/reconciler	4.939s	coverage: 90.5% of statements
./reconciler/example/test.sh
PASS
-----
$ make bench
go test ./... -bench . -benchmem -test.run xxx
goos: linux
goarch: amd64
pkg: github.com/cilium/statedb
cpu: AMD EPYC 7763 64-Core Processor                
BenchmarkDB_WriteTxn_1-4                    	  487390	      2501 ns/op	    399828 objects/sec	    2688 B/op	      32 allocs/op
BenchmarkDB_WriteTxn_10-4                   	 1258680	       947.0 ns/op	   1056014 objects/sec	     712 B/op	      10 allocs/op
BenchmarkDB_WriteTxn_100-4                  	 1585005	       800.8 ns/op	   1248752 objects/sec	     583 B/op	       7 allocs/op
BenchmarkDB_WriteTxn_1000-4                 	 1523626	       789.2 ns/op	   1267164 objects/sec	     534 B/op	       7 allocs/op
BenchmarkDB_WriteTxn_10000-4                	 1275295	       951.0 ns/op	   1051477 objects/sec	     551 B/op	       7 allocs/op
BenchmarkDB_WriteTxn_100_SecondaryIndex-4   	  506152	      2254 ns/op	    443623 objects/sec	    1670 B/op	      30 allocs/op
BenchmarkDB_RandomInsert-4                  	    2528	    475631 ns/op	   2102470 objects/sec	  385887 B/op	    7097 allocs/op
BenchmarkDB_RandomReplace-4                 	     430	   2786460 ns/op	    358878 objects/sec	 1851317 B/op	   30566 allocs/op
BenchmarkDB_SequentialInsert-4              	    1556	    785037 ns/op	   1273825 objects/sec	  533520 B/op	    7288 allocs/op
BenchmarkDB_Changes_Baseline-4              	    1280	    925417 ns/op	   1080595 objects/sec	  536193 B/op	   10246 allocs/op
BenchmarkDB_Changes-4                       	     717	   1669299 ns/op	    599054 objects/sec	  963652 B/op	   14540 allocs/op
BenchmarkDB_RandomLookup-4                  	   21160	     55722 ns/op	  17946318 objects/sec	     144 B/op	       1 allocs/op
BenchmarkDB_SequentialLookup-4              	   25728	     46859 ns/op	  21340678 objects/sec	       0 B/op	       0 allocs/op
BenchmarkDB_FullIteration_All-4             	     909	   1404075 ns/op	  71221390 objects/sec	     360 B/op	       7 allocs/op
BenchmarkDB_FullIteration_Get-4             	     212	   5721375 ns/op	  17478350 objects/sec	       0 B/op	       0 allocs/op
BenchmarkDB_PropagationDelay-4              	  536588	      2250 ns/op	        19.00 50th_µs	        22.00 90th_µs	        67.00 99th_µs	    1503 B/op	      24 allocs/op
PASS
ok  	github.com/cilium/statedb	26.250s
PASS
ok  	github.com/cilium/statedb/index	0.004s
PASS
ok  	github.com/cilium/statedb/internal	0.003s
goos: linux
goarch: amd64
pkg: github.com/cilium/statedb/part
cpu: AMD EPYC 7763 64-Core Processor                
Benchmark_Insert_RootOnlyWatch-4    	    8678	    132029 ns/op	   7574104 objects/sec	  104128 B/op	    2041 allocs/op
Benchmark_Insert-4                  	    6346	    177144 ns/op	   5645112 objects/sec	  202688 B/op	    3065 allocs/op
Benchmark_Replace-4                 	29407518	        41.14 ns/op	  24308842 objects/sec	       0 B/op	       0 allocs/op
Benchmark_Replace_RootOnlyWatch-4   	29509952	        41.90 ns/op	  23866858 objects/sec	       0 B/op	       0 allocs/op
Benchmark_txn_1-4                   	 2995696	       400.1 ns/op	   2499564 objects/sec	     432 B/op	       7 allocs/op
Benchmark_txn_10-4                  	 7569270	       158.5 ns/op	   6307242 objects/sec	     152 B/op	       2 allocs/op
Benchmark_txn_100-4                 	 7398884	       175.8 ns/op	   5687305 objects/sec	     223 B/op	       2 allocs/op
Benchmark_txn_1000-4                	 7492095	       159.8 ns/op	   6256476 objects/sec	     214 B/op	       2 allocs/op
Benchmark_txn_10000-4               	 5083800	       236.3 ns/op	   4231703 objects/sec	     238 B/op	       2 allocs/op
Benchmark_txn_100000-4              	 3728347	       288.1 ns/op	   3470661 objects/sec	     343 B/op	       2 allocs/op
Benchmark_txn_delete_1-4            	 3256158	       364.6 ns/op	   2742658 objects/sec	     840 B/op	       6 allocs/op
Benchmark_txn_delete_10-4           	 8629612	       137.4 ns/op	   7280597 objects/sec	     131 B/op	       1 allocs/op
Benchmark_txn_delete_100-4          	10323128	       115.2 ns/op	   8679295 objects/sec	      60 B/op	       1 allocs/op
Benchmark_txn_delete_1000-4         	11329483	       105.6 ns/op	   9471741 objects/sec	      26 B/op	       1 allocs/op
Benchmark_txn_delete_10000-4        	 9708306	       122.9 ns/op	   8136810 objects/sec	      25 B/op	       1 allocs/op
Benchmark_txn_delete_100000-4       	 8529201	       136.8 ns/op	   7308189 objects/sec	      26 B/op	       1 allocs/op
Benchmark_Get-4                     	   38156	     31560 ns/op	  31685493 objects/sec	       0 B/op	       0 allocs/op
Benchmark_Iterate-4                 	  165925	      7158 ns/op	 139706219 objects/sec	      80 B/op	       3 allocs/op
Benchmark_Hashmap_Insert-4          	   15685	     76476 ns/op	  13076082 objects/sec	   86554 B/op	      64 allocs/op
Benchmark_Hashmap_Get_Uint64-4      	  148407	      7996 ns/op	 125063357 objects/sec	       0 B/op	       0 allocs/op
Benchmark_Hashmap_Get_Bytes-4       	  147350	      8049 ns/op	 124237353 objects/sec	       0 B/op	       0 allocs/op
Benchmark_Uint64Map_Random-4        	    1332	    913323 ns/op	   1094904 items/sec	 2688528 B/op	    9038 allocs/op
Benchmark_Uint64Map_Sequential-4    	    1374	    869876 ns/op	   1149589 items/sec	 2476392 B/op	    9749 allocs/op
PASS
ok  	github.com/cilium/statedb/part	32.582s
PASS
ok  	github.com/cilium/statedb/reconciler	0.004s
?   	github.com/cilium/statedb/reconciler/benchmark	[no test files]
?   	github.com/cilium/statedb/reconciler/example	[no test files]
go run ./reconciler/benchmark -quiet
1000000 objects reconciled in 2.85 seconds (batch size 1000)
Throughput 351353.23 objects per second
Allocated 6011380 objects, 393431kB bytes, 514744kB bytes still in use

@@ -0,0 +1,57 @@
#!/usr/bin/env bash
SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
Copy link
Member

Choose a reason for hiding this comment

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

hm, not sure I'm super excited about a bash test case that doesn't run on go test ./...

What was the reasoning in not making this a Go test? ease of starting/stopping processes etc?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Just the ease of writing it, but yeah that's a bit short sighted. Let's make this into a go test.

trap 'cleanup' SIGINT SIGTERM EXIT

for i in 1 2 3 4 5; do
curl -q http://localhost:8080/statedb &>/dev/null && break
Copy link
Member

Choose a reason for hiding this comment

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

should this error out if it doesn't manage to come up soon enough?

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