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

initial commit for tests #50

Merged
merged 3 commits into from Dec 11, 2019
Merged

Conversation

lina-is-here
Copy link

@lina-is-here lina-is-here commented Nov 18, 2019

Output locally

$ go test ./test/integration
ok      github.com/openshift/insights-operator/test/integration 10.722s

@openshift-ci-robot openshift-ci-robot added do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Nov 18, 2019
@openshift-ci-robot
Copy link
Contributor

Hi @lina-nikiforova. Thanks for your PR.

I'm waiting for a openshift 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. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@openshift-ci-robot openshift-ci-robot added the size/M Denotes a PR that changes 30-99 lines, ignoring generated files. label Nov 18, 2019
@openshift-ci-robot openshift-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 Nov 19, 2019
@lina-is-here lina-is-here changed the title WIP: initial commit for tests initial commit for tests Nov 20, 2019
@openshift-ci-robot openshift-ci-robot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Nov 20, 2019
Copy link
Contributor

@tisnik tisnik left a comment

Choose a reason for hiding this comment

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

@lina-nikiforova it looks very good so far, thank you a lot! I just added some nitpicks, we might discuss about them f2f

err := kubeClient.CoreV1().Secrets("openshift-config").Delete("support", &metav1.DeleteOptions{})

// if the secret is not found, continue, not a problem
if (err != nil) && (err.Error() != "secrets \"support\" not found") {
Copy link
Contributor

Choose a reason for hiding this comment

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

!= operator has higher precedence that &&, so strictly speaking parenthesis are not needed there

(https://golang.org/ref/spec#Operators)

Copy link
Contributor

Choose a reason for hiding this comment

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

you can write `secrets "support" not found` instead of escaping quote (but it depends what you prefer)

Copy link
Author

Choose a reason for hiding this comment

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

thanks!

// restart insights-operator (delete pods)
pods, err := kubeClient.CoreV1().Pods("openshift-insights").List(metav1.ListOptions{})
if err != nil {
panic(err.Error())
Copy link
Contributor

Choose a reason for hiding this comment

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

t.Fatal(err.Error())


// if the secret is not found, continue, not a problem
if (err != nil) && (err.Error() != "secrets \"support\" not found") {
panic(err.Error())
Copy link
Contributor

Choose a reason for hiding this comment

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

t.Fatal(err.Error())

// check logs for "Gathering cluster info every 2h0m0s"
newPods, err := kubeClient.CoreV1().Pods("openshift-insights").List(metav1.ListOptions{})
if err != nil {
panic(err.Error())
Copy link
Contributor

Choose a reason for hiding this comment

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

t.Fatal(err.Error())

log := buf.String()

result := strings.Contains(log, "Gathering cluster info every 2h0m0s")
podLogs.Close()
Copy link
Contributor

Choose a reason for hiding this comment

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

I'd suggest to use defer podLogs.Close() on line 63 or so

Copy link
Author

Choose a reason for hiding this comment

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

I had it there but somehow got errors when I used it... I'll try to look into it again

Copy link
Author

Choose a reason for hiding this comment

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

now it seems to work, I was missing handling of one of the errors :)

)

func KubeClient() (result *kubernetes.Clientset) {
kubeconfig := os.Getenv("KUBECONFIG") // variable is a path to the local kubeconfig
Copy link
Contributor

Choose a reason for hiding this comment

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

would be good to test whether the $KUBECONFIG exists at all

Copy link
Author

Choose a reason for hiding this comment

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

done using os.LookupEnv

_, err := kubeClient.CoreV1().Pods("openshift-insights").Get(pod.Name, metav1.GetOptions{})
if err == nil {
fmt.Printf("the pod is not yet deleted: %v\n", err)
return false, nil
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm not sure there - should not it be rather:

return false, err?

@mfojtik
Copy link
Member

mfojtik commented Nov 25, 2019

/ok-to-test

@openshift-ci-robot openshift-ci-robot added ok-to-test Indicates a non-member PR verified by an org member that is safe to test. and removed needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Nov 25, 2019
@quarckster
Copy link
Contributor

/retest

@quarckster
Copy link
Contributor

@mfojtik, please put a required label if you think this PR is fine.

@mfojtik
Copy link
Member

mfojtik commented Dec 11, 2019

/lgtm

@openshift-ci-robot openshift-ci-robot added the lgtm Indicates that a PR is ready to be merged. label Dec 11, 2019
@openshift-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: lina-nikiforova, mfojtik

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

@openshift-ci-robot openshift-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Dec 11, 2019
@openshift-merge-robot openshift-merge-robot merged commit ed5af49 into openshift:master Dec 11, 2019
@lina-is-here lina-is-here deleted the tests branch December 11, 2019 11:35
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. ok-to-test Indicates a non-member PR verified by an org member that is safe to test. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants