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

Use own FakeClock func instead of from library #1993

Merged
merged 2 commits into from
Apr 14, 2023

Conversation

vinamra28
Copy link
Member

Changes

We were using clockwork.NewFakeClock() from the clockwork library. With recent changes the implementation of this function changed and it now returns the current date instead of an older date.

Creating the function FakeClock() in pkg/test/helpers.go so that we can manually hardcode the date and not 100% rely on the library.

Submitter Checklist

These are the criteria that every PR should meet, please check them off as you
review them:

  • Includes tests (if functionality changed/added)
  • Run the code checkers with make check
  • Regenerate the manpages, docs and go formatting with make generated
  • Commit messages follow commit message best practices

See the contribution guide
for more details.

Release Notes

NONE

@tekton-robot tekton-robot added the release-note-none Denotes a PR that doesnt merit a release note. label Apr 14, 2023
@tekton-robot tekton-robot added size/M Denotes a PR that changes 30-99 lines, ignoring generated files. size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. and removed size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Apr 14, 2023
vinamra28 and others added 2 commits April 14, 2023 10:55
We were using clockwork.NewFakeClock() from the clockwork library. With
recent changes the implementation of this function changed and it now
returns the current date instead of an older date.

Creating the function FakeClock() in `pkg/test/helpers.go` so that we
can manually hardcode the date and not 100% rely on the library.

