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

workloadrepo: Add unit testing for the Workload Repository. #58266

Merged
merged 24 commits into from
Jan 9, 2025

Conversation

wddevries
Copy link
Contributor

Issue Number: ref #58247

Problem Summary:

This pull request adds unit testing for the Workload Repository code. It also fixes a few issues and refactors some code. Specific changes include:

  • Create the etcd snap id key the first actual value instead of zero.
  • Enable snapshot collection for the TIDB_INDEX_USAGE.
  • Add checks for nil to a few places in the partition handling code.
  • Partition validation code will only check that partitions cover today and tomorrow.
  • It will only generate new partitions if no partition covers the current day and the next day.
  • Validate that the value assigned to tidb_workload_repository_dest is either an empty string or 'table.'
  • Fix a couple of bugs in the housing keeping process.
  • Factor out fillInTableNames(), createPartition() and dropOldPartition() for testing purposes.
  • Pass the current time into createAllTables() and createPartition() so that testing can be deterministic
  • Reread the information schema in createAllTables() before running code to create missing partitions.
  • Add unit tests for the Workload Repository.

Tests

  • Unit test
  • Integration test
  • Manual test (add detailed scripts or steps below)
  • No need to test
    • I checked and no code files have been changed.

Side effects

  • Performance regression: Consumes more CPU
  • Performance regression: Consumes more Memory
  • Breaking backward compatibility

Documentation

  • Affects user behaviors
  • Contains syntax changes
  • Contains variable changes
  • Contains experimental features
  • Changes MySQL compatibility

Release note

Please refer to Release Notes Language Style Guide to write a quality release note.

None

@ti-chi-bot ti-chi-bot bot added release-note-none Denotes a PR that doesn't merit a release note. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. labels Dec 15, 2024
Copy link

tiprow bot commented Dec 15, 2024

Hi @wddevries. Thanks for your PR.

PRs from untrusted users cannot be marked as trusted with /ok-to-test in this repo meaning untrusted PR authors can never trigger tests themselves. Collaborators can still trigger tests on the PR using /test all.

I understand the commands that are listed here.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

@bb7133
Copy link
Member

bb7133 commented Dec 16, 2024

Please resolve the conflicts.

Copy link

codecov bot commented Dec 18, 2024

Codecov Report

Attention: Patch coverage is 76.47059% with 44 lines in your changes missing coverage. Please review.

Project coverage is 73.6320%. Comparing base (67249cb) to head (bf04e11).
Report is 10 commits behind head on master.

Additional details and impacted files
@@               Coverage Diff                @@
##             master     #58266        +/-   ##
================================================
+ Coverage   73.0858%   73.6320%   +0.5462%     
================================================
  Files          1676       1676                
  Lines        463685     465641      +1956     
================================================
+ Hits         338888     342861      +3973     
+ Misses       103941     101924      -2017     
  Partials      20856      20856                
Flag Coverage Δ
integration 42.8211% <7.4866%> (?)
unit 72.3003% <75.9358%> (+0.0200%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Components Coverage Δ
dumpling 52.6910% <ø> (ø)
parser ∅ <ø> (∅)
br 45.7419% <ø> (+0.0209%) ⬆️

Copy link
Contributor

@henrybw henrybw left a comment

Choose a reason for hiding this comment

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

Pretty much LGTM

Copy link
Contributor

@xhebox xhebox left a comment

Choose a reason for hiding this comment

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

I don't have much objections on these little refactors, LGTM

Copy link
Contributor

@xhebox xhebox left a comment

Choose a reason for hiding this comment

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

�[31m�[1mTIMEOUT: �[0m//pkg/util/workloadrepo:workloadrepo_test (Summary)
      /home/jenkins/.tidb/tmp/63a9840cd0739f2c243bb46478607469/execroot/__main__/bazel-out/k8-fastbuild/testlogs/pkg/util/workloadrepo/workloadrepo_test/test.log
      /home/jenkins/.tidb/tmp/63a9840cd0739f2c243bb46478607469/execroot/__main__/bazel-out/k8-fastbuild/testlogs/pkg/util/workloadrepo/workloadrepo_test/test_attempts/attempt_1.log
      /home/jenkins/.tidb/tmp/63a9840cd0739f2c243bb46478607469/execroot/__main__/bazel-out/k8-fastbuild/testlogs/pkg/util/workloadrepo/workloadrepo_test/test_attempts/attempt_2.log
�[31m�[1mERROR: �[0m/home/jenkins/agent/workspace/pingcap/tidb/ghpr_unit_test/tidb/pkg/util/workloadrepo/BUILD.bazel:41:8: Testing //pkg/util/workloadrepo:workloadrepo_test failed: Test failed, aborting
==================== Test output for //pkg/util/workloadrepo:workloadrepo_test:

Is there a problem for the test?

Copy link

tiprow bot commented Dec 31, 2024

@wddevries: Cannot trigger testing until a trusted user reviews the PR and leaves an /ok-to-test message.

In response to this:

/test unit-test

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

@wddevries
Copy link
Contributor Author

/test unit-test

Copy link

tiprow bot commented Jan 1, 2025

@wddevries: Cannot trigger testing until a trusted user reviews the PR and leaves an /ok-to-test message.

In response to this:

/test unit-test

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

Copy link
Contributor

@henrybw henrybw left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link

ti-chi-bot bot commented Jan 6, 2025

@henrybw: adding LGTM is restricted to approvers and reviewers in OWNERS files.

In response to this:

LGTM

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

@wddevries wddevries force-pushed the add_unit_testing branch 2 times, most recently from 5b44f73 to 3da6355 Compare January 7, 2025 09:06
if !testWorker {
workerCtx.etcdClient = nil
Copy link
Contributor

Choose a reason for hiding this comment

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

Hmm, can we do workCtx = worker{}? GO will init every field to zero.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I was under the impression that multiple unit tests were being run within the same process and that the global variables were not reinitialized between tests, but my experimentation seems to indicate this is not the case. I will fix it.

@ti-chi-bot ti-chi-bot bot added approved needs-1-more-lgtm Indicates a PR needs 1 more LGTM. labels Jan 8, 2025
Copy link
Member

@bb7133 bb7133 left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link

ti-chi-bot bot commented Jan 9, 2025

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: bb7133, henrybw, xhebox

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

@ti-chi-bot ti-chi-bot bot added lgtm and removed needs-1-more-lgtm Indicates a PR needs 1 more LGTM. labels Jan 9, 2025
Copy link

ti-chi-bot bot commented Jan 9, 2025

[LGTM Timeline notifier]

Timeline:

  • 2025-01-08 03:33:28.277255836 +0000 UTC m=+324551.566087541: ☑️ agreed by xhebox.
  • 2025-01-09 03:03:58.62722449 +0000 UTC m=+409181.916056197: ☑️ agreed by bb7133.

@ti-chi-bot ti-chi-bot bot merged commit 2ae0b0a into pingcap:master Jan 9, 2025
24 checks passed
@wddevries wddevries deleted the add_unit_testing branch January 9, 2025 03:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved lgtm release-note-none Denotes a PR that doesn't 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