mirror of https://github.com/grafana/grafana.git
				
				
				
			Search e2e (#102827)
* search e2e * add github action * run test for every ini file in test folder
This commit is contained in:
		
							parent
							
								
									cd53070a00
								
							
						
					
					
						commit
						2489e423d0
					
				|  | @ -816,6 +816,7 @@ embed.go @grafana/grafana-as-code | ||||||
| /.github/workflows/verify-kinds.yml @grafana/platform-monitoring | /.github/workflows/verify-kinds.yml @grafana/platform-monitoring | ||||||
| /.github/workflows/dashboards-issue-add-label.yml @grafana/dashboards-squad | /.github/workflows/dashboards-issue-add-label.yml @grafana/dashboards-squad | ||||||
| /.github/workflows/run-schema-v2-e2e.yml  @grafana/dashboards-squad | /.github/workflows/run-schema-v2-e2e.yml  @grafana/dashboards-squad | ||||||
|  | /.github/workflows/run-dashboard-search-e2e.yml  @grafana/grafana-search-and-storage | ||||||
| /.github/workflows/ephemeral-instances-pr-comment.yml @grafana/grafana-backend-services-squad | /.github/workflows/ephemeral-instances-pr-comment.yml @grafana/grafana-backend-services-squad | ||||||
| /.github/workflows/create-security-patch-from-security-mirror.yml @grafana/grafana-developer-enablement-squad | /.github/workflows/create-security-patch-from-security-mirror.yml @grafana/grafana-developer-enablement-squad | ||||||
| /.github/workflows/core-plugins-build-and-release.yml @grafana/plugins-platform-frontend @grafana/plugins-platform-backend | /.github/workflows/core-plugins-build-and-release.yml @grafana/plugins-platform-frontend @grafana/plugins-platform-backend | ||||||
|  |  | ||||||
|  | @ -0,0 +1,121 @@ | ||||||
|  | name: Run dashboard search e2e | ||||||
|  | 
 | ||||||
|  | on: | ||||||
|  |   push: | ||||||
|  |     branches: | ||||||
|  |       - main | ||||||
|  |   pull_request: | ||||||
|  |     branches: | ||||||
|  |       - main | ||||||
|  | 
 | ||||||
|  | env: | ||||||
|  |   ARCH: linux-amd64 | ||||||
|  | 
 | ||||||
|  | jobs: | ||||||
|  |   setup: | ||||||
|  |     runs-on: ubuntu-latest | ||||||
|  |     if: github.event.pull_request.draft == false | ||||||
|  |     outputs: | ||||||
|  |       ini_files: ${{ steps.get_files.outputs.ini_files }} | ||||||
|  | 
 | ||||||
|  |     steps: | ||||||
|  |       - name: Checkout | ||||||
|  |         uses: actions/checkout@v4 | ||||||
|  |       - name: Pin Go version to mod file | ||||||
|  |         uses: actions/setup-go@v5 | ||||||
|  |         with: | ||||||
|  |           go-version-file: 'go.mod' | ||||||
|  |           cache: true | ||||||
|  |       - run: go version | ||||||
|  |       - uses: actions/setup-node@v4 | ||||||
|  |         with: | ||||||
|  |           node-version: 20 | ||||||
|  |           cache: 'yarn' | ||||||
|  |       - name: Cache Node Modules | ||||||
|  |         id: cache-node-modules | ||||||
|  |         uses: actions/cache@v3 | ||||||
|  |         with: | ||||||
|  |           path: | | ||||||
|  |             node_modules | ||||||
|  |             /home/runner/.cache/Cypress | ||||||
|  |           key: ${{ runner.os }}-node-${{ hashFiles('package-lock.json') }} | ||||||
|  |       - name: Install dependencies | ||||||
|  |         if: steps.cache-node-modules.outputs.cache-hit != 'true' | ||||||
|  |         run: yarn install --immutable | ||||||
|  |       - name: Install Cypress dependencies | ||||||
|  |         if: steps.cache-node-modules.outputs.cache-hit != 'true' | ||||||
|  |         uses: cypress-io/github-action@v6 | ||||||
|  |         with: | ||||||
|  |           runTests: false | ||||||
|  |       - name: Cache Grafana Build and Dependencies | ||||||
|  |         id: cache-grafana | ||||||
|  |         uses: actions/cache@v3 | ||||||
|  |         with: | ||||||
|  |           path: | | ||||||
|  |             bin/ | ||||||
|  |             scripts/grafana-server/ | ||||||
|  |             tools/ | ||||||
|  |             public/ | ||||||
|  |             conf/ | ||||||
|  |             e2e/test-plugins/ | ||||||
|  |             devenv/ | ||||||
|  |           key: ${{ runner.os }}-grafana-${{ hashFiles('go.mod', 'package-lock.json', 'Makefile', 'pkg/storage/**/*.go', 'public/app/features/search/**/*.ts', 'public/app/features/search/**/*.tsx') }} | ||||||
|  |       # only rebuild grafana if search files have changed ( or dependencies ) | ||||||
|  |       - name: Build Grafana (Runs Only If Not Cached) | ||||||
|  |         if: steps.cache-grafana.outputs.cache-hit != 'true' | ||||||
|  |         run: make build | ||||||
|  | 
 | ||||||
|  |       - name: Get list of .ini files | ||||||
|  |         id: get_files | ||||||
|  |         run: | | ||||||
|  |           INI_FILES=$(ls ${{ github.workspace }}/e2e/dashboards-search-suite/*.ini | jq -R -s -c 'split("\n")[:-1]') | ||||||
|  |           echo "ini_files=$INI_FILES" >> $GITHUB_OUTPUT | ||||||
|  |         shell: bash | ||||||
|  | 
 | ||||||
|  |   run_tests: | ||||||
|  |       needs: setup | ||||||
|  |       runs-on: ubuntu-latest | ||||||
|  |       continue-on-error: true | ||||||
|  |       if: github.event.pull_request.draft == false | ||||||
|  |       strategy: | ||||||
|  |         matrix: | ||||||
|  |           ini_file: ${{ fromJson(needs.setup.outputs.ini_files) }} | ||||||
|  | 
 | ||||||
|  |       steps: | ||||||
|  |         - name: Checkout repository | ||||||
|  |           uses: actions/checkout@v4 | ||||||
|  | 
 | ||||||
|  |         - name: Restore Cached Node Modules | ||||||
|  |           uses: actions/cache@v3 | ||||||
|  |           with: | ||||||
|  |             path: | | ||||||
|  |               node_modules | ||||||
|  |               /home/runner/.cache/Cypress | ||||||
|  |             key: foo | ||||||
|  | 
 | ||||||
|  |         - name: Restore Cached Grafana Build and Dependencies | ||||||
|  |           uses: actions/cache@v3 | ||||||
|  |           with: | ||||||
|  |             path: | | ||||||
|  |               bin/ | ||||||
|  |               scripts/grafana-server/ | ||||||
|  |               tools/ | ||||||
|  |               public/ | ||||||
|  |               conf/ | ||||||
|  |               e2e/test-plugins/ | ||||||
|  |               devenv/ | ||||||
|  |             key: ${{ runner.os }}-grafana-${{ hashFiles('go.mod', 'package-lock.json', 'Makefile', 'pkg/storage/**/*.go', 'public/app/features/search/**/*.ts', 'public/app/features/search/**/*.tsx') }} | ||||||
|  |         - name: Prettify the name | ||||||
|  |           run: echo "Running tests for $(basename "${{ matrix.ini_file }}")" | ||||||
|  |         - name: Set the step name | ||||||
|  |           id: set_file_name | ||||||
|  |           run: | | ||||||
|  |             FILE_NAME=$(basename "${{ matrix.ini_file }}" .ini) | ||||||
|  |             echo "FILE_NAME=$FILE_NAME" >> $GITHUB_ENV | ||||||
|  |         - name: Run tests for ${{ env.FILE_NAME }} | ||||||
|  |           run: | | ||||||
|  |             cp -rf ${{ matrix.ini_file }} ${{ github.workspace }}/scripts/grafana-server/custom.ini | ||||||
|  |             yarn e2e:dashboards-search || echo "Test failed but marking as success since unified search is behind a feature flag and should not block PRs" | ||||||
|  |         - name: Always succeed # This is a workaround to make the job pass even if the previous step fails | ||||||
|  |           if: failure() | ||||||
|  |           run: exit 0 | ||||||
|  | @ -0,0 +1,61 @@ | ||||||
|  | import { e2e } from '../utils'; | ||||||
|  | 
 | ||||||
|  | const rowGroup = '[role="rowgroup"]'; | ||||||
|  | const row = '[role="row"]'; | ||||||
|  | const searchInput = '[data-testid="input-wrapper"]'; | ||||||
|  | 
 | ||||||
|  | describe('Dashboard search', () => { | ||||||
|  |   beforeEach(() => { | ||||||
|  |     e2e.flows.login(Cypress.env('USERNAME'), Cypress.env('PASSWORD')); | ||||||
|  |   }); | ||||||
|  | 
 | ||||||
|  |   it('Search - Dashboards list', () => { | ||||||
|  |     e2e.pages.Dashboards.visit(); | ||||||
|  | 
 | ||||||
|  |     toggleSearchView(); | ||||||
|  | 
 | ||||||
|  |     assertResultsCount(24); | ||||||
|  |   }); | ||||||
|  | 
 | ||||||
|  |   it('Search - Filter by search input', () => { | ||||||
|  |     e2e.pages.Dashboards.visit(); | ||||||
|  | 
 | ||||||
|  |     toggleSearchView(); | ||||||
|  | 
 | ||||||
|  |     assertResultsCount(24); | ||||||
|  | 
 | ||||||
|  |     // prefix match
 | ||||||
|  |     cy.get(searchInput).type('Datasource tests - MySQL'); | ||||||
|  |     assertResultsCount(2); | ||||||
|  | 
 | ||||||
|  |     cy.get(searchInput).type('{selectall}{backspace}'); // clear input
 | ||||||
|  | 
 | ||||||
|  |     // exact match
 | ||||||
|  |     cy.get(searchInput).type('Datasource tests - MySQL (unittest)'); | ||||||
|  |     assertResultsCount(1); | ||||||
|  | 
 | ||||||
|  |     cy.get(searchInput).type('{selectall}{backspace}'); // clear input
 | ||||||
|  | 
 | ||||||
|  |     // suffix match
 | ||||||
|  |     cy.get(searchInput).type('- MySQL'); | ||||||
|  |     assertResultsCount(1); | ||||||
|  |   }); | ||||||
|  | }); | ||||||
|  | 
 | ||||||
|  | const assertResultsCount = (length: number) => { | ||||||
|  |   e2e.pages.SearchDashboards.table().should('exist'); | ||||||
|  | 
 | ||||||
|  |   const table = e2e.pages.SearchDashboards.table(); | ||||||
|  |   const group = table.find(rowGroup); | ||||||
|  |   group.should('have.length', 1); | ||||||
|  |   const rows = group.find(row); | ||||||
|  |   rows.should('have.length', length); | ||||||
|  | }; | ||||||
|  | 
 | ||||||
|  | const toggleSearchView = () => { | ||||||
|  |   e2e.pages.Dashboards.toggleView().each((e, i) => { | ||||||
|  |     if (i === 1) { | ||||||
|  |       cy.wrap(e).click(); | ||||||
|  |     } | ||||||
|  |   }); | ||||||
|  | }; | ||||||
|  | @ -0,0 +1,19 @@ | ||||||
|  | [server] | ||||||
|  | 
 | ||||||
|  | [feature_toggles] | ||||||
|  | kubernetesFolders = true | ||||||
|  | unifiedStorageSearch = true | ||||||
|  | unifiedStorageSearchUI = true | ||||||
|  | grafanaAPIServerWithExperimentalAPIs = true | ||||||
|  | kubernetesDashboardsAPI = true | ||||||
|  | kubernetesCliDashboards = true | ||||||
|  | unifiedStorageSearchSprinkles = true | ||||||
|  | kubernetesFoldersServiceV2 = true | ||||||
|  | unifiedStorageSearchPermissionFiltering = true | ||||||
|  | kubernetesClientDashboardsFolders = true | ||||||
|  | 
 | ||||||
|  | [unified_storage.folders.folder.grafana.app] | ||||||
|  | dualWriterMode = 0 | ||||||
|  | 
 | ||||||
|  | [unified_storage.dashboards.dashboard.grafana.app] | ||||||
|  | dualWriterMode = 0 | ||||||
|  | @ -0,0 +1,19 @@ | ||||||
|  | [server] | ||||||
|  | 
 | ||||||
|  | [feature_toggles] | ||||||
|  | kubernetesFolders = true | ||||||
|  | unifiedStorageSearch = true | ||||||
|  | unifiedStorageSearchUI = true | ||||||
|  | grafanaAPIServerWithExperimentalAPIs = true | ||||||
|  | kubernetesDashboardsAPI = true | ||||||
|  | kubernetesCliDashboards = true | ||||||
|  | unifiedStorageSearchSprinkles = true | ||||||
|  | kubernetesFoldersServiceV2 = true | ||||||
|  | unifiedStorageSearchPermissionFiltering = true | ||||||
|  | kubernetesClientDashboardsFolders = true | ||||||
|  | 
 | ||||||
|  | [unified_storage.folders.folder.grafana.app] | ||||||
|  | dualWriterMode = 1 | ||||||
|  | 
 | ||||||
|  | [unified_storage.dashboards.dashboard.grafana.app] | ||||||
|  | dualWriterMode = 1 | ||||||
|  | @ -0,0 +1,19 @@ | ||||||
|  | [server] | ||||||
|  | 
 | ||||||
|  | [feature_toggles] | ||||||
|  | kubernetesFolders = true | ||||||
|  | unifiedStorageSearch = true | ||||||
|  | unifiedStorageSearchUI = false | ||||||
|  | grafanaAPIServerWithExperimentalAPIs = true | ||||||
|  | kubernetesDashboardsAPI = true | ||||||
|  | kubernetesCliDashboards = true | ||||||
|  | unifiedStorageSearchSprinkles = true | ||||||
|  | kubernetesFoldersServiceV2 = true | ||||||
|  | unifiedStorageSearchPermissionFiltering = true | ||||||
|  | kubernetesClientDashboardsFolders = true | ||||||
|  | 
 | ||||||
|  | [unified_storage.folders.folder.grafana.app] | ||||||
|  | dualWriterMode = 2 | ||||||
|  | 
 | ||||||
|  | [unified_storage.dashboards.dashboard.grafana.app] | ||||||
|  | dualWriterMode = 2 | ||||||
|  | @ -0,0 +1,19 @@ | ||||||
|  | [server] | ||||||
|  | 
 | ||||||
|  | [feature_toggles] | ||||||
|  | kubernetesFolders = true | ||||||
|  | unifiedStorageSearch = true | ||||||
|  | unifiedStorageSearchUI = true | ||||||
|  | grafanaAPIServerWithExperimentalAPIs = true | ||||||
|  | kubernetesDashboardsAPI = true | ||||||
|  | kubernetesCliDashboards = true | ||||||
|  | unifiedStorageSearchSprinkles = true | ||||||
|  | kubernetesFoldersServiceV2 = true | ||||||
|  | unifiedStorageSearchPermissionFiltering = true | ||||||
|  | kubernetesClientDashboardsFolders = true | ||||||
|  | 
 | ||||||
|  | [unified_storage.folders.folder.grafana.app] | ||||||
|  | dualWriterMode = 2 | ||||||
|  | 
 | ||||||
|  | [unified_storage.dashboards.dashboard.grafana.app] | ||||||
|  | dualWriterMode = 2 | ||||||
|  | @ -0,0 +1,19 @@ | ||||||
|  | [server] | ||||||
|  | 
 | ||||||
|  | [feature_toggles] | ||||||
|  | kubernetesFolders = true | ||||||
|  | unifiedStorageSearch = true | ||||||
|  | unifiedStorageSearchUI = true | ||||||
|  | grafanaAPIServerWithExperimentalAPIs = true | ||||||
|  | kubernetesDashboardsAPI = true | ||||||
|  | kubernetesCliDashboards = true | ||||||
|  | unifiedStorageSearchSprinkles = true | ||||||
|  | kubernetesFoldersServiceV2 = true | ||||||
|  | unifiedStorageSearchPermissionFiltering = true | ||||||
|  | kubernetesClientDashboardsFolders = true | ||||||
|  | 
 | ||||||
|  | [unified_storage.folders.folder.grafana.app] | ||||||
|  | dualWriterMode = 3 | ||||||
|  | 
 | ||||||
|  | [unified_storage.dashboards.dashboard.grafana.app] | ||||||
|  | dualWriterMode = 3 | ||||||
|  | @ -0,0 +1,19 @@ | ||||||
|  | [server] | ||||||
|  | 
 | ||||||
|  | [feature_toggles] | ||||||
|  | kubernetesFolders = true | ||||||
|  | unifiedStorageSearch = true | ||||||
|  | unifiedStorageSearchUI = true | ||||||
|  | grafanaAPIServerWithExperimentalAPIs = true | ||||||
|  | kubernetesDashboardsAPI = true | ||||||
|  | kubernetesCliDashboards = true | ||||||
|  | unifiedStorageSearchSprinkles = true | ||||||
|  | kubernetesFoldersServiceV2 = true | ||||||
|  | unifiedStorageSearchPermissionFiltering = true | ||||||
|  | kubernetesClientDashboardsFolders = true | ||||||
|  | 
 | ||||||
|  | [unified_storage.folders.folder.grafana.app] | ||||||
|  | dualWriterMode = 4 | ||||||
|  | 
 | ||||||
|  | [unified_storage.dashboards.dashboard.grafana.app] | ||||||
|  | dualWriterMode = 4 | ||||||
|  | @ -0,0 +1,19 @@ | ||||||
|  | [server] | ||||||
|  | 
 | ||||||
|  | [feature_toggles] | ||||||
|  | kubernetesFolders = true | ||||||
|  | unifiedStorageSearch = true | ||||||
|  | unifiedStorageSearchUI = true | ||||||
|  | grafanaAPIServerWithExperimentalAPIs = true | ||||||
|  | kubernetesDashboardsAPI = true | ||||||
|  | kubernetesCliDashboards = true | ||||||
|  | unifiedStorageSearchSprinkles = true | ||||||
|  | kubernetesFoldersServiceV2 = true | ||||||
|  | unifiedStorageSearchPermissionFiltering = true | ||||||
|  | kubernetesClientDashboardsFolders = true | ||||||
|  | 
 | ||||||
|  | [unified_storage.folders.folder.grafana.app] | ||||||
|  | dualWriterMode = 5 | ||||||
|  | 
 | ||||||
|  | [unified_storage.dashboards.dashboard.grafana.app] | ||||||
|  | dualWriterMode = 5 | ||||||
|  | @ -29,6 +29,7 @@ testFilesForSingleSuite="*.spec.ts" | ||||||
| rootForEnterpriseSuite="./e2e/extensions-suite" | rootForEnterpriseSuite="./e2e/extensions-suite" | ||||||
| rootForOldArch="./e2e/old-arch" | rootForOldArch="./e2e/old-arch" | ||||||
| rootForKubernetesDashboards="./e2e/dashboards-suite" | rootForKubernetesDashboards="./e2e/dashboards-suite" | ||||||
|  | rootForSearchDashboards="./e2e/dashboards-search-suite" | ||||||
| 
 | 
 | ||||||
| declare -A cypressConfig=( | declare -A cypressConfig=( | ||||||
|   [screenshotsFolder]=./e2e/"${args[0]}"/screenshots |   [screenshotsFolder]=./e2e/"${args[0]}"/screenshots | ||||||
|  | @ -130,6 +131,24 @@ case "$1" in | ||||||
|                 ;; |                 ;; | ||||||
|           esac |           esac | ||||||
|       ;; |       ;; | ||||||
|  |     "dashboards-search") | ||||||
|  |       env[kubernetesDashboards]=true | ||||||
|  |       cypressConfig[specPattern]=$rootForSearchDashboards/$testFilesForSingleSuite | ||||||
|  |       cypressConfig[video]=false | ||||||
|  |           case "$2" in | ||||||
|  |             "debug") | ||||||
|  |                 echo -e "Debug mode" | ||||||
|  |                 env[SLOWMO]=1 | ||||||
|  |                 PARAMS="--no-exit" | ||||||
|  |                 enterpriseSuite=$(basename "${args[2]}") | ||||||
|  |                 ;; | ||||||
|  |             "dev") | ||||||
|  |                 echo "Dev mode" | ||||||
|  |                 CMD="cypress open" | ||||||
|  |                 enterpriseSuite=$(basename "${args[2]}") | ||||||
|  |                 ;; | ||||||
|  |           esac | ||||||
|  |       ;; | ||||||
|    "enterprise-smtp") |    "enterprise-smtp") | ||||||
|       env[SMTP_PLUGIN_ENABLED]=true |       env[SMTP_PLUGIN_ENABLED]=true | ||||||
|       cypressConfig[specPattern]=./e2e/extensions/enterprise/smtp-suite/$testFilesForSingleSuite |       cypressConfig[specPattern]=./e2e/extensions/enterprise/smtp-suite/$testFilesForSingleSuite | ||||||
|  |  | ||||||
|  | @ -13,6 +13,7 @@ | ||||||
|     "e2e": "./e2e/start-and-run-suite", |     "e2e": "./e2e/start-and-run-suite", | ||||||
|     "e2e:old-arch": "./e2e/start-and-run-suite old-arch", |     "e2e:old-arch": "./e2e/start-and-run-suite old-arch", | ||||||
|     "e2e:schema-v2": "./e2e/start-and-run-suite dashboards-schema-v2", |     "e2e:schema-v2": "./e2e/start-and-run-suite dashboards-schema-v2", | ||||||
|  |     "e2e:dashboards-search": "./e2e/start-and-run-suite dashboards-search", | ||||||
|     "e2e:debug": "./e2e/start-and-run-suite debug", |     "e2e:debug": "./e2e/start-and-run-suite debug", | ||||||
|     "e2e:dev": "./e2e/start-and-run-suite dev", |     "e2e:dev": "./e2e/start-and-run-suite dev", | ||||||
|     "e2e:benchmark:live": "./e2e/start-and-run-suite benchmark live", |     "e2e:benchmark:live": "./e2e/start-and-run-suite benchmark live", | ||||||
|  |  | ||||||
|  | @ -569,6 +569,9 @@ export const versionedPages = { | ||||||
|     dashboards: { |     dashboards: { | ||||||
|       '10.2.0': (title: string) => `Dashboard search item ${title}`, |       '10.2.0': (title: string) => `Dashboard search item ${title}`, | ||||||
|     }, |     }, | ||||||
|  |     toggleView: { | ||||||
|  |       [MIN_GRAFANA_VERSION]: 'data-testid radio-button', | ||||||
|  |     }, | ||||||
|   }, |   }, | ||||||
|   SaveDashboardAsModal: { |   SaveDashboardAsModal: { | ||||||
|     newName: { |     newName: { | ||||||
|  | @ -945,6 +948,11 @@ export const versionedPages = { | ||||||
|       }, |       }, | ||||||
|     }, |     }, | ||||||
|   }, |   }, | ||||||
|  |   SearchDashboards: { | ||||||
|  |     table: { | ||||||
|  |       '10.2.0': 'Search results table', | ||||||
|  |     }, | ||||||
|  |   }, | ||||||
|   Search: { |   Search: { | ||||||
|     url: { |     url: { | ||||||
|       '9.3.0': '/?search=openn', |       '9.3.0': '/?search=openn', | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue