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

Implement runner for e2e tests #548

Merged
merged 96 commits into from
Jun 5, 2019
Merged

Implement runner for e2e tests #548

merged 96 commits into from
Jun 5, 2019

Conversation

sdudoladov
Copy link
Member

early work on #475

Sergey Dudoladov added 2 commits April 24, 2019 17:04
@sdudoladov sdudoladov changed the title [WIP] Implement runner for e2e tests Implement runner for e2e tests May 24, 2019
@sdudoladov
Copy link
Member Author

@CyberDem0n your review will be much appreciated

self. wait_for_pod_start("name=postgres-operator")
# HACK operator must register CRD / add existing PG clusters after pod start up
# for local execution ~ 10 seconds suffices
time.sleep(30)
Copy link
Member Author

Choose a reason for hiding this comment

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

this is sadly not a solution: Travis build fails but local one succeed.
does anyone has other ideas on how to circumvent the issue ?

e2e/run.sh Show resolved Hide resolved

# submit the most recent operator image built on the Docker host
with open("manifests/postgres-operator.yaml", 'r+') as f:
operator_deployment = yaml.load(f, Loader=yaml.Loader)
Copy link
Contributor

Choose a reason for hiding this comment

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

yaml.load is unsafe, it is better to use yaml.safe_load


with open("manifests/complete-postgres-manifest.yaml", 'r+') as f:
pg_manifest = yaml.load(f, Loader=yaml.Loader)
pg_manifest["metadata"]["namespace"] = self.namespace
Copy link
Contributor

Choose a reason for hiding this comment

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

IIRC, one can specify the namespace as kubectl parameters, kubectl create -f foo.yaml --namespace=bar

replica_pod_nodes = []
podsList = self.api.core_v1.list_namespaced_pod(namespace, label_selector=pod_labels)
for pod in podsList.items:
if ('spilo-role', 'master') in pod.metadata.labels.items():
Copy link
Contributor

Choose a reason for hiding this comment

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

if pod.metadata.labels.get('spilo-role') == 'master'

k8s.wait_for_pod_start('spilo-role=replica')

new_master_node, new_replica_nodes = k8s.get_spilo_nodes(labels)
self.assertTrue(current_master_node != new_master_node,
Copy link
Contributor

Choose a reason for hiding this comment

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

assertNotEqual

self.assertTrue(job.metadata.name == "logical-backup-acid-minimal-cluster",
"Expected job name {}, found {}"
.format("logical-backup-acid-minimal-cluster", job.metadata.name))
self.assertTrue(job.spec.schedule == schedule,
Copy link
Contributor

Choose a reason for hiding this comment

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

assertEqual

e2e/tests/test_e2e.py Show resolved Hide resolved

labels = 'version=acid-minimal-cluster'
while self.count_pods_with_label(labels) != number_of_instances:
pass
Copy link
Contributor

Choose a reason for hiding this comment

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

sleep?

e2e/tests/test_e2e.py Show resolved Hide resolved

def wait_for_logical_backup_job(self, expected_num_of_jobs):
while (len(self.get_logical_backup_job().items) != expected_num_of_jobs):
pass
Copy link
Contributor

Choose a reason for hiding this comment

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

sleep?

current_master_node, failover_targets = k8s.get_spilo_nodes(labels)
num_replicas = len(failover_targets)

# if all pods live on the same node, failover will happen to other worker(s)
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'd expand this comment to better explain why we can have len(failover_targets) == 0

  1. single pod clusters (e.g. in test environments) - a new master pod must be started on another worker node meaning longer downtimes for such clusters
  2. clusters that have master/replica on the same node due to unused pod anti-affinity -> a new replica must be started on another worker node for a failover to take place.
  3. other clusters -> failover takes place / failover_targets not empty

e2e/tests/test_e2e.py Outdated Show resolved Hide resolved
@sdudoladov
Copy link
Member Author

👍

1 similar comment
@FxKu
Copy link
Member

FxKu commented Jun 5, 2019

👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants