Skip to content

More tests with ginkgo - #29

Merged
openshift-merge-robot merged 3 commits into
openshift:masterfrom
ingvagabund:more-tests-with-ginkgo
Feb 27, 2019
Merged

openshift-merge-robot merged 3 commits into
openshift:masterfrom
ingvagabund:more-tests-with-ginkgo

Conversation

@ingvagabund

Copy link
Copy Markdown
Member

No description provided.

@openshift-ci-robot openshift-ci-robot added the size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. label Feb 20, 2019
@ingvagabund

Copy link
Copy Markdown
Member Author

/retest

@openshift-ci-robot openshift-ci-robot added needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. and removed needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. labels Feb 23, 2019
@ingvagabund

Copy link
Copy Markdown
Member Author

/test k8s-e2e

@@ -0,0 +1,441 @@
package actuators

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This is called actuators but the fact that this is driven by the actuator is circumstantial today, this could be e.g the machine controller. This should belong to the same suite there's in infra and may be rename it to "elastic compute" or similar

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I did not want to overload the word controller. It's true machine controller is "just" a wrapper around an actuator. Here, actuator is shorter than machinecontroller or elasticcompute. Plus, elastic compute is process oriented term compared to actuator which is component oriented. To goal was to break the tests into component-wise buckets. Infra homes all tests of which I was not sure what would be the right component to put them to. More or less following what I described in the test design google doc.

@enxebre enxebre Feb 26, 2019 •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

the suite you are reimplementing belongs all together. It's validating holistic features that result from the interaction of one or more of the components that together provide the e2e machine API experience. Actuator is an implementation detail that we don't care about in this context
We should have only one suite pkg e.g "elastic compute", may be different files and a common utils
cc @bison @frobware

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I tend to agree that these are meant to be high-level E2E, so things should be named more after groups of features / use-cases / stories than components. Not really sure what the right thing is exactly though. Any example in upstream Kubernetes or something we can look to?

@ingvagabund ingvagabund Feb 26, 2019 •

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

We should have only one suite pkg e.g "elastic compute", may be different files and a common utils

There is only one test suite. Under the hood broken into more packages for better readability and manipulation.

  1. To be clear the conflict of interest is to decide if we are going to break the single test suite component-wise or process-wise. The test suite for me here is "Conformance". We might even go with pkg/e2e/conformance/... layout to explicitly say the tests fall under the category (though I don't consider that necessary).

    I am fine with both (component and process). Any hints on what would be the names/identifiers we might use for holistic process-wise categorization? I could imagine:

    • autoscaling
    • machinereconciling
    • anything else?

    elasticcompute is too generic buzzword that does not say anything.

  2. Does the conflict also includes the question of putting the tests under multiple files under one package instead of how it is currently done?

    I still want to break the individual tests into packages so you can import subset of tests in different test suite (e.g. Performance). If you check the import part of e2e_test.go, you can see:

    import (
    	...
    	_ "github.com/openshift/cluster-api-actuator-pkg/pkg/e2e/actuators"
    	_ "github.com/openshift/cluster-api-actuator-pkg/pkg/e2e/autoscaler"
    	_ "github.com/openshift/cluster-api-actuator-pkg/pkg/e2e/infra"
    	_ "github.com/openshift/cluster-api-actuator-pkg/pkg/e2e/operators"
    )

    I could have pkg/e2e/performance/e2e_test.go that will import just operators (to assert both operators are available and working). With all tests under the same package (just different files) you can import either all the tests or no tests. And I don't want to import all conformance tests into the performance test suite.

    And again, it's easier to see intention of a set of tests if they are imported from e.g. actuators or autocaler then to just have:

    import (
    	...
    	_ "github.com/openshift/cluster-api-actuator-pkg/pkg/e2e"
    )

Bottom line: On the other hand, one could argue we can put all the tests under one huge test suite and use [Conformance] and [Performance]. Doing that, we would need to put the keyword to every Describe or spec part to make sure only conformance, resp. performance tests are run when --ginkgo.focus is set to [Conformance], resp. [Performance] focus. Though, this can be discussed later once we have more test suites.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

1 - This must be process/feature wise, it does not care about components. Conformance/machines/smoke/elasticCompute I don't have strong opinions on the naming

2 - "you can import either all the tests or no tests." this is good and it's exactly the invariant we want to force. This suite is the gate for any of repo which might have an impact on the user feature validation

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

1 - This must be process/feature wise, it does not care about components. Conformance/machines/smoke/elasticCompute I don't have strong opinions on the naming

Conformance is the test suite name, machines, autoscaling, ... would be test suite groups. The question is what would be the group names?

2 - "you can import either all the tests or no tests." this is good and it's exactly the invariant we want to force. This suite is the gate for any of repo which might have an impact on the user feature validation

This is orthogonal to the question. All tests are to be run as part of Conformance test suite. Inseparably from each other. The intent is to:

  • allow other test suites to reuse subset of tests
  • decompose one huge test suite into smaller chunks (groups) so it's easier to maintain, read and extend the code

Comment thread pkg/e2e/actuators/actuators.go Outdated
)

