def test_install_wait(self): expect_cmd( r'helm repo add es-repo https://repo.lightbend.com/helm-charts') expect_cmd(r'helm repo update') expect_cmd(r'helm status enterprise-suite', returncode=-1) expect_cmd(r'kubectl get pvc --namespace=lightbend --no-headers') expect_cmd( r'helm install es-repo/enterprise-suite --name enterprise-suite --namespace lightbend --devel --values \S+ --wait' ) # Verify happens automatically when --wait is provided expect_cmd( r'kubectl --namespace lightbend get deploy/es-console --no-headers', stdout='es-console 1 1 1 1 15m') expect_cmd( r'kubectl --namespace lightbend get deploy/grafana-server --no-headers', stdout='grafana-server 1 1 1 1 15m') expect_cmd( r'kubectl --namespace lightbend get deploy/prometheus-kube-state-metrics --no-headers', stdout='prometheus-kube-state-metrics 1 1 1 1 15m') expect_cmd( r'kubectl --namespace lightbend get deploy/prometheus-server --no-headers', stdout='prometheus-server 2 2 2 2 15m') expect_cmd( r'kubectl --namespace lightbend get deploy/prometheus-alertmanager --no-headers', stdout='prometheus-alertmanager 1 1 1 1 15m') lbc.main([ 'install', '--skip-checks', '--creds=' + self.creds_file, '--wait' ])
def test_export_yaml_local_chart(self): self.expect_helm_version() self.expect_helm_template(chart='chart.tgz') lbc.main([ 'install', '--namespace=lightbend', '--skip-checks', '--export-yaml=console', '--local-chart=chart.tgz' ])
def test_verify_fail(self): expect_cmd( r'kubectl --namespace monitoring get deploy/console-backend --no-headers', stdout='console-backend 2 2 2 2 15m') expect_cmd( r'kubectl --namespace monitoring get deploy/console-frontend --no-headers', stdout='console-frontend 1 1 1 1 15m') # Grafana is not running expect_cmd( r'kubectl --namespace monitoring get deploy/grafana --no-headers', stdout='grafana 1 1 1 0 15m') expect_cmd( r'kubectl --namespace monitoring get deploy/prometheus-kube-state-metrics --no-headers', stdout='prometheus-kube-state-metrics 1 1 1 1 15m') # Installer will check old deployment names if the new ones fail expect_cmd( r'kubectl --namespace monitoring get deploy/es-console --no-headers', stdout='console-backend 2 2 2 2 15m') # Grafana is not running expect_cmd( r'kubectl --namespace monitoring get deploy/grafana-server --no-headers', stdout='console-frontend 1 1 1 0 15m') expect_cmd( r'kubectl --namespace monitoring get deploy/prometheus-server --no-headers', stdout='grafana 1 1 1 1 15m') expect_cmd( r'kubectl --namespace monitoring get deploy/prometheus-kube-state-metrics --no-headers', stdout='prometheus-kube-state-metrics 1 1 1 1 15m') # Expect verify to fail with self.assertRaises(TestFailException): lbc.main(['verify', '--skip-checks', '--namespace=monitoring'])
def test_upgrade(self): self.expect_install_setup() self.expect_helm_status_deployed() self.expect_helm_upgrade() lbc.main([ 'install', '--namespace=lightbend', '--skip-checks', '--delete-pvcs', '--creds=' + self.creds_file ])
def test_export_yaml_local_chart(self): expect_cmd( r'helm template --name enterprise-suite --namespace lightbend chart\.tgz' ) lbc.main([ 'install', '--skip-checks', '--export-yaml=console', '--local-chart=chart.tgz' ])
def test_install_helm_failed(self): # Failed previous install, no PVCs or clusterroles found for reuse self.expect_install_setup() self.expect_helm_status_failed() self.expect_helm_upgrade() lbc.main([ 'install', '--namespace=lightbend', '--skip-checks', '--delete-pvcs', '--creds=' + self.creds_file ])
def test_specify_version(self): self.expect_install_setup() self.expect_helm_status_notfound() self.expect_helm_install(version=r'1\.0\.0-rc\.9') lbc.main([ 'install', '--namespace=lightbend', '--skip-checks', '--delete-pvcs', '--creds=' + self.creds_file, '--version=1.0.0-rc.9' ])
def test_uninstall(self): expect_cmd( r'helm status enterprise-suite', returncode=0, stdout= 'LAST DEPLOYED: Tue Nov 13 09:59:46 2018\nNAMESPACE: lightbend\nSTATUS: DEPLOYED\nNOTES: blah' ) expect_cmd(r'helm delete --purge enterprise-suite') lbc.main(['uninstall', '--skip-checks'])
def test_helm_args_conflicting_namespace(self): with self.assertRaises(TestFailException): self.expect_helm_version() lbc.main([ 'install', '--namespace=lightbend', '--namespace', 'foo', '--skip-checks', '--creds=' + self.creds_file, '--delete-pvcs', '--', '--set', 'minikube=true', '--fakearg', '--namespace', 'bar' ])
def test_upgrade(self): expect_cmd( r'helm repo add es-repo https://repo.lightbend.com/helm-charts') expect_cmd(r'helm repo update') expect_cmd(r'helm status enterprise-suite', returncode=0) expect_cmd( r'helm upgrade enterprise-suite es-repo/enterprise-suite --devel --values \S+ ' ) lbc.main(['install', '--skip-checks', '--creds=' + self.creds_file])
def test_install_override_name(self): self.expect_install_setup() self.expect_helm_status_notfound('lb-console') self.expect_helm_install(name='lb-console') lbc.main([ 'install', '--namespace=lightbend', '--skip-checks', '--delete-pvcs', '--creds=' + self.creds_file, '--helm-name=lb-console' ])
def test_helm_args(self): self.expect_install_setup() self.expect_helm_status_notfound() self.expect_helm_install(args=['--set', 'minikube=true', '--fakearg']) lbc.main([ 'install', '--namespace=lightbend', '--skip-checks', '--creds=' + self.creds_file, '--delete-pvcs', '--', '--set', 'minikube=true', '--fakearg' ])
def test_install_local_chart(self): self.expect_helm_version() expect_cmd(r'helm template .*') self.expect_helm_status_notfound() self.expect_helm_install(chart='chart.tgz') lbc.main([ 'install', '--namespace=lightbend', '--skip-checks', '--delete-pvcs', '--creds=' + self.creds_file, '--local-chart=chart.tgz' ])
def test_install(self): expect_cmd( r'helm repo add es-repo https://repo.lightbend.com/helm-charts') expect_cmd(r'helm repo update') expect_cmd(r'helm status enterprise-suite', returncode=-1) expect_cmd(r'kubectl get pvc --namespace=lightbend --no-headers') expect_cmd( r'helm install es-repo/enterprise-suite --name enterprise-suite --namespace lightbend --devel --values \S+' ) lbc.main(['install', '--skip-checks', '--creds=' + self.creds_file])
def test_export_yaml_console(self): self.setUpFakeChartfile() expect_cmd( r'helm repo add es-repo https://repo.lightbend.com/helm-charts') expect_cmd(r'helm repo update') expect_cmd(r'helm fetch -d \S* --devel es-repo/enterprise-suite') expect_cmd( r'helm template --name enterprise-suite --namespace lightbend \S*\.tgz' ) lbc.main(['install', '--skip-checks', '--export-yaml=console'])
def test_install_local_chart(self): expect_cmd(r'helm status enterprise-suite', returncode=-1) expect_cmd(r'kubectl get pvc --namespace=lightbend --no-headers') expect_cmd( r'helm install chart.tgz --name enterprise-suite --namespace lightbend --devel --values \S+' ) lbc.main([ 'install', '--skip-checks', '--creds=' + self.creds_file, '--local-chart=chart.tgz' ])
def test_install_not_finished(self): self.expect_install_setup() self.expect_helm_status_pending_install() # Expect install to fail when previous install is still pending with self.assertRaises(TestFailException): lbc.main([ 'install', '--namespace=lightbend', '--skip-checks', '--creds=' + self.creds_file ])
def test_export_yaml_console(self): self.expect_helm_version() expect_cmd( r'helm repo add es-repo https://repo.lightbend.com/helm-charts') expect_cmd(r'helm repo update') expect_cmd(r'helm fetch .* es-repo/enterprise-suite') self.expect_helm_template() lbc.main([ 'install', '--namespace=lightbend', '--skip-checks', '--export-yaml=console' ])
def test_checks_detect_legacy_installs_fail(self): with self.assertRaises(TestFailException): self.expect_helm_version() self.expect_basic_setup_checks() expect_cmd( 'kubectl get configmap --namespace kube-system --selector OWNER=TILLER,NAME=enterprise-suite --ignore-not-found=true', returncode=1) lbc.main([ 'install', '--namespace=lightbend', '--delete-pvcs', '--creds=' + self.creds_file ])
def test_helm_set_array(self): self.expect_install_setup() self.expect_helm_status_notfound() self.expect_helm_install(args=[ '--set', r'alertmanagers=alertmgr-00\\,alertmgr-01\\,alertmgr-02' ]) lbc.main([ 'install', '--namespace=lightbend', '--skip-checks', '--creds=' + self.creds_file, '--delete-pvcs', '--set', 'alertmanagers=alertmgr-00,alertmgr-01,alertmgr-02' ])
def test_helm_args_timeout(self): self.expect_helm_version() expect_cmd(r'helm template .*') self.expect_helm_status_notfound(namespace='foo') self.expect_helm_install(chart='.', namespace='foo', args=['--timeout', '110']) lbc.main([ 'install', '--namespace=lightbend', '--local-chart', '.', '--skip-checks', '--creds=' + self.creds_file, '--delete-pvcs', '--namespace', 'foo', '--', '--timeout', '110' ])
def test_export_yaml_console(self): self.expect_helm_version() expect_cmd(r'helm version --client --short', stdout=self.helm_version) expect_cmd( r'helm repo add --force-update es-repo https://repo.lightbend.com/helm-charts' ) expect_cmd(r'helm repo update') expect_cmd(r'helm fetch .* es-repo/enterprise-suite') self.expect_helm_template() lbc.main([ 'install', '--namespace=lightbend', '--skip-checks', '--export-yaml=console', '--creds=' + self.creds_file ])
def test_not_checks_detect_legacy_installs(self): def setup_checks(): self.expect_basic_setup_checks() expect_cmd('curl --version') expect_cmd(r'curl .*') self.expect_install_setup(setup_checks=setup_checks) self.expect_helm_status_notfound() self.expect_helm_install() lbc.main([ 'install', '--namespace=lightbend', '--delete-pvcs', '--creds=' + self.creds_file ])
def test_export_yaml_creds(self): self.setUpFakeChartfile() expect_cmd( r'helm repo add es-repo https://repo.lightbend.com/helm-charts') expect_cmd(r'helm repo update') expect_cmd(r'helm fetch -d \S* --devel es-repo/enterprise-suite') expect_cmd( r'helm template --name enterprise-suite --namespace lightbend --execute templates/commercial-credentials\.yaml --values \S+ \S+\.tgz' ) lbc.main([ 'install', '--skip-checks', '--creds=' + self.creds_file, '--export-yaml=creds' ])
def test_install_override_repo(self): self.expect_helm_version() expect_cmd(r'helm repo add es-repo https://repo.bintray.com/helm') expect_cmd(r'helm repo update') expect_cmd(r'helm fetch .* es-repo/enterprise-suite') expect_cmd(r'helm template .*') self.expect_helm_status_notfound() self.expect_helm_install() lbc.main([ 'install', '--namespace=lightbend', '--skip-checks', '--delete-pvcs', '--creds=' + self.creds_file, '--repo=https://repo.bintray.com/helm' ])
def test_export_yaml_creds(self): self.expect_helm_version() expect_cmd( r'helm repo add es-repo https://repo.lightbend.com/helm-charts') expect_cmd(r'helm repo update') expect_cmd(r'helm fetch .* es-repo/enterprise-suite') self.expect_helm_template( template=r'templates/commercial-credentials\.yaml', args=['--values', r'\S+']) lbc.main([ 'install', '--namespace=lightbend', '--skip-checks', '--creds=' + self.creds_file, '--export-yaml=creds' ])
def test_helm_set_array(self): expect_cmd( r'helm repo add es-repo https://repo.lightbend.com/helm-charts') expect_cmd(r'helm repo update') expect_cmd(r'helm status enterprise-suite', returncode=-1) expect_cmd(r'kubectl get pvc --namespace=lightbend --no-headers') expect_cmd( r'helm install es-repo/enterprise-suite --name enterprise-suite --namespace lightbend --devel --values \S+ --set alertmanagers=alertmgr-00\\,alertmgr-01\\,alertmgr-02 ' ) lbc.main([ 'install', '--skip-checks', '--creds=' + self.creds_file, '--set', 'alertmanagers=alertmgr-00,alertmgr-01,alertmgr-02' ])
def test_verify_success(self): expect_cmd( r'kubectl --namespace monitoring get deploy/console-backend --no-headers', stdout='console-backend 2 2 2 2 15m') expect_cmd( r'kubectl --namespace monitoring get deploy/console-frontend --no-headers', stdout='console-frontend 1 1 1 1 15m') expect_cmd( r'kubectl --namespace monitoring get deploy/grafana --no-headers', stdout='grafana 1 1 1 1 15m') expect_cmd( r'kubectl --namespace monitoring get deploy/prometheus-kube-state-metrics --no-headers', stdout='prometheus-kube-state-metrics 1 1 1 1 15m') lbc.main(['verify', '--skip-checks', '--namespace=monitoring'])
def test_install_not_finished(self): expect_cmd( r'helm repo add es-repo https://repo.lightbend.com/helm-charts') expect_cmd(r'helm repo update') expect_cmd( r'helm status enterprise-suite', returncode=0, stdout= 'LAST DEPLOYED: Tue Nov 13 09:59:46 2018\nNAMESPACE: lightbend\nSTATUS: PENDING_INSTALL\nNOTES: blah' ) # Expect install to fail when previous install is still pending with self.assertRaises(TestFailException): lbc.main( ['install', '--skip-checks', '--creds=' + self.creds_file])
def test_checks_detect_legacy_installs(self): def setup_checks(): self.expect_basic_setup_checks() expect_cmd( 'kubectl get configmap --namespace kube-system --selector OWNER=TILLER,NAME=enterprise-suite --ignore-not-found=true' ) expect_cmd('curl --version') expect_cmd(r'curl .*') self.expect_install_setup(setup_checks=setup_checks) self.expect_helm_status_notfound() self.expect_helm_install() lbc.main([ 'install', '--namespace=lightbend', '--delete-pvcs', '--creds=' + self.creds_file ])