Skip to content

Commit f9cc878

Browse files
committed
Added comments;Added README
Signed-off-by: jubittajohn <[email protected]>
1 parent dbb8fcc commit f9cc878

File tree

7 files changed

+71
-9
lines changed

7 files changed

+71
-9
lines changed

test/operator-e2e/README.md

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
# Cross-component E2E for operator framework
2+
3+
This is a cross-component demo with all OLM v1 repositories. The ginkgo test does the following:
4+
- Automates the creation of plain+v0 bundles and FBCs for a set of bundle manifest directories.
5+
- Creates, upgrades and deletes a plain+v0 operator.
6+
7+
## Objective
8+
- Development on OLM v1 is split across multiple repositories, and the list of relevant repositories may grow over time. While we have demos showing improvements in functionality of components over time, it can be difficult to have a picture of the state of OLM v1 at any given time for someone not following its development closely. Having a single source to look for OLM v1 behavior can provide more clarity about the state of the project.
9+
- With the scale of the OLM v1 project, it is useful to have a means to test components in the operator development + lifecycle pipeline together to create a more cohesive experience for all users.
10+
11+
## Getting Started
12+
13+
- Plain bundle manifests are taken as input.
14+
15+
- The plain bundle manifest directory taken as input should follow the below directory structure:
16+
```
17+
bundles/
18+
└── plain-v0/
19+
├── plain.v0.1.0/
20+
│ ├── manifests
21+
│ └── Dockerfile
22+
└── plain.v0.1.1/
23+
├── manifests
24+
└── Dockerfile
25+
```
26+
- The bundles should present in the testdata folder.
27+
- The bundle paths and bundle image reference is hard coded in the test.
28+
29+
- After the bundle image is created and loaded, the FBC is created by accepting the required information in a config file named `catalog_config.yaml` in the directory `test/operator-e2e/config`.
30+
31+
- Example `catalog_config.yaml` file:
32+
```
33+
schema: catalog-config
34+
packageName: plain
35+
channelData:
36+
- channelName: foo
37+
channelEntries:
38+
- entryVersion: 0.1.0
39+
replaces: null
40+
skipRange: null
41+
skips:
42+
- null
43+
bundleData:
44+
- bundleImage: foobar:v0.1.0
45+
bundleVersion: 0.1.0
46+
```
47+
- The generated FBC will be present in the directory structure: `testdata/catalogs/plainv0-test-catalog`.
48+
- The Dockerfile is generated and the FBC image is built and loaded.
49+
- The output catalog path, catalog name, catalog image reference are hard-coded in the test.
50+
- The FBC generated is validated using opm.
51+
52+
- The FBC image is then used to create an operator.
53+
- Based on the catalog data, we hard code the package names and their version that is to be installed and upgraded.

test/operator-e2e/config/catalog_config.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,12 @@ channelData:
66
- entryVersion: 0.1.0
77
replaces: null
88
skips:
9-
- 0.1.1
9+
- null
1010
skipRange: null
1111
- entryVersion: 0.1.1
12-
replaces: 0.1.0
12+
replaces: null
1313
skips:
14-
- null
14+
- 0.1.0
1515
skipRange: null
1616
- channelName: foo
1717
channelEntries:

test/operator-e2e/config/read_config.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ type Config struct {
3636
BundleData []BundleData `json:"bundleData"`
3737
}
3838

39+
// Reads the catalog-config.yaml and maps it to the above structs
3940
func ReadFile(f string) (*Config, error) {
4041
b, err := readFile(f)
4142
if err != nil {

test/operator-e2e/create_fbc.go

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ const (
2020
BundleMediatype = "plain+v0"
2121
)
2222

23+
// Reads the catalog-config and creates the FBC by calling functions for forming the package, channel and bundles.
2324
func CreateFBC(configFilePath string) (*declcfg.DeclarativeConfig, error) {
2425
config, err := config.ReadFile(configFilePath)
2526
if err != nil {
@@ -38,6 +39,7 @@ func CreateFBC(configFilePath string) (*declcfg.DeclarativeConfig, error) {
3839
return &fbc, nil
3940
}
4041

42+
// Forms package schema for the FBC
4143
func formPackage(config config.Config) declcfg.Package {
4244
packageFormed := declcfg.Package{
4345
Schema: SchemaPackage,
@@ -47,6 +49,7 @@ func formPackage(config config.Config) declcfg.Package {
4749
return packageFormed
4850
}
4951

52+
// Forms channel schema for the FBC
5053
func formChannel(config config.Config) []declcfg.Channel {
5154
channelFormed := make([]declcfg.Channel, 0, len(config.ChannelData))
5255
for _, channel := range config.ChannelData {
@@ -61,6 +64,7 @@ func formChannel(config config.Config) []declcfg.Channel {
6164
return channelFormed
6265
}
6366

67+
// Forms the uprade graph for the FBC
6468
func formChannelEntries(pkgName string, channel config.ChannelData) []declcfg.ChannelEntry {
6569
channelEntries := make([]declcfg.ChannelEntry, 0, len(channel.ChannelEntries))
6670
for _, channelEntry := range channel.ChannelEntries {
@@ -73,7 +77,7 @@ func formChannelEntries(pkgName string, channel config.ChannelData) []declcfg.Ch
7377
if len(channelEntry.Skips) != 0 {
7478
for _, s := range channelEntry.Skips {
7579
if s != "" {
76-
skip = append(skip, s)
80+
skip = append(skip, pkgName+"."+s)
7781
}
7882
}
7983
}
@@ -87,6 +91,7 @@ func formChannelEntries(pkgName string, channel config.ChannelData) []declcfg.Ch
8791
return channelEntries
8892
}
8993

94+
// Forms bundle schema for the FBC
9095
func formBundle(config config.Config) []declcfg.Bundle {
9196
bundleFormed := make([]declcfg.Bundle, 0, len(config.BundleData))
9297
for _, bundle := range config.BundleData {
@@ -111,7 +116,8 @@ func formBundle(config config.Config) []declcfg.Bundle {
111116
return bundleFormed
112117
}
113118

114-
func WriteFBC(fbc declcfg.DeclarativeConfig, fbcFilePath string, fbcFileName string) error {
119+
// Writes the formed FBC into catalog.yaml file
120+
func WriteFBC(fbc declcfg.DeclarativeConfig, fbcFilePath, fbcFileName string) error {
115121
var buf bytes.Buffer
116122
err := declcfg.WriteYAML(fbc, &buf)
117123
if err != nil {

test/operator-e2e/generate_dockerfile.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@ import (
66
"text/template"
77
)
88

9-
func generateDockerFile(dockerFilePath string, yamlFolderName string, dockerFileName string) error {
9+
// generates Dockerfile and its contents for a given yaml file
10+
func generateDockerFile(dockerFilePath, yamlFolderName, dockerFileName string) error {
1011
t, err := template.New("dockerfile").Parse(dockerfileTmpl)
1112
if err != nil {
1213
panic(err)

test/operator-e2e/operator_test.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ var (
4242
err error
4343
ctx context.Context
4444
bundleInfo = []BundleInfo{
45-
{
45+
{ // The bundle directories of the plain bundles whose image is to be created and pushed along with the image reference
4646
BundleImageRef: "localhost/testdata/bundles/plain-v0/plain:v0.1.0",
4747
BundleDirectory: "plain.v0.1.0",
4848
},
@@ -102,6 +102,7 @@ var _ = BeforeSuite(func() {
102102

103103
var _ = AfterSuite(func() {
104104
Eventually(func(g Gomega) {
105+
// Deleting the catalog object and checking if the deletion was successful
105106
err = deleteAndCheckCatalogDeleted(operatorCatalog)
106107
g.Expect(errors.IsNotFound(err)).To(BeTrue())
107108
}).Should(Succeed())

test/operator-e2e/read_manifests.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@ type Object struct {
1919
} `yaml:"metadata"`
2020
}
2121

22-
// collects the Kubernetes objects present in the bundle manifest folder
23-
func collectKubernetesObjects(packageName string, version string) ([]Object, error) {
22+
// collects the Kubernetes objects present in the bundle manifest folder for a particular package and its version
23+
func collectKubernetesObjects(packageName, version string) ([]Object, error) {
2424
objects := []Object{}
2525

2626
bundleManifestPath := filepath.Join(bundlePath, packageName+".v"+version, "manifests")

0 commit comments

Comments
 (0)