Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
ademidoff authored Dec 19, 2023
2 parents 8295bf9 + 75fd4a0 commit aad27c2
Show file tree
Hide file tree
Showing 130 changed files with 13,463 additions and 2,366 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/admin.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ jobs:
uses: actions/checkout@v4

- name: Set up Go release
uses: actions/setup-go@v4
uses: actions/setup-go@v5
with:
go-version-file: ${{ github.workspace }}/go.mod
cache: false
Expand Down Expand Up @@ -98,7 +98,7 @@ jobs:
uses: actions/checkout@v4

- name: Set up Go release
uses: actions/setup-go@v4
uses: actions/setup-go@v5
with:
go-version-file: ${{ github.workspace }}/go.mod
cache: false
Expand Down Expand Up @@ -153,7 +153,7 @@ jobs:

- name: Attach the report on failure
if: failure()
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: "report-${{ matrix.go-version }}-${{ matrix.test-type }}"
path: ${{ github.workspace }}/cli-tests/playwright-report/
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/agent.yml
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ jobs:
uses: actions/checkout@v4

- name: Set up Go release
uses: actions/setup-go@v4
uses: actions/setup-go@v5
with:
go-version-file: ${{ github.workspace }}/go.mod
cache: false
Expand Down
156 changes: 156 additions & 0 deletions .github/workflows/api-tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,156 @@
name: 'API'

on:
# NOTE: no action on `push` and `pull_request` since the API tests need to be run
# against a container that has the latest changes from your code. Therefore, the
# PMM_SERVER_IMAGE should either be the one from your feature build or the local
# devcontainer. One more scenario is when we want to run the API tests on dev-latest
# to see if the tests are in a good shape.
# That said, this workflow is mostly a convenience if you prefer Github to Jenkins.
# https://github.com/Percona-Lab/jenkins-pipelines/blob/master/pmm/pmm2-api-tests.groovy

workflow_dispatch:
inputs:
MYSQL_IMAGE:
description: "MYSQL image version"
default: "percona:5.7"
required: true
type: string
POSTGRESQL_IMAGE:
description: "POSTGRESQL image version"
default: "postgres:12"
required: true
type: string
MONGODB_IMAGE:
description: "MONGODB image version"
default: "percona/percona-server-mongodb:4.4"
required: true
type: string
PMM_SERVER_IMAGE:
description: "PMM Server image version"
default: "perconalab/pmm-server:dev-latest"
required: true
type: string

workflow_call:
inputs:
BRANCH:
description: "The branch to source API tests from"
default: "main"
required: true
type: string
MYSQL_IMAGE:
description: "MYSQL image version"
default: "percona:5.7"
required: true
type: string
POSTGRESQL_IMAGE:
description: "POSTGRESQL image version"
default: "postgres:12"
required: true
type: string
MONGODB_IMAGE:
description: "MONGODB image version"
default: "percona/percona-server-mongodb:4.4"
required: true
type: string
PMM_SERVER_IMAGE:
description: "PMM Server image version"
default: "perconalab/pmm-server:dev-latest"
required: true
type: string

jobs:
test:
name: Tests
runs-on: ubuntu-22.04
env:
PMM_URL: http://admin:[email protected]
BRANCH: ${{ github.event.inputs.BRANCH || 'main' }}
MYSQL_IMAGE: ${{ github.event.inputs.MYSQL_IMAGE || 'percona:5.7' }}
POSTGRESQL_IMAGE: ${{ github.event.inputs.POSTGRESQL_IMAGE || 'postgres:12' }}
MONGODB_IMAGE: ${{ github.event.inputs.MONGODB_IMAGE || 'percona/percona-server-mongodb:4.4' }}
PMM_SERVER_IMAGE: ${{ github.event.inputs.PMM_SERVER_IMAGE || 'perconalab/pmm-server:dev-latest' }}

steps:
- name: Check out code
uses: actions/checkout@v4
with:
ref: ${{ env.BRANCH }}

- name: Login to docker.io registry
uses: docker/login-action@v3
with:
registry: docker.io
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_PASSWORD }}

- name: Run PMM Server
run: |
cat <<-EOF > compose.pmm-server-test.yml
services:
pmm-server:
image: ${{ env.PMM_SERVER_IMAGE }}
container_name: pmm-agent_pmm-server
environment:
- PMM_DEBUG=1
- PERCONA_TEST_CHECKS_INTERVAL=10s
- PERCONA_TEST_PLATFORM_ADDRESS=https://check-dev.percona.com
- PERCONA_TEST_PLATFORM_PUBLIC_KEY=RWTg+ZmCCjt7O8eWeAmTLAqW+1ozUbpRSKSwNTmO+exlS5KEIPYWuYdX
ports:
- 80:80
- 443:443
volumes:
- ./managed/testdata/checks:/srv/checks
EOF
# Run it and wait until it's healthy
docker compose -f compose.pmm-server-test.yml up -d --wait --wait-timeout=100
- name: Build the test image
shell: bash
run: |
docker build -t percona/pmm-api-tests .
- name: Run DB containers
shell: bash
run: |
pushd api-tests
docker compose up test_db # no daemon mode
# TODO: review the provisions below (copied from the Jenkins pipeline)
# MYSQL_IMAGE=${{env.MYSQL_IMAGE}} docker compose up -d mysql
# MONGO_IMAGE=${{env.MONGODB_IMAGE}} docker compose up -d mongo
# POSTGRES_IMAGE=${{env.POSTGRESQL_IMAGE}} docker compose up -d postgres
# docker compose up -d sysbench
popd
- name: Check connectivity to PMM Server
shell: bash
run: curl -f ${{env.PMM_URL}}/ping

- name: Run API tests
shell: bash
run: |
docker run -e PMM_SERVER_URL=${{env.PMM_URL}} \
-e PMM_RUN_UPDATE_TEST=0 \
-e PMM_RUN_STT_TESTS=0 \
--name pmm-api-tests \
--network host \
percona/pmm-api-tests
- name: Get PMM logs
if: ${{ failure() }}
run: curl --insecure ${{env.PMM_URL}}/logs.zip --output ${{ github.workspace }}/logs.zip || true

- name: Upload the logs on failure
if: ${{ failure() }}
uses: actions/upload-artifact@v4
with:
name: "logs.zip"
path: ${{ github.workspace }}/logs.zip

- name: Run debug commands on failure
if: ${{ failure() }}
run: |
echo "----- ENVIRONMENT VARIABLES -----"
env | sort
2 changes: 1 addition & 1 deletion .github/workflows/clean.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ jobs:
env:
# to avoid error due to `go version` accepting -v flag with an argument since 1.15
GOFLAGS: ""
uses: actions/setup-go@v4
uses: actions/setup-go@v5
with:
go-version: ${{ matrix.go.version }}

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ jobs:
uses: actions/checkout@v4

- name: Set up Go release
uses: actions/setup-go@v4
uses: actions/setup-go@v5
with:
go-version-file: ${{ github.workspace }}/go.mod
cache: false
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/qan-api2.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ jobs:
uses: actions/checkout@v4

- name: Set up Go release
uses: actions/setup-go@v4
uses: actions/setup-go@v5
with:
go-version-file: ${{ github.workspace }}/go.mod
cache: false
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/vmproxy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ jobs:
uses: actions/checkout@v4

- name: Set up Go release
uses: actions/setup-go@v4
uses: actions/setup-go@v5
with:
go-version-file: ${{ github.workspace }}/go.mod
cache: false
Expand Down
5 changes: 3 additions & 2 deletions Makefile.include
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ gen-api: ## Generate PMM API

bin/buf generate -v api

for API in api/agentlocalpb api/serverpb api/inventorypb api/managementpb api/managementpb/dbaas api/managementpb/ia api/managementpb/alerting api/managementpb/backup api/managementpb/azure api/managementpb/role api/qanpb api/managementpb/agent api/managementpb/node api/managementpb/service api/platformpb api/userpb; do \
for API in api/agentlocalpb api/serverpb api/inventorypb api/managementpb api/managementpb/dbaas api/managementpb/ia api/managementpb/alerting api/managementpb/backup api/managementpb/dump api/managementpb/azure api/managementpb/role api/qanpb api/managementpb/agent api/managementpb/node api/managementpb/service api/platformpb api/userpb; do \
set -x ; \
bin/swagger mixin $$API/json/header.json $$API/*.swagger.json --output=$$API/json/$$(basename $$API).json --keep-spec-order; \
bin/swagger flatten --with-flatten=expand --with-flatten=remove-unused $$API/json/$$(basename $$API).json --output=$$API/json/$$(basename $$API).json ; \
Expand Down Expand Up @@ -91,6 +91,7 @@ gen-api: ## Generate PMM API
api/managementpb/ia/json/ia.json \
api/managementpb/alerting/json/alerting.json \
api/managementpb/backup/json/backup.json \
api/managementpb/dump/json/dump.json \
api/managementpb/azure/json/azure.json \
api/managementpb/role/json/role.json \
api/managementpb/agent/json/agent.json \
Expand Down Expand Up @@ -127,7 +128,7 @@ clean: clean_swagger ## Remove generated files
find api -name '*.pb.gw.go' -print -delete
find api -name '*.validate.go' -print -delete

for API in api/agentlocalpb api/serverpb api/inventorypb api/managementpb api/managementpb/dbaas api/managementpb/ia api/managementpb/alerting api/managementpb/backup api/managementpb/role api/managementpb/agent api/managementpb/node api/managementpb/service api/qanpb api/platformpb ; do \
for API in api/agentlocalpb api/serverpb api/inventorypb api/managementpb api/managementpb/dbaas api/managementpb/ia api/managementpb/alerting api/managementpb/backup api/management/dump api/managementpb/role api/managementpb/agent api/managementpb/node api/managementpb/service api/qanpb api/platformpb ; do \
rm -fr $$API/json/client $$API/json/models $$API/json/$$(basename $$API).json ; \
done
rm -f api/swagger/swagger.json api/swagger/swagger-dev.json
Expand Down
13 changes: 0 additions & 13 deletions agent/agents/mysql/perfschema/perfschema.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ import (
"fmt"
"io"
"math"
"sync"
"time"

"github.com/AlekSi/pointer" // register SQL driver
Expand All @@ -46,18 +45,6 @@ type (
summaryMap map[string]*eventsStatementsSummaryByDigest
)

// mySQLVersion contains.
type mySQLVersion struct {
version float64
vendor string
}

// versionsCache provides cached access to MySQL version.
type versionsCache struct {
rw sync.RWMutex
items map[string]*mySQLVersion
}

const (
retainHistory = 5 * time.Minute
refreshHistory = 5 * time.Second
Expand Down
108 changes: 0 additions & 108 deletions agent/client/cache/cache.go

This file was deleted.

Loading

0 comments on commit aad27c2

Please sign in to comment.