From fdb3ea91115b5ba3f1535e7e130c1db76fca3662 Mon Sep 17 00:00:00 2001 From: Francisco de Paz Galan Date: Fri, 2 Dec 2022 09:19:44 +0100 Subject: [PATCH] [bitnami/solr] Revisit tests (#13667) Signed-off-by: FraPazGal Signed-off-by: FraPazGal --- .vib/solr/cypress/cypress.env.json | 9 ++++ .vib/solr/cypress/cypress.json | 6 +-- .../cypress/cypress/integration/solr_spec.js | 42 ++++----------- .vib/solr/cypress/cypress/support/commands.js | 4 +- .vib/solr/cypress/cypress/support/utils.js | 2 - .vib/solr/goss/goss.yaml | 53 +++++++++---------- .vib/solr/goss/vars.yaml | 13 +++++ .vib/solr/vib-publish.json | 11 ++-- .vib/solr/vib-verify.json | 13 ++--- 9 files changed, 67 insertions(+), 86 deletions(-) create mode 100644 .vib/solr/cypress/cypress.env.json create mode 100644 .vib/solr/goss/vars.yaml diff --git a/.vib/solr/cypress/cypress.env.json b/.vib/solr/cypress/cypress.env.json new file mode 100644 index 000000000..f9c6d1547 --- /dev/null +++ b/.vib/solr/cypress/cypress.env.json @@ -0,0 +1,9 @@ +{ + "username": "admin_user", + "password": "ComplicatedPassword123!4", + "collection": { + "name": "vib-test-collection", + "shards": 2, + "replicas": 2 + } +} diff --git a/.vib/solr/cypress/cypress.json b/.vib/solr/cypress/cypress.json index 2b13b1c9c..6d9595f3d 100644 --- a/.vib/solr/cypress/cypress.json +++ b/.vib/solr/cypress/cypress.json @@ -1,8 +1,4 @@ { "baseUrl": "http://localhost/", - "env": { - "username": "user", - "password": "ComplicatedPassword123!4" - }, "defaultCommandTimeout": 30000 -} \ No newline at end of file +} diff --git a/.vib/solr/cypress/cypress/integration/solr_spec.js b/.vib/solr/cypress/cypress/integration/solr_spec.js index 6df6e28a4..15747f3a3 100644 --- a/.vib/solr/cypress/cypress/integration/solr_spec.js +++ b/.vib/solr/cypress/cypress/integration/solr_spec.js @@ -1,37 +1,13 @@ /// -import { random, getBasicAuthHeader } from '../support/utils'; +import { getBasicAuthHeader } from '../support/utils'; -it('allows accessing the Dashboard', () => { +it('checks initialized collection', () => { cy.login(); - cy.visit('/solr/#/'); - cy.contains('Unauthorized').should('not.exist'); + cy.visit(`/solr/#/${Cypress.env('collection').name}/collection-overview`); - cy.contains('solr-spec'); - cy.contains('JVM'); - cy.contains('solr.install.dir=/opt/bitnami/solr'); -}); - -it('checks all nodes are up', () => { - const NUMBER_OF_NODES = 3; - cy.login(); - cy.visit('/solr/#/~cloud'); - - cy.get('table#nodes-table').within(() => { - cy.get('div[class*="host-name"]').should('have.length', NUMBER_OF_NODES); - }); -}); - -it('allows registering a user', () => { - cy.login(); - cy.visit('/solr/#/~security'); - - cy.fixture('users').then((users) => { - cy.contains('button', 'Add User').click(); - cy.get('input#add_user').type(`${users.newUser.username}.${random}`); - cy.get('input#add_user_password').type(users.newUser.password); - cy.get('input#add_user_password2').type(users.newUser.password); - cy.contains('button', 'Add User').click(); - cy.contains('td', `${users.newUser.username}.${random}`); + cy.get('#shards').within(() => { + cy.get('[class*="shard-title"]').should('have.length', Cypress.env('collection').shards); + cy.get('[href*="solr-"]').should('have.length', Cypress.env('collection').shards * Cypress.env('collection').replicas); }); }); @@ -49,7 +25,7 @@ it('allows uploading and indexing a file', () => { formData.set('user-file', content, 'data.js'); cy.request({ - url: '/solr/my-collection/update', + url: `/solr/${Cypress.env('collection').name}/update`, qs: { commitWithin: 1000, overwrite: true, @@ -69,7 +45,7 @@ it('allows uploading and indexing a file', () => { // Get an arbitrary book from the collection var book = $books[Math.floor(Math.random() * $books.length)]; cy.request({ - url: '/solr/my-collection/query', + url: `/solr/${Cypress.env('collection').name}/query`, qs: { q: `title:${book.title}`, 'q.op': 'OR', @@ -90,7 +66,7 @@ it('allows uploading and indexing a file', () => { it('allows retrieving sample schema', () => { cy.request({ - url: '/solr/my-collection/schema', + url: `/solr/${Cypress.env('collection').name}/schema`, method: 'GET', headers: { Authorization: getBasicAuthHeader(), diff --git a/.vib/solr/cypress/cypress/support/commands.js b/.vib/solr/cypress/cypress/support/commands.js index 8958ab943..a0c28496b 100644 --- a/.vib/solr/cypress/cypress/support/commands.js +++ b/.vib/solr/cypress/cypress/support/commands.js @@ -21,8 +21,8 @@ Cypress.Commands.add( }); cy.visit('/solr/#/'); cy.contains('Basic Authentication'); - cy.get('input#username').type(username); - cy.get('input#password').type(password); + cy.get('#username').type(username); + cy.get('#password').type(password); cy.contains('button', 'Login').click(); } ); diff --git a/.vib/solr/cypress/cypress/support/utils.js b/.vib/solr/cypress/cypress/support/utils.js index bb7748b23..d65099333 100644 --- a/.vib/solr/cypress/cypress/support/utils.js +++ b/.vib/solr/cypress/cypress/support/utils.js @@ -1,7 +1,5 @@ /// -export let random = (Math.random() + 1).toString(36).substring(7); - export const getBasicAuthHeader = ( username = Cypress.env("username"), password = Cypress.env("password") diff --git a/.vib/solr/goss/goss.yaml b/.vib/solr/goss/goss.yaml index c989fe1b0..6d696b983 100644 --- a/.vib/solr/goss/goss.yaml +++ b/.vib/solr/goss/goss.yaml @@ -1,39 +1,34 @@ command: - which-solr: - exec: which solr + {{- $auth := printf "SOLR_AUTH_TYPE=basic SOLR_AUTHENTICATION_OPTS=-Dbasicauth=%s:%s" .Vars.auth.adminUsername .Vars.auth.adminPassword }} + {{- $collection := printf "test.%s" (randNumeric 5) }} + {{- $replicas := .Vars.replicaCount }} + solr-manage-collection: + exec: | + export {{ $auth }} && \ + solr create_collection -p {{ .Vars.containerPorts.http }} -replicationFactor {{ $replicas }} -c {{ $collection }} && \ + solr healthcheck -z solr-zookeeper:2181/solr -c {{ $collection }} exit-status: 0 stdout: - - "/opt/bitnami/solr/bin/solr" - stderr: [ ] - timeout: 40000 - solr-version-ok: - exec: solr version | grep --quiet "$APP_VERSION" - exit-status: 0 - stdout: [ ] - stderr: [ ] - timeout: 40000 - solr-assert-running: - exec: SOLR_AUTH_TYPE=basic SOLR_AUTHENTICATION_OPTS="-Dbasicauth=${SOLR_ADMIN_USERNAME}:${SOLR_ADMIN_PASSWORD}" solr assert --cloud "http://localhost:${SOLR_PORT_NUMBER}/solr/" - exit-status: 0 - stdout: [ ] - stderr: [ ] - timeout: 40000 - solr-create-collection: - exec: SOLR_AUTH_TYPE=basic SOLR_AUTHENTICATION_OPTS="-Dbasicauth=${SOLR_ADMIN_USERNAME}:${SOLR_ADMIN_PASSWORD}" /opt/bitnami/solr/bin/solr create_collection -c "test.${RANDOM}" + - healthy + {{ range $e, $i := until $replicas }} + - /solr-{{ $i }}/ + {{ end }} + timeout: 30000 + check-user-info: + exec: id exit-status: 0 stdout: - - "Created collection" - stderr: [ ] - timeout: 40000 + - uid={{ .Vars.containerSecurityContext.runAsUser }} + - /groups=.*{{ .Vars.podSecurityContext.fsGroup }}/ file: - /opt/bitnami/solr/server: + {{ .Vars.persistence.mountPath }}: filetype: directory exists: true - /opt/bitnami/solr/server/solr/solr.xml: - mode: "0644" + mode: "2775" + owner: root + /scripts/setup.sh: + mode: "0755" filetype: file exists: true - /opt/bitnami/solr/server/solr/zoo.cfg: - mode: "0644" - filetype: file - exists: true \ No newline at end of file + contains: + - SOLR_CLOUD_BOOTSTRAP={{ if .Vars.cloudBootstrap }}yes{{ else }}no{{ end }} diff --git a/.vib/solr/goss/vars.yaml b/.vib/solr/goss/vars.yaml new file mode 100644 index 000000000..d4f8eeb01 --- /dev/null +++ b/.vib/solr/goss/vars.yaml @@ -0,0 +1,13 @@ +auth: + adminUsername: admin_user + adminPassword: ComplicatedPassword123!4 +cloudBootstrap: true +replicaCount: 4 +containerPorts: + http: 8984 +podSecurityContext: + fsGroup: 1002 +containerSecurityContext: + runAsUser: 1002 +persistence: + mountPath: /bitnami/solr diff --git a/.vib/solr/vib-publish.json b/.vib/solr/vib-publish.json index 247eeb155..cbfce494f 100644 --- a/.vib/solr/vib-publish.json +++ b/.vib/solr/vib-publish.json @@ -22,7 +22,7 @@ "url": "{SHA_ARCHIVE}", "path": "/bitnami/solr" }, - "runtime_parameters": "ImF1dGgiOgogICJhZG1pblBhc3N3b3JkIjogIkNvbXBsaWNhdGVkUGFzc3dvcmQxMjMhNCIKICAiYWRtaW5Vc2VybmFtZSI6ICJ1c2VyIgoic2VydmljZSI6CiAgInBvcnRzIjoKICAgICJodHRwIjogODAKICAidHlwZSI6ICJMb2FkQmFsYW5jZXIi", + "runtime_parameters": "YXV0aDoKICBlbmFibGVkOiB0cnVlCiAgYWRtaW5QYXNzd29yZDogQ29tcGxpY2F0ZWRQYXNzd29yZDEyMyE0CiAgYWRtaW5Vc2VybmFtZTogYWRtaW5fdXNlcgpjbG91ZEVuYWJsZWQ6IHRydWUKY2xvdWRCb290c3RyYXA6IHRydWUKY29sbGVjdGlvbjogdmliLXRlc3QtY29sbGVjdGlvbgpjb2xsZWN0aW9uU2hhcmRzOiAyCmNvbGxlY3Rpb25SZXBsaWNhczogMgpyZXBsaWNhQ291bnQ6IDQKY29udGFpbmVyUG9ydHM6CiAgaHR0cDogODk4NApwb2RTZWN1cml0eUNvbnRleHQ6CiAgZW5hYmxlZDogdHJ1ZQogIGZzR3JvdXA6IDEwMDIKY29udGFpbmVyU2VjdXJpdHlDb250ZXh0OgogIGVuYWJsZWQ6IHRydWUKICBydW5Bc1VzZXI6IDEwMDIKc2VydmljZToKICBwb3J0czoKICAgIGh0dHA6IDgwCiAgdHlwZTogTG9hZEJhbGFuY2VyCnBlcnNpc3RlbmNlOgogIGVuYWJsZWQ6IHRydWUKICBtb3VudFBhdGg6IC9iaXRuYW1pL3NvbHIKem9va2VlcGVyOgogIGVuYWJsZWQ6IHRydWU=", "target_platform": { "target_platform_id": "{VIB_ENV_TARGET_PLATFORM}", "size": { @@ -46,7 +46,8 @@ }, "remote": { "workload": "sts-solr" - } + }, + "vars_file": "vars.yaml" } }, { @@ -56,11 +57,7 @@ "path": "/.vib/solr/cypress" }, "endpoint": "lb-solr-tcp-client", - "app_protocol": "HTTP", - "env": { - "username": "user", - "password": "ComplicatedPassword123!4" - } + "app_protocol": "HTTP" } } ] diff --git a/.vib/solr/vib-verify.json b/.vib/solr/vib-verify.json index dfb529e55..760f7463e 100644 --- a/.vib/solr/vib-verify.json +++ b/.vib/solr/vib-verify.json @@ -22,11 +22,11 @@ "url": "{SHA_ARCHIVE}", "path": "/bitnami/solr" }, - "runtime_parameters": "ImF1dGgiOgogICJhZG1pblBhc3N3b3JkIjogIkNvbXBsaWNhdGVkUGFzc3dvcmQxMjMhNCIKICAiYWRtaW5Vc2VybmFtZSI6ICJ1c2VyIgoic2VydmljZSI6CiAgInBvcnRzIjoKICAgICJodHRwIjogODAKICAidHlwZSI6ICJMb2FkQmFsYW5jZXIi", + "runtime_parameters": "YXV0aDoKICBlbmFibGVkOiB0cnVlCiAgYWRtaW5QYXNzd29yZDogQ29tcGxpY2F0ZWRQYXNzd29yZDEyMyE0CiAgYWRtaW5Vc2VybmFtZTogYWRtaW5fdXNlcgpjbG91ZEVuYWJsZWQ6IHRydWUKY2xvdWRCb290c3RyYXA6IHRydWUKY29sbGVjdGlvbjogdmliLXRlc3QtY29sbGVjdGlvbgpjb2xsZWN0aW9uU2hhcmRzOiAyCmNvbGxlY3Rpb25SZXBsaWNhczogMgpyZXBsaWNhQ291bnQ6IDQKY29udGFpbmVyUG9ydHM6CiAgaHR0cDogODk4NApwb2RTZWN1cml0eUNvbnRleHQ6CiAgZW5hYmxlZDogdHJ1ZQogIGZzR3JvdXA6IDEwMDIKY29udGFpbmVyU2VjdXJpdHlDb250ZXh0OgogIGVuYWJsZWQ6IHRydWUKICBydW5Bc1VzZXI6IDEwMDIKc2VydmljZToKICBwb3J0czoKICAgIGh0dHA6IDgwCiAgdHlwZTogTG9hZEJhbGFuY2VyCnBlcnNpc3RlbmNlOgogIGVuYWJsZWQ6IHRydWUKICBtb3VudFBhdGg6IC9iaXRuYW1pL3NvbHIKem9va2VlcGVyOgogIGVuYWJsZWQ6IHRydWU=", "target_platform": { "target_platform_id": "{VIB_ENV_TARGET_PLATFORM}", "size": { - "name": "S4" + "name": "M4" } } }, @@ -46,7 +46,8 @@ }, "remote": { "workload": "sts-solr" - } + }, + "vars_file": "vars.yaml" } }, { @@ -56,11 +57,7 @@ "path": "/.vib/solr/cypress" }, "endpoint": "lb-solr-tcp-client", - "app_protocol": "HTTP", - "env": { - "username": "user", - "password": "ComplicatedPassword123!4" - } + "app_protocol": "HTTP" } } ]