Skip to content

test(generators): add regression tests for deterministic ConfigMap key ordering#6092

Open
lolo1883NIG wants to merge 2 commits intokubernetes-sigs:masterfrom
lolo1883NIG:fix/configmap-deterministic-order
Open

test(generators): add regression tests for deterministic ConfigMap key ordering#6092
lolo1883NIG wants to merge 2 commits intokubernetes-sigs:masterfrom
lolo1883NIG:fix/configmap-deterministic-order

Conversation

@lolo1883NIG
Copy link
Copy Markdown

What this does

Adds explicit regression tests verifying that ConfigMap data keys are always emitted in sorted (alphabetical) order regardless of the order they are defined in the source.

Closes #4292

Background

Issue #4292 reported that kustomize build could produce ConfigMap items in a non-deterministic order. A previous fix attempt (#6025) was closed because it lacked sufficient test coverage — the reviewer explicitly asked for tests before anything else would be reviewed.

This PR addresses that feedback directly by adding three new test cases to TestMakeConfigMap:

  • Literals in non-alphabetical order — keys defined as zebra, mango, apple, banana, kiwi must output as apple, banana, kiwi, mango, zebra
  • Env file with non-alphabetical keys — same guarantee for env file sources
  • Mixed literal + env sources — ordering is deterministic across source types

The behavior under test is already implemented via SortedMapKeys in kyaml/yaml/datamap.go. These tests lock it in against future regressions.

Testing

go test ./api/internal/generators/... -run TestMakeConfigMap -v

All 8 test cases pass (3 new + 5 existing).

Note on pre-existing failures

TestAddManagedbyLabel in api/krusty and a test in api/provenance fail due to a version string mismatch (kustomize-(devel) vs kustomize-(test)) that is pre-existing on master and unrelated to this change.

@k8s-ci-robot k8s-ci-robot added the do-not-merge/invalid-commit-message Indicates that a PR should not merge because it has an invalid commit message. label Mar 12, 2026
@k8s-ci-robot
Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: lolo1883NIG
Once this PR has been reviewed and has the lgtm label, please assign koba1t for approval. For more information see the Code Review Process.

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

Details 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

@k8s-ci-robot
Copy link
Copy Markdown
Contributor

Welcome @lolo1883NIG!

It looks like this is your first PR to kubernetes-sigs/kustomize 🎉. Please refer to our pull request process documentation to help your PR have a smooth ride to approval.

You will be prompted by a bot to use commands during the review process. Do not be afraid to follow the prompts! It is okay to experiment. Here is the bot commands documentation.

You can also check if kubernetes-sigs/kustomize has its own contribution guidelines.

You may want to refer to our testing guide if you run into trouble with your tests not passing.

If you are having difficulty getting your pull request seen, please follow the recommended escalation practices. Also, for tips and tricks in the contribution process you may want to read the Kubernetes contributor cheat sheet. We want to make sure your contribution gets all the attention it needs!

Thank you, and welcome to Kubernetes. 😃

@k8s-ci-robot k8s-ci-robot added the needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. label Mar 12, 2026
@linux-foundation-easycla
Copy link
Copy Markdown

linux-foundation-easycla bot commented Mar 12, 2026

CLA Signed

The committers listed above are authorized under a signed CLA.

@k8s-ci-robot
Copy link
Copy Markdown
Contributor

Hi @lolo1883NIG. Thanks for your PR.

I'm waiting for a kubernetes-sigs member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work.

Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

Details

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.

@k8s-ci-robot k8s-ci-robot added cncf-cla: no Indicates the PR's author has not signed the CNCF CLA. size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Mar 12, 2026
@lolo1883NIG lolo1883NIG force-pushed the fix/configmap-deterministic-order branch from 1db11f5 to d375c24 Compare March 12, 2026 13:07
@k8s-ci-robot k8s-ci-robot removed the do-not-merge/invalid-commit-message Indicates that a PR should not merge because it has an invalid commit message. label Mar 12, 2026
…y ordering

Adds explicit test cases to verify that ConfigMap data keys are always
emitted in sorted (alphabetical) order regardless of the order they are
defined in the source — covering literals, env files, and mixed sources.
@lolo1883NIG lolo1883NIG force-pushed the fix/configmap-deterministic-order branch from d375c24 to 0ac8ab7 Compare March 12, 2026 13:11
@k8s-ci-robot k8s-ci-robot added cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. and removed cncf-cla: no Indicates the PR's author has not signed the CNCF CLA. labels Mar 12, 2026
@lolo1883NIG
Copy link
Copy Markdown
Author

Hey @koba1t or @varshaprasad96 can you review and provide /ok-to-test?

@koba1t
Copy link
Copy Markdown
Member

koba1t commented Mar 12, 2026

#6025 has not been closed yet....

@k8s-ci-robot
Copy link
Copy Markdown
Contributor

@koba1t: The label(s) triage/duplicated cannot be applied, because the repository doesn't have them.

Details

In response to this:

#6025 has not been closed yet....
/triage duplicated

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.

@koba1t koba1t added the triage/duplicate Indicates an issue is a duplicate of other open issue. label Mar 12, 2026
@koba1t
Copy link
Copy Markdown
Member

koba1t commented Mar 12, 2026

@lolo1883NIG
I understand that you want to add a test to confirm that it is sorted order.
This comment describes the failure case that causes the problem, so please also add the test for the case raised here.
#4292 (comment)

@k8s-ci-robot
Copy link
Copy Markdown
Contributor

This PR has multiple commits, and the default merge method is: merge.
You can request commits to be squashed using the label: tide/merge-method-squash

Details

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.

@k8s-ci-robot k8s-ci-robot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. and removed size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Mar 13, 2026
@Believe-AS
Copy link
Copy Markdown

/approve cancel

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. triage/duplicate Indicates an issue is a duplicate of other open issue.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ConfigMaps items are generated with random order

4 participants