Signed-off-by: vinamra28 <[email protected]>
Bumps [github.com/jonboulle/clockwork](https://github.com/jonboulle/clockwork) from 0.3.0 to 0.4.0.
- [Release notes](https://github.com/jonboulle/clockwork/releases)
- [Commits](jonboulle/clockwork@v0.3.0...v0.4.0)

---
updated-dependencies:
- dependency-name: github.com/jonboulle/clockwork
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <[email protected]>
@vinamra28 vinamra28 force-pushed the use-self-fake-clock-impl branch from dad8ca5 to f936776 Compare April 14, 2023 05:25
@tekton-robot tekton-robot added size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. and removed size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. labels Apr 14, 2023
@@ -92,3 +94,7 @@ func Contains(t *testing.T, container interface{}, obj interface{}) {
}
t.Errorf("no matches found in: %s", strings.Join(diffs, "\n"))
}

func FakeClock() clockwork.FakeClock {
return clockwork.NewFakeClockAt(time.Date(1984, time.April, 4, 0, 0, 0, 0, time.UTC))
Copy link
Member

Choose a reason for hiding this comment

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

you may updated the previous default value here.

https://github.com/jonboulle/clockwork/pull/55/files#diff-4cc12df1de8f3164eac723ca9251237312941079fd075dca3907d1386a44abf1L49

NewFakeClockAt(time.Date(2006, time.January, 2, 15, 4, 5, 0, time.UTC))

Copy link
Member Author

Choose a reason for hiding this comment

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

well, the previous value that we were using was
https://github.com/jonboulle/clockwork/blob/6a247c35607b17156e639c6e0606887fa6fc304f/clockwork.go#L42

NewFakeClockAt(time.Date(1984, time.April, 4, 0, 0, 0, 0, time.UTC))

Copy link
Contributor

Choose a reason for hiding this comment

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

yes @vinamra28 seems correct otherwise all the tests would ave been failing

Copy link
Member

Choose a reason for hiding this comment

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

Thanks @vinamra28 , I took the wrong reference

@vinamra28
Copy link
Member Author

/test pull-tekton-cli-integration-tests

@jkandasa
Copy link
Member

@vinamra28 do you see any issue with the current default value of github.com/jonboulle/clockwork ?
that is NewFakeClockAt(time.Now())

Is there any test failing because of this change?

@vinamra28
Copy link
Member Author

@vinamra28 do you see any issue with the current default value of github.com/jonboulle/clockwork ? that is NewFakeClockAt(time.Now())

Is there any test failing because of this change?

@jkandasa, yes, test cases were failing as the golden files are getting updated on every run. PR #1970

@piyush-garg
Copy link
Contributor

/approve

@tekton-robot tekton-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Apr 14, 2023
Copy link
Member

@jkandasa jkandasa left a comment

Choose a reason for hiding this comment

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

LGTM

@tekton-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: jkandasa, piyush-garg

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@piyush-garg
Copy link
Contributor

/lgtm

@tekton-robot tekton-robot added the lgtm Indicates that a PR is ready to be merged. label Apr 14, 2023
@vinamra28
Copy link
Member Author

/test pull-tekton-cli-integration-tests

1 similar comment
@vinamra28
Copy link
Member Author

/test pull-tekton-cli-integration-tests

@tekton-robot tekton-robot merged commit 736a24d into tektoncd:main Apr 14, 2023
@vinamra28 vinamra28 deleted the use-self-fake-clock-impl branch April 14, 2023 08:24
vinamra28 added a commit that referenced this pull request May 10, 2023
#1981 | [vinamra28] Bump versions in README to v0.30.1 | 2023/04/11-07:18
#1983 | [pratap0007] Remove PipelineResource support in clustertask | 2023/04/13-07:24
#1985 | [Zoran Regvart] Adapt for changes in TEP-0100 | 2023/04/13-07:58
#1984 | [pratap0007] Remove PipelineResource support in task | 2023/04/13-09:42
#1988 | [pratap0007] Remove PipelineResource support in pipeline | 2023/04/13-14:54
#1987 | [Basavaraju G] remove e2e pipeline resource tests | 2023/04/13-18:48
#1991 | [dependabot[bot]] Bump k8s.io/apimachinery from 0.26.3 to 0.26.4 | 2023/04/14-07:26
#1992 | [dependabot[bot]] Bump k8s.io/client-go from 0.25.8 to 0.25.9 | 2023/04/14-08:08
#1993 | [vinamra28] Use own FakeClock func instead of from library | 2023/04/14-08:44
#1993 | [dependabot[bot]] Bump github.com/jonboulle/clockwork from 0.3.0 to 0.4.0 | 2023/04/14-08:44
null | [pratap0007] Remove resource command | 2023/04/14-09:36
null | [pratap0007] Remove input and output resource in clustertask describe command | 2023/04/14-11:38
null | [dependabot[bot]] Bump k8s.io/cli-runtime from 0.25.8 to 0.25.9 | 2023/04/14-12:34
null | [Eng Zer Jun] Replace `github.com/ghodss/yaml` with `sigs.k8s.io/yaml` | 2023/04/16-13:44
null | [pratap0007] Remove all occurrence of PipelineResource and move pipeline to 0.46.0 in CI | 2023/04/17-15:06
null | [dependabot[bot]] Bump github.com/docker/cli | 2023/04/19-20:14
null | [Luiz Carvalho] Update to cosign v2 | 2023/04/19-21:38
null | [pratap0007] Remove docs related to PipelineResource | 2023/04/20-10:34
null | [dependabot[bot]] Bump k8s.io/api from 0.26.1 to 0.26.4 | 2023/04/22-04:36
null | [dependabot[bot]] Bump github.com/sigstore/sigstore from 1.6.1 to 1.6.3 | 2023/04/22-05:12
null | [dependabot[bot]] Bump github.com/docker/docker | 2023/04/22-05:46
null | [pratap0007] Remove PipelineResource in the describe command test | 2023/04/25-19:40
null | [PuneetPunamiya] Remove flags from chains payload command as not used | 2023/05/02-10:40
null | [pratap0007] Remove default value info for true flag in delete command | 2023/05/02-13:16
null | [pratap0007] Upgrade golangci version to v1.52.2 and fix lint errors | 2023/05/04-13:26
null | [pratap0007] Bump tektoncd/pipeline to 0.47.0 manually | 2023/05/05-21:34
null | [dependabot[bot]] Bump github.com/docker/cli | 2023/05/06-04:04
null | [dependabot[bot]] Bump github.com/docker/docker | 2023/05/06-04:40
null | [dependabot[bot]] Bump golang.org/x/term from 0.7.0 to 0.8.0 | 2023/05/06-12:58
null | [pratap0007] Fix tkn pr/tr delete command for keep flag | 2023/05/06-16:44
null | [dependabot[bot]] Bump github.com/tektoncd/chains | 2023/05/06-17:24
null | [Piyush Garg] Bump cosign to v2.0.2 | 2023/05/07-06:44
null | [dependabot[bot]] Bump github.com/docker/cli | 2023/05/08-16:42
null | [dependabot[bot]] Bump github.com/docker/docker | 2023/05/08-18:08
null | [dependabot[bot]] Bump github.com/tektoncd/hub from 1.12.1 to 1.13.0 | 2023/05/09-08:08

Signed-off-by: vinamra28 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. lgtm Indicates that a PR is ready to be merged. release-note-none Denotes a PR that doesnt merit a release note. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants