Skip to content
This repository has been archived by the owner on Dec 16, 2024. It is now read-only.

updating e2e to adapt to mpas-product-controller with cuelang #156

Merged
merged 4 commits into from
Dec 4, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
54 changes: 12 additions & 42 deletions e2e/create_test_component.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,19 +75,14 @@ func podinfoBackend(t *testing.T) setup.Component {
t.Fatal("failed to read config file: %w", err)
}

readmeContent, err := os.ReadFile(filepath.Join("testdata", "podinfo", "backend", "README.md"))
if err != nil {
t.Fatal("failed to read readme file: %w", err)
}

manifestContent, err := os.ReadFile(filepath.Join("testdata", "podinfo", "backend", "manifests.tar"))
if err != nil {
t.Fatal("failed to read manifest file: %w", err)
}

validationContent, err := os.ReadFile(filepath.Join("testdata", "podinfo", "backend", "validation.rego"))
schemaContent, err := os.ReadFile(filepath.Join("testdata", "podinfo", "backend", "schema.cue"))
if err != nil {
t.Fatal("failed to read validation file: %w", err)
t.Fatal("failed to read schema file: %w", err)
}

return setup.Component{
Expand All @@ -102,8 +97,8 @@ func podinfoBackend(t *testing.T) setup.Component {
Type: "configdata.ocm.software",
}),
shared.BlobResource(shared.Resource{
Name: "instructions",
Data: string(readmeContent),
Name: "schema",
Data: string(schemaContent),
Type: "PlainText",
}),
shared.ImageRefResource("ghcr.io/stefanprodan/podinfo:6.2.0", shared.Resource{
Expand All @@ -116,11 +111,6 @@ func podinfoBackend(t *testing.T) setup.Component {
Data: string(manifestContent),
Type: "kustomize.ocm.fluxcd.io",
}),
shared.BlobResource(shared.Resource{
Name: "validation",
Data: string(validationContent),
Type: "validator.mpas.ocm.software",
}),
},
}
}
Expand All @@ -133,19 +123,14 @@ func podinfoFrontend(t *testing.T) setup.Component {
t.Fatal("failed to read config file: %w", err)
}

readmeContent, err := os.ReadFile(filepath.Join("testdata", "podinfo", "frontend", "README.md"))
if err != nil {
t.Fatal("failed to read readme file: %w", err)
}

manifestContent, err := os.ReadFile(filepath.Join("testdata", "podinfo", "frontend", "manifests.tar"))
if err != nil {
t.Fatal("failed to read manifest file: %w", err)
}

validationContent, err := os.ReadFile(filepath.Join("testdata", "podinfo", "frontend", "validation.rego"))
schemaContent, err := os.ReadFile(filepath.Join("testdata", "podinfo", "frontend", "schema.cue"))
if err != nil {
t.Fatal("failed to read validation file: %w", err)
t.Fatal("failed to read schema file: %w", err)
}

return setup.Component{
Expand All @@ -160,8 +145,8 @@ func podinfoFrontend(t *testing.T) setup.Component {
Type: "configdata.ocm.software",
}),
shared.BlobResource(shared.Resource{
Name: "instructions",
Data: string(readmeContent),
Name: "schema",
Data: string(schemaContent),
Type: "PlainText",
}),
shared.ImageRefResource("ghcr.io/stefanprodan/podinfo:6.2.0", shared.Resource{
Expand All @@ -174,11 +159,6 @@ func podinfoFrontend(t *testing.T) setup.Component {
Data: string(manifestContent),
Type: "kustomize.ocm.fluxcd.io",
}),
shared.BlobResource(shared.Resource{
Name: "validation",
Data: string(validationContent),
Type: "validator.mpas.ocm.software",
}),
},
}
}
Expand All @@ -191,19 +171,14 @@ func podinfoRedis(t *testing.T) setup.Component {
t.Fatal("failed to read config file: %w", err)
}

readmeContent, err := os.ReadFile(filepath.Join("testdata", "podinfo", "redis", "README.md"))
if err != nil {
t.Fatal("failed to read readme file: %w", err)
}

manifestContent, err := os.ReadFile(filepath.Join("testdata", "podinfo", "redis", "manifests.tar"))
if err != nil {
t.Fatal("failed to read manifest file: %w", err)
}

validationContent, err := os.ReadFile(filepath.Join("testdata", "podinfo", "redis", "validation.rego"))
schemaContent, err := os.ReadFile(filepath.Join("testdata", "podinfo", "redis", "schema.cue"))
if err != nil {
t.Fatal("failed to read validation file: %w", err)
t.Fatal("failed to read schema file: %w", err)
}

