Skip to content

Download kubernetes for E2E tests ourselves#86

Merged
knative-prow-robot merged 1 commit intoknative:masterfrom
adrcunha:download-k8s
Aug 21, 2018
Merged

Download kubernetes for E2E tests ourselves#86
knative-prow-robot merged 1 commit intoknative:masterfrom
adrcunha:download-k8s

Conversation

@adrcunha
Copy link
Copy Markdown
Contributor

@adrcunha adrcunha commented Aug 21, 2018

The current approach for running the E2E tests through kubetest is to let the tool magically download kubernetes and start the cluster.

To ensure that our tests don't unexpectedly break, we don't pin the kubernetes version to a particular one (knative/serving#1294) but always use latest.

However, the concept of latest for kubetests means "kubernetes head", which can be broken (didn't happen so far) or doesn't support all platforms (OS X is the most common case).

Unfortunately, switching to default or release/stable translates to kubernetes 1.9, which is not recommended for Knative according to the docs.

This PR reverts the default GKE version to latest and adds the function download_k8s(): it will download the latest public, stable GKE binary supported by the test cluster and the client machine.

As a bonus, the function knocks out the kubernetes-test.tar.gz package; this 1.2GB package is not used by Knative tests, and is a severe burden on slower connections (anedoctal evidence: 20+ min download on my home network).

Fixes #40.

Bonus 1: fixes #80.
Bonus 2: fixes knative/serving#1914.

…to let the tool magically download kubernetes and start the cluster.

To ensure that our tests don't unexpectedly break, we don't pin the kubernetes version to a particular one (knative/serving#1294) but always use `latest`.

However, the concept of `latest` for kubetests means "kubernetes head", which can be broken (didn't happen so far) or doesn't support all platforms (OS X is the most common case).

Unfortunately, switching to `default` or `release/stable` translates to kubernetes 1.9, which is not recommended for Knative according to the docs.

This PR adds the function `download_k8s()`: it will download the latest public, stable GKE binary supported by the test cluster and the client machine.

As a bonus, the function knocks out the `kubernetes-test.tar.gz` package; this 1.2GB package is not used by Knative tests, and is a severe burden on slower connections (anedoctal evidence: 20+ min download on my home network).

Fixes #40.

Bonus: fixes #80.
@knative-prow-robot knative-prow-robot added the size/M Denotes a PR that changes 30-99 lines, ignoring generated files. label Aug 21, 2018
@knative-prow-robot
Copy link
Copy Markdown
Collaborator

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: adrcunha

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

@knative-prow-robot knative-prow-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Aug 21, 2018
@adrcunha adrcunha changed the title The current approach for running the E2E tests through kubetest is … Download kubernetes for E2E tests ourselves Aug 21, 2018
@jessiezcc
Copy link
Copy Markdown
Contributor

/lgtm

@knative-prow-robot knative-prow-robot added the lgtm Indicates that a PR is ready to be merged. label Aug 21, 2018
@knative-prow-robot knative-prow-robot merged commit 7cb4d66 into knative:master Aug 21, 2018
adrcunha added a commit that referenced this pull request Aug 22, 2018
`kubectl` 1.11 doesn't recognize the `--username` and `--password` flags anymore. Because the `prow-tests` image uses `kubectl` 1.8, the Prow jobs are not broken (yet).

The changes in #86 don't work because the context is not changed (nor restored), but the function works as long as the current user is an owner of the GCP project (which is not the case for Prow E2E test jobs).

This change creates and uses a new context for the cluster admin, created the role binding, then switches back to the original context. This is more secure as no ACL changes are required for the current user, nor project wide ACL changes are performed.
Cynocracy pushed a commit to Cynocracy/test-infra that referenced this pull request Jun 13, 2020
This starts to sketch common libraries for instantiating informers/listers for a particular GroupVersionResource as one of our duck types.

You can instantiate a duck.InformerFactory like so:
```go
        dynaClient, err := dynamic.NewForConfig(cfg)
        if err != nil {
                logger.Fatalf("Error building dynamic clientset: %v", err)
        }

	// Cache as the outermost layer so we only register the EventHandler once.
        dif := &duck.CachedInformerFactory{
                Delegate: &duck.EnqueueInformerFactory{
			Delegate: &duck.TypedInformerFactory{
        	                Client:       dynaClient,
                	        Type:         &duckv1alpha1.Target{},
                        	ResyncPeriod: 30 * time.Second,
	                        StopChannel:  stopCh,
			},
			EventHandler: cache.ResourceEventHandlerFuncs{
				AddFunc: func(obj interface{}) {
					// Enqueue, obj is: *duckerv1alpha1.Target
				},
				UpdateFunc: func(old, new interface{}) {
					// Enqueue, old and new are: *duckerv1alpha1.Target
				},
			},
                },
        }
```

Then, as you come across new GroupVersionResources that you want to handle:
```go
        informer, lister, err := dif.Get(gvr)
        if err != nil {
               logger.Fatalf("Error starting shared index informer: %v", err)
        }
```

With the `duck.TypedInformerFactory` the objects will be returned as the provided `Type:`, so in this example, you could safely write:
```go
        elt, err := lister.ByNamespace(ns).Get(name)
        if err != nil { ... }

        target := elt.(*duckv1alpha1.Target)
        // Stuff involving target.
```
knative-prow-updater-robot pushed a commit to knative-prow-updater-robot/test-infra that referenced this pull request Jun 5, 2023
Bumps rust from 1.69 to 1.70.

---
updated-dependencies:
- dependency-name: rust
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
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/M Denotes a PR that changes 30-99 lines, ignoring generated files.

Projects

None yet

3 participants