Skip to content

Commit 048b197

Browse files
committed
Update OSDK scorecard for 4.7
1 parent 5ad6898 commit 048b197

12 files changed

+456
-488
lines changed

modules/osdk-about-scorecard-tool.adoc

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

modules/osdk-running-scorecard.adoc

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

modules/osdk-scorecard-about.adoc

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
// Module included in the following assemblies:
2+
//
3+
// * operators/operator_sdk/osdk-scorecard.adoc
4+
5+
[id="osdk-about-scorecard_{context}"]
6+
= About the scorecard tool
7+
8+
While the Operator SDK `bundle validate` subcommand can validate local bundle directories and remote bundle images for content and structure, you can use the `scorecard` subcommand to run tests on your Operator based on a configuration file and test images. These tests are implemented within test images that are configured and constructed to be executed by the scorecard.
9+
10+
The scorecard assumes it is run with access to a configured Kubernetes cluster, such as {product-title}. The scorecard runs each test within a pod, from which pod logs are aggregated and test results are sent to the console. The scorecard has built-in basic and Operator Lifecycle Manager (OLM) tests and also provides a means to execute custom test definitions.
11+
12+
.Scorecard workflow
13+
. Create all resources required by any related custom resources (CRs) and the Operator
14+
. Create a proxy container in the deployment of the Operator to record calls to the API server and run tests
15+
. Examine parameters in the CRs
16+
17+
The scorecard tests make no assumptions as to the state of the Operator being tested. Creating Operators and CRs for an Operators are beyond the scope of the scorecard itself. Scorecard tests can, however, create whatever resources they require if the tests are designed for resource creation.
18+
19+
The `scorecard` subcommand has the following syntax:
20+
21+
[source,terminal]
22+
----
23+
$ operator-sdk scorecard <bundle_dir_or_image> [flags]
24+
----
25+
26+
The scorecard requires a positional argument for either the on-disk path to
27+
your Operator bundle or the name of a bundle image.
28+
29+
For further information about the flags, run:
30+
31+
[source,terminal]
32+
----
33+
$ operator-sdk scorecard -h
34+
----

modules/osdk-scorecard-config.adoc

Lines changed: 45 additions & 142 deletions
Original file line numberDiff line numberDiff line change
@@ -2,160 +2,63 @@
22
//
33
// * operators/operator_sdk/osdk-scorecard.adoc
44

5+
:osdk_ver: v1.3.0
6+
57
[id="osdk-scorecard-config_{context}"]
68
= Scorecard configuration
79

8-
The scorecard tool uses a configuration file that allows you to configure internal plug-ins, as well as several global configuration options.
9-
10-
[id="osdk-scorecard-config-file_{context}"]
11-
== Configuration file
12-
13-
The default location for the scorecard tool configuration is the `<project_dir>/.osdk-scorecard.*`. The following is an example of a YAML-formatted configuration file:
10+
The scorecard tool uses a configuration that allows you to configure internal plug-ins, as well as several global configuration options. Tests are driven by a configuration file named `config.yaml`, which is generated by the `make bundle` command, located in your `bundle/` directory:
1411

15-
.Scorecard configuration file
16-
[source,yaml]
12+
[source,terminal]
1713
----
18-
scorecard:
19-
output: json
20-
plugins:
21-
- basic: <1>
22-
cr-manifest:
23-
- "deploy/crds/cache.example.com_v1alpha1_memcached_cr.yaml"
24-
- "deploy/crds/cache.example.com_v1alpha1_memcachedrs_cr.yaml"
25-
- olm: <2>
26-
cr-manifest:
27-
- "deploy/crds/cache.example.com_v1alpha1_memcached_cr.yaml"
28-
- "deploy/crds/cache.example.com_v1alpha1_memcachedrs_cr.yaml"
29-
csv-path: "deploy/olm-catalog/memcached-operator/0.0.3/memcached-operator.v0.0.3.clusterserviceversion.yaml"
14+
./bundle
15+
...
16+
└── tests
17+
└── scorecard
18+
└── config.yaml
3019
----
31-
<1> `basic` tests configured to test two custom resources (CRs).
32-
<2> `olm` tests configured to test two CRs.
33-
34-
Configuration methods for global options take the following priority, highest to lowest:
35-
36-
Command arguments (if available) -> configuration file -> default
37-
38-
The configuration file must be in YAML format. As the configuration file might be extended to allow configuration of all `operator-sdk` subcommands in the future, the scorecard configuration must be under a `scorecard` subsection.
39-
40-
[NOTE]
41-
====
42-
Configuration file support is provided by the `viper` package. For more info on how `viper` configuration works, see the link:https://github.com/spf13/viper/blob/master/README.md[README].
43-
====
44-
45-
[id="osdk-scorecard-config-args_{context}"]
46-
== Command arguments
47-
48-
While most of the scorecard tool configuration is done using a configuration file, you can also use the following arguments:
49-
50-
.Scorecard tool arguments
51-
[cols="25%,20%,55%",options="header"]
52-
|===
53-
|Flag |Type |Description
54-
55-
|`--bundle`, `-b`
56-
|string
57-
|The path to a bundle directory used for the bundle validation test.
58-
59-
|`--config`
60-
|string
61-
|The path to the scorecard configuration file. The default is `<project_dir>/.osdk-scorecard`. The file type and extension must be `.yaml`. If a configuration file is not provided or found at the default location, the scorecard exits with an error.
62-
63-
|`--output`, `-o`
64-
|string
65-
|Output format. Valid options are `text` and `json`. The default format is `text`, which is designed to be a human readable format. The `json` format uses the JSON schema output format used for plug-ins defined later.
66-
67-
|`--kubeconfig`, `-o`
68-
|string
69-
|The path to the `kubeconfig` file. It sets the `kubeconfig` for internal plug-ins.
70-
71-
|`--version`
72-
|string
73-
|The version of scorecard to run. The default and only valid option is `v1alpha2`.
74-
75-
|`--selector`, `-l`
76-
|string
77-
|The label selector to filter tests on.
78-
79-
|`--list`, `-L`
80-
|bool
81-
|If `true`, only print the test names that would be run based on selector filtering.
82-
|===
83-
84-
[id="osdk-scorecard-config-file-options_{context}"]
85-
== Configuration file options
86-
87-
The scorecard configuration file provides the following options:
88-
89-
.Scorecard configuration file options
90-
[cols="25%,20%,55%",options="header"]
91-
|===
92-
|Option |Type |Description
93-
94-
|`bundle`
95-
|string
96-
|Equivalent of the `--bundle` flag. Operator Lifecycle Manager (OLM) bundle directory path, when specified, runs bundle validation.
97-
98-
|`output`
99-
|string
100-
|Equivalent of the `--output` flag. If this option is defined by both the configuration file and the flag, the flag value takes priority.
101-
102-
|`kubeconfig`
103-
|string
104-
|Equivalent of the `--kubeconfig` flag. If this option is defined by both the configuration file and the flag, the flag value takes priority.
105-
106-
|`plugins`
107-
|array
108-
|An array of plug-in names.
109-
|===
11020

111-
[id="osdk-scorecard-config-plugins_{context}"]
112-
=== Basic and OLM plug-ins
21+
.Example scorecard configuration file
22+
[source,yaml,subs="attributes+"]
23+
----
24+
kind: Configuration
25+
apiversion: scorecard.operatorframework.io/v1alpha3
26+
metadata:
27+
name: config
28+
stages:
29+
- parallel: true
30+
tests:
31+
- image: quay.io/operator-framework/scorecard-test:{osdk_ver}
32+
entrypoint:
33+
- scorecard-test
34+
- basic-check-spec
35+
labels:
36+
suite: basic
37+
test: basic-check-spec-test
38+
- image: quay.io/operator-framework/scorecard-test:{osdk_ver}
39+
entrypoint:
40+
- scorecard-test
41+
- olm-bundle-validation
42+
labels:
43+
suite: olm
44+
test: olm-bundle-validation-test
45+
----
11346

114-
The scorecard supports the internal `basic` and `olm` plug-ins, which are configured by a `plugins` section in the configuration file.
47+
The configuration file defines each test that scorecard can execute. The
48+
following fields of the scorecard configuration file define the test as follows:
11549

116-
.Plug-in options
117-
[cols="25%,20%,55%",options="header"]
50+
[cols="3,7",options="header"]
11851
|===
119-
|Option |Type |Description
120-
121-
|`cr-manifest`
122-
|[]string
123-
|The path(s) for CRs being tested. Required if `olm-deployed` is unset or `false`.
124-
125-
|`csv-path`
126-
|string
127-
|The path to the cluster service version (CSV) for the Operator. Required for OLM tests or if `olm-deployed` is set to `true`.
128-
129-
|`olm-deployed`
130-
|bool
131-
|Indicates that the CSV and relevant CRDs have been deployed onto the cluster by OLM.
132-
133-
|`kubeconfig`
134-
|string
135-
|The path to the `kubeconfig` file. If both the global `kubeconfig` and this field are set, this field is used for the plug-in.
136-
137-
|`namespace`
138-
|string
139-
|The namespace to run the plug-ins in. If unset, the default specified by the `kubeconfig` file is used.
140-
141-
|`init-timeout`
142-
|int
143-
|Time in seconds until a timeout during initialization of the Operator.
52+
|Configuration field |Description
14453

145-
|`crds-dir`
146-
|string
147-
|The path to the directory containing CRDs that must be deployed to the cluster.
54+
|`image`
55+
|Test container image name that implements a test
14856

149-
|`namespaced-manifest`
150-
|string
151-
|The manifest file with all resources that run within a namespace. By default, the scorecard combines the `service_account.yaml`, `role.yaml`, `role_binding.yaml`, and `operator.yaml` files from the `deploy` directory into a temporary manifest to use as the namespaced manifest.
57+
|`entrypoint`
58+
|Command and arguments that are invoked in the test image to execute a test
15259

153-
|`global-manifest`
154-
|string
155-
|The manifest containing required resources that run globally (not namespaced). By default, the scorecard combines all CRDs in the `crds-dir` directory into a temporary manifest to use as the global manifest.
60+
|`labels`
61+
|Scorecard-defined or custom labels that select which tests to run
15662
|===
15763

158-
[NOTE]
159-
====
160-
Currently, using the scorecard with a CSV does not permit multiple CR manifests to be set through the CLI, configuration file, or CSV annotations. You must tear down your Operator in the cluster, re-deploy, and re-run the scorecard for each CR that is tested.
161-
====
64+
:!osdk_ver:

0 commit comments

Comments
 (0)