kubernetes-sigs / e2e-framework

A Go framework for end-to-end testing of components running in Kubernetes clusters.
Apache License 2.0
529 stars 103 forks source link

fix: fix RandomName's dash when no prefix provided #327

Closed pmalek closed 1 year ago

pmalek commented 1 year ago

What type of PR is this?

/kind bug

What this PR does / why we need it:

Currently envconf.RandomName() return a string with an empty prefix when no prefix was provided even though the godoc states:

If prefix is omitted, the then entire name is random char.

This PR fixes it by checking if an empty prefix was provided.

Which issue(s) this PR fixes:

Special notes for your reviewer:

Does this PR introduce a user-facing change?

fixes `envconfg.RandomName() returning a string beginning with `-` when an empty prefix is provided

Additional documentation e.g., Usage docs, etc.:

k8s-ci-robot commented 1 year ago

Hi @pmalek. 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.

Instructions for interacting with me using PR comments are available [here](https://git.k8s.io/community/contributors/guide/pull-requests.md). If you have questions or suggestions related to my behavior, please file an issue against the [kubernetes/test-infra](https://github.com/kubernetes/test-infra/issues/new?title=Prow%20issue:) repository.
ShwethaKumbla commented 1 year ago

/ok-to-test

pmalek commented 1 year ago

@ShwethaKumbla I've removed my change w.r.t usage of deprecated math/rand.Seed.

I'd be happy to resolve that in a separate pr but please advise on the linter issue.

make verify-golangci-lint returns an error because when I change the file the error from rand.Read(p) is not checked. I don't want to change the signature (to include the returned error) without consulting the maintainers first.

pmalek commented 1 year ago

An unrelated test seems to have failed 🤔

 === RUN   TestKwokCluster/appsv1/deployment/pod_ready
    kwok_test.go:73: context deadline exceeded
--- FAIL: TestKwokCluster (120.02s)
    --- FAIL: TestKwokCluster/appsv1/deployment (120.02s)
        --- FAIL: TestKwokCluster/appsv1/deployment/deployment_creation (60.00s)
        --- FAIL: TestKwokCluster/appsv1/deployment/pod_ready (60.00s)
panic: interface conversion: interface {} is nil, not *v1.Deployment [recovered]
    panic: interface conversion: interface {} is nil, not *v1.Deployment
goroutine 45 [running]:
testing.tRunner.func1.2({0x20b1620, 0xc00020a000})
    /usr/local/go/src/testing/testing.go:1526 +0x372
testing.tRunner.func1()
    /usr/local/go/src/testing/testing.go:1529 +0x650
panic({0x20b1620, 0xc00020a000})
    /usr/local/go/src/runtime/panic.go:890 +0x263
sigs.k8s.io/e2e-framework/examples/kwok/kwok_with_config.TestKwokCluster.func4({0x2582730, 0xc000586090}, 0xc00031c9c0, 0x2581b00?)
    /home/prow/go/src/sigs.k8s.io/e2e-framework/examples/kwok/kwok_with_config/kwok_test.go:78 +0x165
sigs.k8s.io/e2e-framework/pkg/env.(*testEnv).executeSteps(0xc00014f830, {0x2582730, 0xc000586090}, 0xc000586902?, {0xc000366220, 0x1, 0x2ce1120?})
    /home/prow/go/src/sigs.k8s.io/e2e-framework/pkg/env/env.go:428 +0x136
sigs.k8s.io/e2e-framework/pkg/env.(*testEnv).execFeature.func1(0xc00031c9c0)
    /home/prow/go/src/sigs.k8s.io/e2e-framework/pkg/env/env.go:486 +0x7ac
testing.tRunner(0xc00031c9c0, 0xc0002be1b0)
    /usr/local/go/src/testing/testing.go:1576 +0x217
created by testing.(*T).Run
    /usr/local/go/src/testing/testing.go:1629 +0x806 
pmalek commented 1 year ago

/retest

pmalek commented 1 year ago

Another unrelated failure :(

https://prow.k8s.io/view/gs/kubernetes-jenkins/pr-logs/pull/kubernetes-sigs_e2e-framework/327/pull-e2e-framework-test/1708826099758141440

         --- FAIL: TestTableDriven/Random_numbers/less_than_equal_64 (0.00s)
panic: invalid argument to Int31n [recovered]
    panic: invalid argument to Int31n
goroutine 15 [running]:
testing.tRunner.func1.2({0x2022aa0, 0x2554a30})
    /usr/local/go/src/testing/testing.go:1526 +0x372
testing.tRunner.func1()
    /usr/local/go/src/testing/testing.go:1529 +0x650
panic({0x2022aa0, 0x2554a30})
    /usr/local/go/src/runtime/panic.go:890 +0x263
math/rand.(*Rand).Int31n(0xc000225500, 0x0)
    /usr/local/go/src/math/rand/rand.go:138 +0x126
sigs.k8s.io/e2e-framework/examples/table.TestTableDriven.func2({0x256d580, 0xc000225560}, 0xc000183040, 0x0?)
    /home/prow/go/src/sigs.k8s.io/e2e-framework/examples/table/table_test.go:62 +0xac
sigs.k8s.io/e2e-framework/pkg/env.(*testEnv).executeSteps(0xc0002254a0, {0x256d580, 0xc000225560}, 0x599?, {0xc0005a9e88, 0x1, 0x0?})
    /home/prow/go/src/sigs.k8s.io/e2e-framework/pkg/env/env.go:428 +0x136
sigs.k8s.io/e2e-framework/pkg/env.(*testEnv).execFeature.func1.1(0xc000183040)
    /home/prow/go/src/sigs.k8s.io/e2e-framework/pkg/env/env.go:466 +0x125
testing.tRunner(0xc000183040, 0xc000225860)
    /usr/local/go/src/testing/testing.go:1576 +0x217
created by testing.(*T).Run
    /usr/local/go/src/testing/testing.go:1629 +0x806
FAIL    sigs.k8s.io/e2e-framework/examples/table    0.082s 

/retest

harshanarayana commented 1 year ago

/retest

harshanarayana commented 1 year ago

/lgtm /approve

k8s-ci-robot commented 1 year ago

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: harshanarayana, pmalek

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: - ~~[OWNERS](https://github.com/kubernetes-sigs/e2e-framework/blob/main/OWNERS)~~ [harshanarayana] Approvers can indicate their approval by writing `/approve` in a comment Approvers can cancel approval by writing `/approve cancel` in a comment