Skip to content

Add smart diff to testutil.GatherAndCompare family of utilities. #996

@bwplotka

Description

@bwplotka

Currently, it's much better to just use require.Equal from testify to compare outputs of scrape, since it gives nice diff:

0304 12:33:58.224133 4120671 server.go:406] "Adding debug handlers to kubelet server"
    server_test.go:1449: 
        	Error Trace:	server_test.go:1449
        	Error:      	Not equal: 
        	            	...
        	            	
        	            	Diff:
        	            	--- Expected
        	            	+++ Actual
        	            	@@ -3648,3 +3648,3 @@
        	            	 container_processes{container="",id="/user.slice/user-1000.slice/[email protected]/session.slice/pulseaudio.service",image="",name="",namespace="",pod=""} 0 1645535816846
        	            	-# HELP container_scrape_error 1 if there was an error while getting container metrics, 0 otherwise.
        	            	+# HELP container_scrape_error 1 if there was an error while getting container metrics, 0 otherwise
        	            	 # TYPE container_scrape_error gauge
        	            	@@ -3939,3 +3939,3 @@
        	            	 container_spec_cpu_period{container="",id="/user.slice/user-1000.slice/[email protected]/session.slice/pulseaudio.service",image="",name="",namespace="",pod=""} 0
        	            	-# HELP container_spec_cpu_shares CPU share (limit) of the container.
        	            	+# HELP container_spec_cpu_shares CPU share of the container.
        	            	 # TYPE container_spec_cpu_shares gauge
        	Test:       	TestCadvisorMetrics

If I do this with our compare, it is huge unreadable blob without diff ): Just got, want. Let's improve experience here!

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions