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

Add internal/runner test #505

Merged
merged 5 commits into from
Jun 29, 2020
Merged

Add internal/runner test #505

merged 5 commits into from
Jun 29, 2020

Conversation

hlts2
Copy link
Collaborator

@hlts2 hlts2 commented Jun 23, 2020

Signed-off-by: hlts2 hiroto.funakoshi.hiroto@gmail.com

Description:

I added test code for internal/runner pacakge.

Related Issue:

How Has This Been Tested?:

Environment:

  • Go Version: 1.14.3
  • Docker Version: 19.03.8
  • Kubernetes Version: 1.18.2
  • NGT Version: 1.11.5

Types of changes:

  • Bug fix [type/bug]
  • New feature [type/feature]
  • Add tests [type/test]
  • Security related changes [type/security]
  • Add documents [type/documentation]
  • Refactoring [type/refactoring]
  • Update dependencies [type/dependency]
  • Update benchmarks and performances [type/bench]
  • Update CI [type/ci]

Changes to Core Features:

  • Have you added an explanation of what your changes do and why you'd like us to include them?
  • Have you written new tests for your core changes, as applicable?
  • Have you successfully ran tests with your changes locally?

Checklist:

  • I have read the CONTRIBUTING document.
  • I have checked open Pull Requests for the similar feature or fixes?
  • I have added tests and benchmarks to cover my changes.
  • I have ensured all new and existing tests passed.
  • I have commented my code, particularly in hard-to-understand areas
  • I have updated the documentation accordingly.

@pull-assistant
Copy link

pull-assistant bot commented Jun 23, 2020

Score: 0.96

Best reviewed: commit by commit


Optimal code review plan (1 warning)

     feat: runner pacakge test

feat: logging error message

internal/runner/runner_test.go 79% changes removed in fix: flaky test

     fix: apply suggestion

     fix: flaky test

     🤖 Update license headers / Format go codes and yaml files

Powered by Pull Assistant. Last update 64ee619 ... 1e25e4a. Read the comment docs.

@codecov
Copy link

codecov bot commented Jun 23, 2020

Codecov Report

Merging #505 into master will increase coverage by 0.54%.
The diff coverage is 80.00%.

Impacted file tree graph

@@            Coverage Diff            @@
##           master    #505      +/-   ##
=========================================
+ Coverage    8.31%   8.86%   +0.54%     
=========================================
  Files         402     402              
  Lines       20836   20831       -5     