return setup.Component{
Expand All @@ -218,8 +193,8 @@ func podinfoRedis(t *testing.T) setup.Component {
Type: "configdata.ocm.software",
}),
shared.BlobResource(shared.Resource{
Name: "instructions",
Data: string(readmeContent),
Name: "schema",
Data: string(schemaContent),
Type: "PlainText",
}),
shared.ImageRefResource("redis:6.0.1", shared.Resource{
Expand All @@ -232,11 +207,6 @@ func podinfoRedis(t *testing.T) setup.Component {
Data: string(manifestContent),
Type: "kustomize.ocm.fluxcd.io",
}),
shared.BlobResource(shared.Resource{
Name: "validation",
Data: string(validationContent),
Type: "validator.mpas.ocm.software",
}),
},
}
}
2 changes: 1 addition & 1 deletion e2e/product_controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ func newProductFeature(projectRepoName string) *features.FeatureBuilder {
Path: "products/" + prodDepGenName + "/product-deployment.yaml"},
assess.File{
Repository: projectRepoName,
Path: "products/" + prodDepGenName + "/values.yaml"},
Path: "products/" + prodDepGenName + "/config.cue"},
)).
Assess(fmt.Sprintf("ProductDeployment %s exists in namespace %s", prodDepGenName, projectRepoName), checkIfProductDeploymentExists(prodDepGenName, projectRepoName)).
Assess(fmt.Sprintf("ProductDeploymentPipelines exist in namespace %s", projectRepoName), checkIfProductDeploymentPipelinesExist(projectRepoName, pipelineNames)).
Expand Down
10 changes: 0 additions & 10 deletions e2e/testdata/podinfo/backend/README.md

This file was deleted.

20 changes: 20 additions & 0 deletions e2e/testdata/podinfo/backend/schema.cue
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
// # Configuration Instructions

// This is the api service of the podinfo microservices application.

// The following parameters are available for configuration:

// | Parameter | Type | Default | Description |
// |-----------|---------|------------------|----------------------------------------|
// | replicas | integer | 2 | Number of replicas for the application |
// | cacheAddr | string | tcp://redis:6379 | Address of the cache server |

#SchemaVersion: "v1.0.0"

// an object named after the target resource is expected in order to pick parameters from it.
backend: {
// this field has a default value of 2 and must be less than 4
replicas: *2 | int & >0 & <4
// this field is required and must match the regex
cacheAddr: *"tcp://redis:6379" | string & =~"^tcp://[a-z.-]+:\\d+"
}
31 changes: 0 additions & 31 deletions e2e/testdata/podinfo/backend/validation.rego

This file was deleted.

12 changes: 0 additions & 12 deletions e2e/testdata/podinfo/frontend/README.md

This file was deleted.

22 changes: 22 additions & 0 deletions e2e/testdata/podinfo/frontend/schema.cue
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
// # Configuration Instructions

// This is the web frontend for the podinfo microservices application.

// The following parameters are available for configuration:

// | Parameter | Type | Default | Description |
// |-----------|---------|---------------|--------------------------------------------|
// | color | string | red | The background color of the website |
// | message | string | Hello, world! | The message to display |
// | replicas | integer | 1 | The number of replicas for the application |

#SchemaVersion: "v1.0.0"

// an object named after the target resource is expected in order to pick parameters from it.
frontend: {
color: *"red" | "blue" | "green" | "yellow"
// this field is required
message: *"Hello, world!" | string
// this field has a default value of 1 and must be an integer between 1 and 2
replicas: *1 | int & >0 & <2
}
32 changes: 0 additions & 32 deletions e2e/testdata/podinfo/frontend/validation.rego

This file was deleted.

10 changes: 0 additions & 10 deletions e2e/testdata/podinfo/redis/README.md

This file was deleted.

17 changes: 17 additions & 0 deletions e2e/testdata/podinfo/redis/schema.cue
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
// # Configuration Instructions

// This is the cache for the podinfo microservices application.

// The following parameters are available for configuration:

// | Parameter | Type | Default | Description |
// |-----------|------|---------|--------------------------------------|
// | replicas | int | 1 | The number of replicas for the cache |

#SchemaVersion: "v1.0.0"

// an object named after the target resource is expected in order to pick parameters from it.
redis: {
// this field has a default value of 1 and must equal to 1
replicas: *1 | 1
}
13 changes: 0 additions & 13 deletions e2e/testdata/podinfo/redis/validation.rego

This file was deleted.

27 changes: 6 additions & 21 deletions e2e/testdata/product_description.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,8 @@ spec:
version: 1.0.0
referencePath:
- name: backend
readme:
name: instructions
version: 1.0.0
referencePath:
- name: backend
validation:
name: validation
schema:
name: schema
version: 1.0.0
referencePath:
- name: backend
Expand All @@ -51,13 +46,8 @@ spec:
version: 1.0.0
referencePath:
- name: frontend
readme:
name: instructions
version: 1.0.0
referencePath:
- name: frontend
validation:
name: validation
schema:
name: schema
version: 1.0.0
referencePath:
- name: frontend
Expand All @@ -79,13 +69,8 @@ spec:
version: 1.0.0
referencePath:
- name: redis
readme:
name: instructions
version: 1.0.0
referencePath:
- name: redis
validation:
name: validation
schema:
name: schema
version: 1.0.0
referencePath:
- name: redis
Expand Down
1 change: 0 additions & 1 deletion podinfo_component/config/schema.cue
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,3 @@ podinfo: {
// this field is optional
serviceAccountName?: string
}

Loading