Skip to content

Commit

Permalink
Merge pull request openshift#1991 from mjudeikis/test.command.generator
Browse files Browse the repository at this point in the history
auto-generated docs
  • Loading branch information
openshift-merge-robot committed Oct 18, 2019
2 parents 0bb797d + c13b788 commit 4f19dd8
Show file tree
Hide file tree
Showing 7 changed files with 125 additions and 26 deletions.
1 change: 1 addition & 0 deletions Makefile
Expand Up @@ -60,6 +60,7 @@ releasenotes:

content:
go test -timeout=300s -tags=content -run=TestContent ./pkg/sync/$(LATEST_PLUGIN_VERSION)
go run ./hack/generate-test-commands >docs/commands.md
go generate ./pkg/sync/$(LATEST_PLUGIN_VERSION)

verify:
Expand Down
43 changes: 43 additions & 0 deletions docs/commands.md
@@ -0,0 +1,43 @@
# Test Commands

```
/test codecov
/test e2e-applysecurityupdates
/test conformance
/test e2e-changeloglevel
/test e2e-create-20190430
/test e2e-create-20190930
/test e2e-create-20191027
/test e2e-etcdbackuprecovery
/test e2e-forceupdate
/test e2e-keyrotation
/test e2e-reimagevm
/test e2e-scaleupdown
/test unit
/test upgrade-v10.0
/test upgrade-v7.1
/test upgrade-v9.0
/test vmimage
/test images
/test verify
```
27 changes: 1 addition & 26 deletions docs/testing.md
Expand Up @@ -4,33 +4,8 @@ OpenShift on Azure project is using a few testing methods.
Some of the test code base is being reused from other projects.

PR commands to execute tests:
```
/test e2e - run native e2e tests
/test unit - run unit tests
```

Optional test commands:
```
/test upgrade - run upgrade in-place cluster tests
/test conformance - run origin conformance tests
/test etcdbackuprecovery - run etcd backup and restore test
/test keyrotation - run key rotation test
/test e2e-no-test - no tests
/test prod - run prod tests (broken)
/test scaleupdown - run cluster scale-up-down test
/test upgrade-v1.2 - run upgrade release version v1.2 to PR code test
/test upgrade-v2.0 - run upgrade release version v2.0 to PR code test
/test upgrade-v2.1 - run upgrade release version v2.1 to PR code test
```

We have some optinal jobs, which are artifacts of prow-gen.
Those can be ignored and `/skip`ed. In example:
```
/test e2e-upgrade-v1.2
/test e2e-upgrade-v2.0
/test e2e-upgrade-v2.1
```
Upstream issue: https://github.com/openshift/ci-operator-prowgen/issues/79
[All test commands](commands.md)

## Verify

Expand Down
12 changes: 12 additions & 0 deletions hack/generate-test-commands/codecov_dummy_test.go
@@ -0,0 +1,12 @@
package main

import (
"testing"
)

// This file exists because this package has no unit tests. Codecov does not
// report packages with no unit tests as 0% coverage, incorrectly inflating our
// coverage statistics. When unit tests are added to this package, this file
// can be removed.

func TestDummyCodeCov(t *testing.T) {}
7 changes: 7 additions & 0 deletions hack/generate-test-commands/commands.md
@@ -0,0 +1,7 @@
# Test Commands

```
{{ range $value := . }}
{{ $value }}
{{ end }}
```
60 changes: 60 additions & 0 deletions hack/generate-test-commands/generate-test-commands.go
@@ -0,0 +1,60 @@
package main

import (
"fmt"
"io/ioutil"
"net/http"
"os"
"text/template"

"github.com/ghodss/yaml"
)

type prow struct {
Presubmits struct {
OpenshiftOpenshiftAzure []struct {
RerunCommand string `json:"rerun_command"`
} `json:"openshift/openshift-azure"`
} `json:"presubmits"`
}

func get(url string) ([]byte, error) {
/* #nosec - this helper is supposed to take an arbitrary url */
resp, err := http.Get(url)
if err != nil {
return nil, err
}
defer resp.Body.Close()

if resp.StatusCode != http.StatusOK {
return nil, fmt.Errorf("unexpected status code %d", resp.StatusCode)
}

return ioutil.ReadAll(resp.Body)
}

func run() error {
b, err := get("https://raw.githubusercontent.com/openshift/release/master/ci-operator/jobs/openshift/openshift-azure/openshift-openshift-azure-master-presubmits.yaml")
if err != nil {
return err
}

var prow prow
err = yaml.Unmarshal(b, &prow)
if err != nil {
return err
}

var commands []string
for _, c := range prow.Presubmits.OpenshiftOpenshiftAzure {
commands = append(commands, c.RerunCommand)
}

return template.Must(template.New("commands.md").ParseFiles("hack/generate-test-commands/commands.md")).Execute(os.Stdout, commands)
}

func main() {
if err := run(); err != nil {
panic(err)
}
}
1 change: 1 addition & 0 deletions hack/periodic/content-update.sh
Expand Up @@ -7,6 +7,7 @@ go generate ./...
. hack/tests/ci-prepare.sh

git add --all pkg/sync/$(shell go run hack/dev-version/dev-version.go)
git add --all docs/
GIT_COMMITTER_NAME=openshift-azure-robot GIT_COMMITTER_EMAIL=aos-azure@redhat.com git commit --no-gpg-sign --author 'openshift-azure-robot <aos-azure@redhat.com>' -m "Content update" || exit 0

git push https://openshift-azure-robot:$GITHUB_TOKEN@github.com/openshift-azure-robot/openshift-azure.git HEAD:content-update -f
Expand Down

0 comments on commit 4f19dd8

Please sign in to comment.