=========================================
+ Hits         1733    1847     +114     
+ Misses      18853   18731     -122     
- Partials      250     253       +3     
Impacted Files Coverage Δ
internal/runner/runner.go 90.38% <80.00%> (+90.38%) ⬆️
internal/runner/option.go 100.00% <0.00%> (+100.00%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 85aa279...1e25e4a. Read the comment docs.

@hlts2
Copy link
Collaborator Author

hlts2 commented Jun 23, 2020

/rebase

@vdaas-ci
Copy link
Collaborator

[REBASE] Rebase triggered by hlts2 for branch: test/internal/runner

@kevindiu
Copy link
Contributor

seems the test failed..

% go test -cover
2020-06-24 10:06:59	[INFO]:
build cpu info flags -> []
build time           -> Wed, 24 Jun 2020 10:06:59 JST
cgo enabled          ->
git commit           -> master
go arch              -> amd64
go os                -> darwin
go version           -> go1.14.4
ngt version          ->
server name          ->
stack trace-0        -> https://github.com/vdaas/vald/tree/master                               	github.com/vdaas/vald/internal/runner.Do
stack trace-1        -> https://github.com/vdaas/vald/tree/master                               	github.com/vdaas/vald/internal/runner.TestDo.func15
stack trace-2        -> https://github.com/golang/go/blob/go1.14.4/src/testing/testing.go#L991  	testing.tRunner
stack trace-3        -> https://github.com/golang/go/blob/go1.14.4/src/runtime/asm_amd64.s#L1373	runtime.goexit
vald version         -> v0.0.1
flag provided but not defined: -team
Usage of test:
  -c string
    	 config file path (default "/etc/server/config.yaml")
  -config string
    	 config file path (default "/etc/server/config.yaml")
  -f string
    	 config file path (default "/etc/server/config.yaml")
  -file string
    	 config file path (default "/etc/server/config.yaml")
  -v	show server version
  -ver
    	show server version
  -version
    	show server version
2020-06-24 10:06:59	[INFO]:	maxprocs: Leaving GOMAXPROCS=4: CPU quota undefined
2020-06-24 10:06:59	[INFO]:	maxprocs: Leaving GOMAXPROCS=4: CPU quota undefined
2020-06-24 10:06:59	[INFO]:	service  v1.1.2 starting...
2020-06-24 01:07:01	[WARN]:	interrupt signal received daemon will stopping soon...
2020-06-24 01:07:01	[WARN]:	daemon stopped
2020-06-24 01:07:01	[WARN]:	daemon stopped
2020-06-24 01:07:03	[ERR]:	error occured in runner.PreStop at vald: err1
2020-06-24 01:07:03	[ERR]:	error occured in runner.Stop at vald: err2
2020-06-24 01:07:03	[ERR]:	error occured in runner.PostStop at vald: err3
2020-06-24 01:07:03	[WARN]:	daemon stopped
2020-06-24 01:07:03	[ERR]:	error occured in runner.Start at vald: err1
2020-06-24 01:07:03	[ERR]:	error occured in runner.Start at vald: err2
2020-06-24 01:07:03	[ERR]:	error occured in runner.Start at vald: err1
2020-06-24 01:07:05	[WARN]:	daemon stopped
--- FAIL: TestRun (4.01s)
    --- FAIL: TestRun/returns_error_when_channel_of_run.StartFunc_contains_error (2.00s)
        runner_test.go:473: error = got error = failed to stop daemon: error:	err2	count:	1: error:	err1	count:	2, want failed to stop daemon: error:	err1	count:	2: error:	err2	count:	1
FAIL
coverage: 93.4% of statements
exit status 1
FAIL	github.com/vdaas/vald/internal/runner	6.444s

@kevindiu
Copy link
Contributor

For the Run test case, I think we can remove the time.Sleep() by moving the afterFunc().
What do you think?

if test.beforeFunc != nil {
				test.beforeFunc(test.args)
			}

/* remove this
			if test.afterFunc != nil {
				defer test.afterFunc(test.args)
			}
*/ 
			if test.checkFunc == nil {
				test.checkFunc = defaultCheckFunc
			}
			err := Run(test.args.ctx, test.args.run, test.args.name)

                         // here
			if test.afterFunc != nil {
 				test.afterFunc(test.args)
			}

			if err := test.checkFunc(test.want, err); err != nil {
				tt.Errorf("error = %v", err)
			}

kevindiu
kevindiu previously approved these changes Jun 24, 2020
Copy link
Contributor

@kevindiu kevindiu left a comment

Choose a reason for hiding this comment

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

LGTM

@hlts2 hlts2 requested a review from vankichi June 24, 2020 06:59
@kevindiu
Copy link
Contributor

/rebase

@vdaas-ci
Copy link
Collaborator

[REBASE] Rebase triggered by kevindiu for branch: test/internal/runner

@hlts2
Copy link
Collaborator Author

hlts2 commented Jun 25, 2020

/rebase

@vdaas-ci
Copy link
Collaborator

[REBASE] Rebase triggered by hlts2 for branch: test/internal/runner

kevindiu
kevindiu previously approved these changes Jun 25, 2020
@hlts2
Copy link
Collaborator Author

hlts2 commented Jun 29, 2020

/rebase

@vdaas-ci
Copy link
Collaborator

[REBASE] Rebase triggered by hlts2 for branch: test/internal/runner

kevindiu
kevindiu previously approved these changes Jun 29, 2020
vankichi
vankichi previously approved these changes Jun 29, 2020
Copy link
Contributor

@vankichi vankichi left a comment

Choose a reason for hiding this comment

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

LGTM

@vankichi
Copy link
Contributor

/rebase
/format
/approve

@vdaas-ci
Copy link
Collaborator

[REBASE] Rebase triggered by vankichi for branch: test/internal/runner

@vdaas-ci
Copy link
Collaborator

[FORMAT] Updating license headers and formatting go codes triggered by vankichi.

@vdaas-ci vdaas-ci dismissed stale reviews from vankichi and kevindiu via eccde19 June 29, 2020 03:10
vdaas-ci
vdaas-ci previously approved these changes Jun 29, 2020
Copy link
Collaborator

@vdaas-ci vdaas-ci left a comment

Choose a reason for hiding this comment

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

[APPROVED] This PR is approved by vankichi.

@vankichi
Copy link
Contributor

/rebase
/approve

@vdaas-ci
Copy link
Collaborator

[REBASE] Rebase triggered by vankichi for branch: test/internal/runner

hlts2 and others added 5 commits June 29, 2020 03:21
Signed-off-by: hlts2 <hiroto.funakoshi.hiroto@gmail.com>
Signed-off-by: hlts2 <hiroto.funakoshi.hiroto@gmail.com>
Signed-off-by: hlts2 <hiroto.funakoshi.hiroto@gmail.com>
Signed-off-by: hlts2 <hiroto.funakoshi.hiroto@gmail.com>
Copy link
Collaborator

@vdaas-ci vdaas-ci left a comment

Choose a reason for hiding this comment

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

[APPROVED] This PR is approved by vankichi.

@vankichi vankichi merged commit 9e1f1e8 into master Jun 29, 2020
@vankichi vankichi deleted the test/internal/runner branch June 29, 2020 03:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants