Skip to content

Commit 9828ab7

Browse files
authored
Merge pull request #349 from xueweiz/test
Allow e2e test to rent project from Boskos
2 parents 5345185 + fb7fd23 commit 9828ab7

File tree

1,243 files changed

+89643
-91387
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

1,243 files changed

+89643
-91387
lines changed

Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,7 @@ e2e-test: vet fmt build-tar
115115
-image=$(VM_IMAGE) -image-project=$(IMAGE_PROJECT) \
116116
-ssh-user=$(SSH_USER) -ssh-key=$(SSH_KEY) \
117117
-npd-build-tar=`pwd`/$(TARBALL) \
118+
-boskos-project-type=$(BOSKOS_PROJECT_TYPE) -job-name=$(JOB_NAME) \
118119
-artifacts-dir=$(ARTIFACTS)
119120

120121
build-binaries: ./bin/node-problem-detector ./bin/log-counter

go.mod

Lines changed: 10 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -3,61 +3,43 @@ module k8s.io/node-problem-detector
33
go 1.11
44

55
require (
6+
cloud.google.com/go v0.43.0
67
code.cloudfoundry.org/clock v0.0.0-20180518195852-02e53af36e6c
78
contrib.go.opencensus.io/exporter/prometheus v0.0.0-20190427222117-f6cda26f80a3
89
contrib.go.opencensus.io/exporter/stackdriver v0.12.5
9-
github.com/PuerkitoBio/purell v1.0.0 // indirect
10-
github.com/PuerkitoBio/urlesc v0.0.0-20160726150825-5bd2802263f2 // indirect
1110
github.com/StackExchange/wmi v0.0.0-20181212234831-e0a55b97c705 // indirect
1211
github.com/avast/retry-go v2.4.1+incompatible
13-
github.com/beorn7/perks v1.0.0 // indirect
1412
github.com/cobaugh/osrelease v0.0.0-20181218015638-a93a0a55a249
1513
github.com/coreos/go-systemd v0.0.0-20190321100706-95778dfbb74e
16-
github.com/coreos/pkg v0.0.0-20160620232715-fa29b1d70f0b // indirect
1714
github.com/emicklei/go-restful v0.0.0-20170410110728-ff4f55a20633 // indirect
1815
github.com/euank/go-kmsg-parser v2.0.1+incompatible
19-
github.com/ghodss/yaml v0.0.0-20150909031657-73d445a93680 // indirect
2016
github.com/go-ole/go-ole v1.2.4 // indirect
21-
github.com/go-openapi/jsonpointer v0.0.0-20160704185906-46af16f9f7b1 // indirect
22-
github.com/go-openapi/jsonreference v0.0.0-20160704190145-13c6e3589ad9 // indirect
23-
github.com/go-openapi/spec v0.0.0-20160808142527-6aced65f8501 // indirect
24-
github.com/go-openapi/swag v0.0.0-20160704191624-1d0bd113de87 // indirect
2517
github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b
26-
github.com/golang/groupcache v0.0.0-20150125180832-604ed5785183 // indirect
2718
github.com/google/cadvisor v0.33.0
28-
github.com/google/gofuzz v0.0.0-20161122191042-44d81051d367 // indirect
29-
github.com/googleapis/gnostic v0.1.0 // indirect
30-
github.com/gregjones/httpcache v0.0.0-20170926212834-c1f8028e62ad // indirect
3119
github.com/howeyc/gopass v0.0.0-20160826175423-3ca23474a7c7 // indirect
32-
github.com/imdario/mergo v0.0.0-20141206190957-6633656539c1 // indirect
33-
github.com/json-iterator/go v0.0.0-20171130024224-051434fab7e0 // indirect
3420
github.com/juju/ratelimit v0.0.0-20170523012141-5b9ff8664717 // indirect
35-
github.com/kr/pretty v0.1.0 // indirect
36-
github.com/mailru/easyjson v0.0.0-20160728113105-d5b7844b561a // indirect
3721
github.com/onsi/ginkgo v1.8.0
3822
github.com/onsi/gomega v1.5.0 // indirect
3923
github.com/pborman/uuid v1.2.0
4024
github.com/peterbourgon/diskv v2.0.1+incompatible // indirect
4125
github.com/prometheus/client_model v0.0.0-20190129233127-fd36f4220a90
42-
github.com/prometheus/common v0.3.0
43-
github.com/prometheus/procfs v0.0.0-20190425082905-87a4384529e0 // indirect
26+
github.com/prometheus/common v0.4.1
4427
github.com/shirou/gopsutil v2.18.12+incompatible
4528
github.com/shirou/w32 v0.0.0-20160930032740-bb4de0191aa4 // indirect
4629
github.com/sigma/go-inotify v0.0.0-20181102212354-c87b6cf5033d // indirect
4730
github.com/spf13/pflag v1.0.3
48-
github.com/stretchr/testify v1.3.0
31+
github.com/stretchr/testify v1.4.0
4932
github.com/tedsuo/ifrit v0.0.0-20180802180643-bea94bb476cc // indirect
5033
go.opencensus.io v0.22.0
5134
golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45
5235
google.golang.org/api v0.7.0
53-
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127 // indirect
54-
gopkg.in/inf.v0 v0.9.0 // indirect
5536
gopkg.in/yaml.v1 v1.0.0-20140924161607-9f9df34309c0 // indirect
56-
k8s.io/api v0.0.0-20180127130940-acf347b865f2
57-
k8s.io/apimachinery v0.0.0-20180126010752-19e3f5aa3adc
58-
k8s.io/client-go v0.0.0-20180103015815-9389c055a838
37+
k8s.io/api v0.0.0-20190816222004-e3a6b8045b0b
38+
k8s.io/apimachinery v0.0.0-20190816221834-a9f1d8a9c101
39+
k8s.io/client-go v11.0.1-0.20190805182717-6502b5e7b1b5+incompatible
5940
k8s.io/heapster v0.0.0-20180704153620-b25f8a16208f
60-
k8s.io/klog v0.3.2 // indirect
61-
k8s.io/kube-openapi v0.0.0-20180216212618-50ae88d24ede // indirect
62-
k8s.io/kubernetes v1.14.2
41+
k8s.io/kubernetes v1.14.6
42+
k8s.io/test-infra v0.0.0-20190914015041-e1cbc3ccd91c
6343
)
44+
45+
replace git.apache.org/thrift.git => github.com/apache/thrift v0.0.0-20180902110319-2566ecd5d999

go.sum

Lines changed: 304 additions & 0 deletions
Large diffs are not rendered by default.

pkg/exporters/k8sexporter/condition/manager.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -110,10 +110,11 @@ func (c *conditionManager) GetConditions() []types.Condition {
110110
}
111111

112112
func (c *conditionManager) syncLoop() {
113-
updateCh := c.clock.Tick(updatePeriod)
113+
ticker := c.clock.NewTicker(updatePeriod)
114+
defer ticker.Stop()
114115
for {
115116
select {
116-
case <-updateCh:
117+
case <-ticker.C():
117118
if c.needUpdates() || c.needResync() || c.needHeartbeat() {
118119
c.sync()
119120
}

test/e2e/metriconly/e2e_npd_test.go

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,16 @@ limitations under the License.
1717
package e2e_metric_only
1818

1919
import (
20+
"context"
2021
"flag"
2122
"fmt"
2223
"os"
2324
"path"
2425
"testing"
26+
"time"
2527

2628
"k8s.io/node-problem-detector/test/e2e/lib/gce"
29+
"k8s.io/test-infra/boskos/client"
2730

2831
"github.com/onsi/ginkgo"
2932
"github.com/onsi/ginkgo/reporters"
@@ -36,10 +39,17 @@ var zone = flag.String("zone", "", "gce zone the hosts live in")
3639
var project = flag.String("project", "", "gce project the hosts live in")
3740
var image = flag.String("image", "", "image to test")
3841
var imageProject = flag.String("image-project", "", "gce project of the OS image")
42+
var jobName = flag.String("job-name", "", "name of the Prow job running the test")
3943
var sshKey = flag.String("ssh-key", "", "path to ssh private key.")
4044
var sshUser = flag.String("ssh-user", "", "use predefined user for ssh.")
4145
var npdBuildTar = flag.String("npd-build-tar", "", "tarball containing NPD to be tested.")
4246
var artifactsDir = flag.String("artifacts-dir", "", "local directory to save test artifacts into.")
47+
var boskosProjectType = flag.String("boskos-project-type", "gce-project",
48+
"specifies which project type to select from Boskos.")
49+
var boskosServerURL = flag.String("boskos-server-url", "http://boskos.test-pods.svc.cluster.local",
50+
"specifies Boskos server URL.")
51+
var boskosWaitDuration = flag.Duration("boskos-wait-duration", 5*time.Minute,
52+
"Duration to wait before quitting getting Boskos resource.")
4353

4454
var computeService *compute.Service
4555

@@ -48,6 +58,13 @@ func TestNPD(t *testing.T) {
4858
t.Skip("skipping test in short mode.")
4959
}
5060

61+
if *project == "" {
62+
boskosClient := client.NewClient(*jobName, *boskosServerURL)
63+
*project = acquireProjectOrDie(boskosClient)
64+
65+
defer releaseProjectOrDie(boskosClient)
66+
}
67+
5168
if *artifactsDir != "" {
5269
_, err := os.Stat(*artifactsDir)
5370
if err != nil && os.IsNotExist(err) {
@@ -60,6 +77,37 @@ func TestNPD(t *testing.T) {
6077
ginkgo.RunSpecsWithDefaultAndCustomReporters(t, "NPD Metric-only Suite", []ginkgo.Reporter{junitReporter})
6178
}
6279

80+
func acquireProjectOrDie(boskosClient *client.Client) string {
81+
fmt.Printf("Renting project from Boskos\n")
82+
ctx, cancel := context.WithTimeout(context.Background(), *boskosWaitDuration)
83+
defer cancel()
84+
p, err := boskosClient.AcquireWait(ctx, *boskosProjectType, "free", "busy")
85+
if err != nil {
86+
panic(fmt.Sprintf("Unable to rent project from Boskos: %v\n", err))
87+
}
88+
fmt.Printf("Rented project %s from Boskos", p.Name)
89+
90+
go func(boskosClient *client.Client, projectName string) {
91+
for range time.Tick(5 * time.Minute) {
92+
if err := boskosClient.UpdateOne(projectName, "busy", nil); err != nil {
93+
fmt.Printf("Failed to update status for project %s with Boskos: %v\n", projectName, err)
94+
}
95+
}
96+
}(boskosClient, p.Name)
97+
98+
return p.Name
99+
}
100+
101+
func releaseProjectOrDie(boskosClient *client.Client) {
102+
if !boskosClient.HasResource() {
103+
return
104+
}
105+
err := boskosClient.ReleaseAll("dirty")
106+
if err != nil {
107+
panic(fmt.Sprintf("Failed to release project to Boskos: %v", err))
108+
}
109+
}
110+
63111
func TestMain(m *testing.M) {
64112
flag.Parse()
65113

vendor/github.com/PuerkitoBio/purell/.gitignore

Lines changed: 0 additions & 5 deletions
This file was deleted.

vendor/github.com/PuerkitoBio/purell/.travis.yml

Lines changed: 0 additions & 7 deletions
This file was deleted.

vendor/github.com/PuerkitoBio/purell/LICENSE

Lines changed: 0 additions & 12 deletions
This file was deleted.

vendor/github.com/PuerkitoBio/purell/README.md

Lines changed: 0 additions & 185 deletions
This file was deleted.

0 commit comments

Comments
 (0)