generated from konveyor/template-repo
-
Notifications
You must be signed in to change notification settings - Fork 7
🧪 add tests/ infra
#51
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
midays
wants to merge
7
commits into
konveyor-ecosystem:main
Choose a base branch
from
midays:add-e2e-test-setup
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 6 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
05d76d8
Update dependencies and add end-to-end tests for export command
midays e33e369
Refactor testing framework and enhance end-to-end tests
midays 6e65739
Add test configuration template and refactor cluster management
midays 2a6973e
Refactor cluster utility functions and relocate string containment check
midays da30d93
Add config.yaml existence check in test setup
midays dc96af5
Enhance test setup and error handling for configuration loading
midays 82576cf
Merge branch 'konveyor-ecosystem:main' into add-e2e-test-setup
midays File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -37,4 +37,7 @@ temp/ | |
| /export/ | ||
| /transform/ | ||
| *.export/ | ||
| *.transform/ | ||
| *.transform/ | ||
|
|
||
| # Test configuration | ||
| tests/config.yaml | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| # kubectl-migrate Test Configuration Template | ||
| # | ||
| # Copy this file to config.yaml and update with your cluster details: | ||
| # cp config.yaml.template config.yaml | ||
| # | ||
| # Then edit config.yaml with your actual cluster contexts from: | ||
| # kubectl config get-contexts | ||
|
|
||
| clusters: | ||
| # Source cluster configuration | ||
| source: | ||
| name: "src_cluster" # Friendly name for the cluster | ||
| context: "kind-src-cluster" # Context name from 'kubectl config get-contexts' | ||
|
|
||
| # Target cluster configuration | ||
| target: | ||
| name: "tgt_cluster" # Friendly name for the cluster | ||
| context: "kind-tgt-cluster" # Context name from 'kubectl config get-contexts' | ||
|
|
||
| # IMPORTANT: The 'context' value must exactly match the NAME column from: | ||
| # kubectl config get-contexts | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| package export_test | ||
|
|
||
| import ( | ||
| "testing" | ||
|
|
||
| . "github.com/onsi/ginkgo/v2" | ||
| . "github.com/onsi/gomega" | ||
|
|
||
| tests "github.com/konveyor-ecosystem/kubectl-migrate/tests" | ||
| ) | ||
|
|
||
| func TestExport(t *testing.T) { | ||
| RegisterFailHandler(Fail) | ||
| RunSpecs(t, "Export Suite") | ||
| } | ||
|
|
||
| // BeforeSuite - just call the shared setup | ||
| var _ = BeforeSuite(func() { | ||
| tests.SetupClusters() | ||
| }) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,34 @@ | ||
| package export_test | ||
|
|
||
| import ( | ||
| . "github.com/onsi/ginkgo/v2" | ||
| . "github.com/onsi/gomega" | ||
|
|
||
| tests "github.com/konveyor-ecosystem/kubectl-migrate/tests" | ||
| ) | ||
|
|
||
| var _ = Describe("Export Command Tests", func() { | ||
|
|
||
| It("should create a namespace on source cluster", func() { | ||
| testNs := "test-namespace-12345" | ||
|
|
||
| GinkgoWriter.Printf("Creating namespace: %s\n", testNs) | ||
|
|
||
| // Create namespace | ||
| err := tests.SrcCluster.CreateNamespace(testNs) | ||
| Expect(err).NotTo(HaveOccurred()) | ||
|
|
||
| GinkgoWriter.Println("✓ Namespace created") | ||
|
|
||
| // Verify it exists | ||
| result := tests.SrcCluster.RunKubectl("get", "namespace", testNs) | ||
| GinkgoWriter.Printf("Get namespace result:\n%s\n", result.Stdout) | ||
| Expect(result.Success()).To(BeTrue()) | ||
|
|
||
| // Cleanup | ||
| err = tests.SrcCluster.DeleteNamespace(testNs) | ||
| Expect(err).NotTo(HaveOccurred()) | ||
|
|
||
| GinkgoWriter.Println("✓ Namespace deleted") | ||
| }) | ||
| }) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,53 @@ | ||
| # Export Command E2E Tests | ||
|
|
||
| This directory contains end-to-end tests for the `kubectl migrate export` command. | ||
|
|
||
| ## Test Scenarios | ||
|
|
||
| ### 1. Basic Export Test | ||
| **Objective:** Verify that the export command successfully exports resources from a namespace | ||
|
|
||
| **Test Steps:** | ||
| 1. Set up a test Kubernetes cluster with sample resources | ||
| 2. Create a test namespace with sample deployments, services, and configmaps | ||
| 3. Run `kubectl migrate export <namespace> --export-dir <temp-dir>` | ||
| 4. Verify that: | ||
| - Export directory is created | ||
| - Resource YAML files are exported | ||
| - All expected resource types are present | ||
| - File contents are valid YAML | ||
|
|
||
| **Expected Result:** All resources from the namespace are exported to the specified directory | ||
|
|
||
| ### 2. Export with Invalid Namespace | ||
| **Objective:** Verify proper error handling when namespace doesn't exist | ||
|
|
||
| **Test Steps:** | ||
| 1. Run `kubectl migrate export non-existent-namespace --export-dir <temp-dir>` | ||
| 2. Verify that: | ||
| - Command returns an error | ||
| - Error message is informative | ||
| - No files are created | ||
|
|
||
| **Expected Result:** Command fails gracefully with appropriate error message | ||
|
|
||
| ### 3. Export with Custom Kubeconfig | ||
| **Objective:** Verify export works with custom kubeconfig file | ||
|
|
||
| **Test Steps:** | ||
| 1. Create a custom kubeconfig file | ||
| 2. Run `kubectl migrate export <namespace> --kubeconfig <custom-config> --export-dir <temp-dir>` | ||
| 3. Verify successful export using the specified kubeconfig | ||
|
|
||
| **Expected Result:** Resources are exported using the custom kubeconfig | ||
|
|
||
| ## Test Data | ||
|
|
||
| - Sample deployments: nginx, redis | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Just a question, do these deployments come from sample resources? (not sure about |
||
| - Sample services: nginx-service, redis-service | ||
| - Sample configmaps: app-config | ||
|
|
||
| ## Prerequisites | ||
|
|
||
| - Kind or Minikube cluster running | ||
| - Sample resources deployed (use `make resources-deploy`) | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just thinking if hardcoding a YAML config file is the best way, other parts of code recommend dynamic/unique names creation for namespaces (which looks great to me, mentioned in README), hardcoding it into file looks to add an unnecesarry complexity to me. Please correct me if it is better from QE perspective.