|
1 | 1 | package kcp_test |
2 | 2 |
|
3 | 3 | import ( |
| 4 | + "context" |
| 5 | + "encoding/json" |
4 | 6 | "errors" |
5 | 7 | "fmt" |
6 | 8 | "maps" |
@@ -108,7 +110,20 @@ var _ = Describe("Kyma sync into Remote Cluster", Ordered, func() { |
108 | 110 | Should(Succeed()) |
109 | 111 | }) |
110 | 112 |
|
| 113 | + It("ModuleReleaseMeta should be created in KCP", func() { |
| 114 | + registerDescriptor(moduleInSKROCMName, moduleVersion) |
| 115 | + Eventually(configureKCPModuleReleaseMeta, Timeout, Interval).WithArguments(moduleInSKR.Name).Should(Succeed()) |
| 116 | + registerDescriptor(moduleInKCPOCMName, moduleVersion) |
| 117 | + Eventually(configureKCPModuleReleaseMeta, Timeout, Interval).WithArguments(moduleInKCP.Name).Should(Succeed()) |
| 118 | + }) |
| 119 | + |
111 | 120 | It("ModuleTemplates should be synchronized in both clusters", func() { |
| 121 | + //time.Sleep(15 * time.Second) |
| 122 | + //PrintKymas(ctx, kcpClient) |
| 123 | + //PrintModuleTemplates(ctx, kcpClient) |
| 124 | + //PrintModuleReleaseMetas(ctx, kcpClient) |
| 125 | + //PrintManifests(ctx, kcpClient) |
| 126 | + |
112 | 127 | By("ModuleTemplate exists in KCP cluster") |
113 | 128 | Eventually(ModuleTemplateExists, Timeout, Interval). |
114 | 129 | WithArguments(ctx, kcpClient, moduleInKCP, kyma). |
@@ -150,12 +165,6 @@ var _ = Describe("Kyma sync into Remote Cluster", Ordered, func() { |
150 | 165 | Should(Succeed()) |
151 | 166 | }) |
152 | 167 |
|
153 | | - It("ModuleReleaseMeta should be created in KCP", func() { |
154 | | - registerDescriptor(moduleInSKROCMName, moduleVersion) |
155 | | - Eventually(configureKCPModuleReleaseMeta, Timeout, Interval).WithArguments(moduleInSKR.Name).Should(Succeed()) |
156 | | - registerDescriptor(moduleInKCPOCMName, moduleVersion) |
157 | | - Eventually(configureKCPModuleReleaseMeta, Timeout, Interval).WithArguments(moduleInKCP.Name).Should(Succeed()) |
158 | | - }) |
159 | 168 |
|
160 | 169 | It("Enable module in SKR Kyma CR", func() { |
161 | 170 | By("add module to remote Kyma") |
@@ -585,3 +594,69 @@ func assertCrdGenerationAnnotations(kcpKyma *v1beta2.Kyma, annotationName string |
585 | 594 | } |
586 | 595 | return nil |
587 | 596 | } |
| 597 | + |
| 598 | +func PrintModuleTemplates(ctx context.Context, clnt client.Client) { |
| 599 | + fmt.Printf("\n#### ModuleTemplates: ##########################################################\n") |
| 600 | + moduletemplates := v1beta2.ModuleTemplateList{} |
| 601 | + if err := clnt.List(ctx, &moduletemplates); err != nil { |
| 602 | + fmt.Printf("%s", fmt.Errorf("while listing ModuleTemplates: %w", err)) |
| 603 | + } |
| 604 | + for i, mtemplate := range moduletemplates.Items { |
| 605 | + fmt.Printf("ModuleTemplate %d: name: %s, spec.moduleName: %q, spec.version: %q\n", |
| 606 | + i, mtemplate.Name, mtemplate.Spec.ModuleName, mtemplate.Spec.Version) |
| 607 | + } |
| 608 | + fmt.Printf("################################################################################\n") |
| 609 | +} |
| 610 | + |
| 611 | +func PrintModuleReleaseMetas(ctx context.Context, clnt client.Client) { |
| 612 | + fmt.Printf("\n#### ModuleReleaseMetas: #######################################################\n") |
| 613 | + modulereleasemetas := v1beta2.ModuleReleaseMetaList{} |
| 614 | + if err := clnt.List(ctx, &modulereleasemetas); err != nil { |
| 615 | + fmt.Printf("%s", fmt.Errorf("while listing ModuleReleaseMetas: %w", err)) |
| 616 | + } |
| 617 | + for i, mrm := range modulereleasemetas.Items { |
| 618 | + fmt.Printf("ModuleReleaseMeta %d: name: %s, spec.moduleName: %#v, spec.ocmComponentName: %s, channel mapping:", |
| 619 | + i, mrm.Name, mrm.Spec.ModuleName, mrm.Spec.OcmComponentName) |
| 620 | + for _, mapping := range mrm.Spec.Channels { |
| 621 | + fmt.Printf(" %s->%s;", mapping.Channel, mapping.Version) |
| 622 | + } |
| 623 | + fmt.Println() |
| 624 | + } |
| 625 | + fmt.Printf("################################################################################\n") |
| 626 | +} |
| 627 | + |
| 628 | +func PrintManifests(ctx context.Context, clnt client.Client) { |
| 629 | + fmt.Printf("\n#### Manifests: ################################################################\n") |
| 630 | + manifests := v1beta2.ManifestList{} |
| 631 | + if err := clnt.List(ctx, &manifests); err != nil { |
| 632 | + fmt.Printf("%s", fmt.Errorf("while listing Manifests: %w", err)) |
| 633 | + } |
| 634 | + for i, manifest := range manifests.Items { |
| 635 | + fmt.Printf("Manifest %d: name: %s, spec.config: %#v, status.operation: %s\n", |
| 636 | + i, manifest.Name, manifest.Spec.Config, manifest.Status.Operation) |
| 637 | + } |
| 638 | + fmt.Printf("################################################################################\n") |
| 639 | +} |
| 640 | + |
| 641 | +func PrintKymas(ctx context.Context, clnt client.Client) { |
| 642 | + fmt.Printf("\n#### Kymas: ####################################################################\n") |
| 643 | + kymas := v1beta2.KymaList{} |
| 644 | + if err := clnt.List(ctx, &kymas); err != nil { |
| 645 | + fmt.Printf("%s", fmt.Errorf("while listing Kymas: %w", err)) |
| 646 | + } |
| 647 | + for i, kyma := range kymas.Items { |
| 648 | + modules := []string{} |
| 649 | + for _, m := range kyma.Spec.Modules { |
| 650 | + modules = append(modules, m.Name) |
| 651 | + } |
| 652 | + fmt.Printf("Kyma %d: name: %s, spec.modules: %v, status.state: %s, status.operation: %s\n", |
| 653 | + i, kyma.Name, modules, kyma.Status.State, kyma.Status.Operation) |
| 654 | + |
| 655 | + ser, _ := json.MarshalIndent(kyma.Spec, " ==> ", " ") |
| 656 | + fmt.Printf("\nKyma %d spec: %s\n", i, string(ser)) |
| 657 | + |
| 658 | + ser, _ = json.MarshalIndent(kyma.Status, " ==> ", " ") |
| 659 | + fmt.Printf("\nKyma %d status: %s\n", i, string(ser)) |
| 660 | + } |
| 661 | + fmt.Printf("################################################################################\n") |
| 662 | +} |
0 commit comments