diff --git a/README.md b/README.md index c87899ee..a08c1e4a 100644 --- a/README.md +++ b/README.md @@ -27,7 +27,7 @@ The KubePlus Operator does not need any admin-level permissions on a cluster for ### Resource utilization -KubePlus provides controls to set per-namespace resource quotas. It also monitors usage of CPU, memory, storage, and network traffic at the application instance level. The collected metrics are available in different formats and can be pulled into Prometheus for historical usage tracking. +KubePlus provides controls to set per-namespace resource quotas. It also monitors usage of CPU, memory, storage, and network traffic at the application instance level. The collected metrics are available in different formats and can be pulled into Prometheus for historical usage tracking. KubePlus also supports ability to define licenses for the CRDs. A license defines the number of application instances that can be created for that CRD, and an expiry date. KubePlus prevents creation of application instances if the license terms are not met. ### Upgrades @@ -37,7 +37,8 @@ A new version of an application can be deployed by updating the application Helm ### Customization -The spec properties of the Kubernetes CRD wrapping the application Helm chart are the fields defined in the chart’s values.yaml file. Application deployments can be customized by specifying different values for these spec properties. KubePlus also supports ability to define licenses for the CRDs. A license defines the number of application instances that can be created for that CRD, and an expiry date. KubePlus prevents creation of application instances if the license terms are not met. +The spec properties of the Kubernetes CRD wrapping the application Helm chart are the fields defined in the chart’s values.yaml file. Application deployments can be customized by specifying different values for these spec properties. + ## Demo diff --git a/tests/tests.py b/tests/tests.py index f6fe1308..cabcf818 100644 --- a/tests/tests.py +++ b/tests/tests.py @@ -260,6 +260,20 @@ def count_users(response): num_users += 1 return num_users + def cleanup(): + cmd = 'kubectl delete -f ./application-upgrade/resource-composition-localchart.yaml --kubeconfig=./application-upgrade/provider.conf' + TestKubePlus.run_command(cmd) + + # restore chart + data = None + with open('./application-upgrade/resource-composition-localchart.yaml', 'r') as f: + data = yaml.safe_load(f) + + data['spec']['newResource']['chartURL'] = 'file:///resource-composition-0.0.1.tgz' + + with open('./application-upgrade/resource-composition-localchart.yaml', 'w') as f: + yaml.safe_dump(data, f, default_flow_style=False) + # preliminary checks if not TestKubePlus._is_kubeplus_running(): print("KubePlus is not running. Deploy KubePlus and then run tests") @@ -298,7 +312,8 @@ def count_users(response): port = 5000 # let the app pods come up - time.sleep(30) + wait_time = 60 + time.sleep(wait_time) # grab name of deployed pod cmd = "kubectl get pods -n %s" % namespace @@ -312,6 +327,12 @@ def count_users(response): name = part.strip() break + print("Pod name:" + name) + if name == None: + print("Pod did not come up even after waiting " + str(wait_time) + " seconds.") + print("Skipping rest of the test.") + cleanup() + # port forwarding # CLI: kubectl port-forward pod-name -n bwa-tenant1 5000:5000 config.load_kube_config() @@ -320,6 +341,7 @@ def count_users(response): Configuration.set_default(c) api_instance = core_v1_api.CoreV1Api() + # https://github.com/kubernetes-client/python/blob/master/examples/pod_portforward.py pf = portforward(api_instance.connect_get_namespaced_pod_portforward, name, @@ -365,19 +387,7 @@ def count_users(response): response = make_http_request(port).strip(" ") num_users_second = count_users(response) - # cleanup - cmd = 'kubectl delete -f ./application-upgrade/resource-composition-localchart.yaml --kubeconfig=./application-upgrade/provider.conf' - TestKubePlus.run_command(cmd) - - # restore chart - data = None - with open('./application-upgrade/resource-composition-localchart.yaml', 'r') as f: - data = yaml.safe_load(f) - - data['spec']['newResource']['chartURL'] = 'file:///resource-composition-0.0.1.tgz' - - with open('./application-upgrade/resource-composition-localchart.yaml', 'w') as f: - yaml.safe_dump(data, f, default_flow_style=False) + cleanup() # check if upgrade worked self.assertTrue(num_users_second > num_users_first)