Skip to content
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

Pytest-bdd setup and helm_install BDD test #352

Open
wants to merge 6 commits into
base: develop
Choose a base branch
from

Conversation

niladrih
Copy link
Member

@niladrih niladrih commented Oct 8, 2023

Adds python setup for bdd tests, and adds a bdd test for testing helm install on the helm chart.

Description

Changes:

  • adds pytest setup
  • adds common python module
  • adds helm install gherkin feature file
  • adds helm install python file
  • adds venv setup file to populate bdd.pth file (an alternative to setting PYTHONPATH)
  • minor changes to minikube setup (none mode)

TODO:

  • TODO: minikube kvm mode
  • TODO: Jenkinsfile integration for CI runs
  • TODO: README changes with pytest instructions

Motivation and Context

Testing...

Regression

No

And one promtail Kubernetes DaemonSet for which all replicas are Available
And one etcd Kubernetes StatefulSet for which all replicas are Available
And one loki Kubernetes StatefulSet for which all replicas are Available
And one nats Kubernetes StatefulSet for which all replicas are Available
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you should use Scenario Outline and Examples here

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah. We should use Scenario Outline for these kind of test case.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've found it difficult to implement the feature file using 'Scenario Outline' and 'Examples'. I'd like some help in this matter.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Alright, thanks.

Given: A Kubernetes cluster

Scenario: Mayastor helm chart install
Given worker nodes on the kubernetes cluster are labelled with the label 'openebs.io/engine=mayastor'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Given worker nodes on the kubernetes cluster are labelled with the label 'openebs.io/engine=mayastor'
Given the worker nodes are labelled with the label 'openebs.io/engine=mayastor'

Scenario: Mayastor helm chart install
Given worker nodes on the kubernetes cluster are labelled with the label 'openebs.io/engine=mayastor'
And a kubernetes namespace to install the Mayastor helm chart
When the Mayastor helm chart is installed with callhome disabled and at most 3 replicas of etcd
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should callhome be enabled but with sendReport false?

@given('a kubernetes namespace to install the Mayastor helm chart')
def a_kubernetes_namespace_to_install_the_mayastor_helm_chart():
"""a kubernetes namespace to install the Mayastor helm chart."""
kube_config.load_kube_config()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should there create_namespace, label et all be part of a common thing? Seems like we'd be doing this a lot?

niladrih and others added 6 commits October 9, 2023 13:53
Signed-off-by: Niladri Halder <niladri.halder26@gmail.com>
The set options set in these scripts may apply to other scripts
when they import these ones. The importing scripts should have
the freedom to decide its set options, so these scripts unset
their options after their function definitions.

Signed-off-by: Niladri Halder <niladri.halder26@gmail.com>
Signed-off-by: Niladri Halder <niladri.halder26@gmail.com>
This lets the cleanup script avoid running the cleanup more than once.
Also adds statuses 'Initializing', 'Ready', 'CleaningUp' and 'CleanupCompleted'.
Cleanup only works on 'Ready' cleanup_config.yaml files.
Also removes 'die' method and uses 'log_fatal' from scripts/utils/log.sh instead
for minikube-cleanup

Signed-off-by: Niladri Halder <niladri.halder26@gmail.com>
Co-authored-by: Vandana Varakantham <yvandana.varakantham@datacore.com>
Co-authored-by: Tiago Castro <tiagolobocastro@gmail.com>
Signed-off-by: Niladri Halder <niladri.halder26@gmail.com>
Signed-off-by: Niladri Halder <niladri.halder26@gmail.com>
@niladrih niladrih force-pushed the helm-install-bdd branch 2 times, most recently from 984ace6 to 307da83 Compare October 9, 2023 13:57
@niladrih niladrih added the wip Indicates that this is a work in progress label Oct 9, 2023
And one promtail Kubernetes DaemonSet for which all replicas are Available
And one etcd Kubernetes StatefulSet for which all replicas are Available
And one loki Kubernetes StatefulSet for which all replicas are Available
And one nats Kubernetes StatefulSet for which all replicas are Available
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah. We should use Scenario Outline for these kind of test case.

def predicate() -> bool:
return deployment_is_available(pytest.helm_release + "-csi-controller", pytest.helm_namespace)

assert retry_predicate(predicate, pytest.max_retries, pytest.retry_seconds)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: You can also use pytest modules to retry. Something like this on top of the method @retry(wait_fixed=100, stop_max_attempt_number=50)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
wip Indicates that this is a work in progress
Projects
None yet
3 participants