const (
workerRoleLabel = "node-role.kubernetes.io/worker"

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

these values are duplicated in operator common. Can we have some common utils?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

nit: Anything but common or utils. Something with more explicit naming please.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Yeah, I will create pkg/e2e/common package.

Comment thread pkg/e2e/autoscaler/autoscaler.go Outdated
@@ -0,0 +1,371 @@
package infra

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

infra? is this an accidental carry over?
In any case is there any reason to have operator/autoscalers/infra/actuators.
I think they could all belong to same package e.g "elastic compute" and then have independent files and a common utils

@ingvagabund ingvagabund Feb 26, 2019 •

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

infra? is this an accidental carry over?

Right, it should be autoscaler.

In any case is there any reason to have operator/autoscalers/infra/actuators.
I think they could all belong to same package e.g "elastic compute" and then have independent files and a common utils

We are not exposing new API so in this case I prefer to allocate one directory/package for each important component. I still prefer smaller packages with few files rather than one package with a lots of files.

Comment thread pkg/e2e/framework/framework.go Resolved
Comment thread pkg/e2e/operators/common.go Resolved
@enxebre

enxebre commented Feb 26, 2019 •

Copy link
Copy Markdown
Member

thanks!! Dropped some comments. I don't see the need for having different packages, I'd be in favour of having all the suite in the same package e.g "elastic compute" and different files one common utils.
With the current e2e/openshift approach you can easily see a list of all the validations and understand the current coverage which makes it easier for others to chime in and add new tests. Since this is deprecating e2e/openshift can you remove those? Also could you elaborate a bit the motivation and improvements of this PR in the description?
cc @frobware @bison

Comment thread pkg/e2e/autoscaler/autoscaler.go Resolved
Comment thread Gopkg.lock Resolved
Comment thread Makefile
.PHONY: test
test: # Run unit test
$(DOCKER_CMD) go test -race -cover ./pkg/...
$(DOCKER_CMD) go test -race -cover `go list ./... | grep -v github.com/openshift/cluster-api-actuator-pkg/pkg/e2e`

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Why don't we be explicit here? Just run the named package?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

other packages might have unit tests worth running so I am just skipping anything but e2e

Comment thread Makefile
.PHONY: k8s-e2e
k8s-e2e: ## Run k8s specific e2e test
# KUBECONFIG and SSH_PK dirs needs to be mounted inside a container if tests are run in containers
go test -timeout 30m \

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I think the test-e2e and the k8s-e2e only differ in the namespace. We could create a Makefile macro here and reduce the duplication.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Any example?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

We might have a single make e2e-operator or similar and run make e2e-operator NAMESPACE=kube-system so there is only a single point of entry. This will require to update the Prow job first. Let's do it in the next iteration so we can start adding new tests to the new framework.

Comment thread pkg/e2e/actuators/actuators.go Outdated
)

const (
workerRoleLabel = "node-role.kubernetes.io/worker"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

nit: Anything but common or utils. Something with more explicit naming please.

Comment thread pkg/e2e/actuators/actuators.go Outdated
return machine
}

func isNodeReady(node *corev1.Node) bool {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Can't believe you bailed on the 67MB import from kube for this... :-D

Comment thread pkg/e2e/actuators/actuators.go Outdated
return false
}

func waitUntilNodesAreReady(client runtimeclient.Client, listOpt *runtimeclient.ListOptions, nodeCount int) error {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I think we should pass in a Context here - start with that in mind so that we can do cancellation.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

We should have to set BeforeEach for each g.Describe like this (most of the code can be put into a function and called, yet still needs to be repeated):

	var describeContext context.Context

	g.BeforeEach(func() {
		var cancel context.CancelFunc

		g.By("Creating context")

		stopCh := signals.SetupSignalHandler()
		describeContext, cancel = context.WithCancel(context.Background())
		go func() {
			select {
			case <-stopCh:
				cancel()
			case <-describeContext.Done():
			}
		}()
	})

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Let's discuss this and expectations in the next iteration of the tests. Right now, I am not sure how we should approach this.

Comment thread pkg/e2e/actuators/actuators.go Resolved
Comment thread pkg/e2e/actuators/actuators.go Resolved
Comment thread pkg/e2e/actuators/actuators.go Resolved
Comment thread pkg/e2e/actuators/actuators.go Resolved
@ingvagabund

Copy link
Copy Markdown
Member Author

/retest

@enxebre

enxebre commented Feb 27, 2019

Copy link
Copy Markdown
Member

/approve

@openshift-ci-robot

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: enxebre

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

The pull request process is described 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

@openshift-ci-robot openshift-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Feb 27, 2019
@enxebre

enxebre commented Feb 27, 2019

Copy link
Copy Markdown
Member

This looks good enough to me. Once we merge we can sync all repos to run this and follow up with any farther improvement

@enxebre

enxebre commented Feb 27, 2019

Copy link
Copy Markdown
Member

/lgtm

@openshift-ci-robot openshift-ci-robot added the lgtm Indicates that a PR is ready to be merged. label Feb 27, 2019
@openshift-merge-robot
openshift-merge-robot merged commit d8aa532 into openshift:master Feb 27, 2019
@ingvagabund
ingvagabund deleted the more-tests-with-ginkgo branch February 27, 2019 13:45
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. 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.

6 participants