Skip to content

Commit

Permalink
move mysql to github action services
Browse files Browse the repository at this point in the history
  • Loading branch information
atoulme committed Mar 24, 2024
1 parent 7e1f0cc commit f9b8dd5
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 51 deletions.
4 changes: 4 additions & 0 deletions .github/workflows/integration-test.yml
Expand Up @@ -221,6 +221,10 @@ jobs:
image: quay.io/splunko11ytest/redis_server:latest
ports:
- "6379:6379"
mysql:
image: quay.io/splunko11ytest/mysql:latest
ports:
- "3306:3306"
strategy:
matrix:
ARCH: [ "amd64", "arm64" ]
Expand Down
6 changes: 6 additions & 0 deletions docker/mysql/Dockerfile
@@ -0,0 +1,6 @@
FROM mysql:latest
ENV MYSQL_DATABASE testdb
ENV MYSQL_USER testuser
ENV MYSQL_PASSWORD testpass
ENV MYSQL_ROOT_PASSWORD testpass
COPY init.sql /docker-entrypoint-initdb.d
12 changes: 12 additions & 0 deletions docker/mysql/init.sql
@@ -0,0 +1,12 @@
grant PROCESS on *.* TO 'testuser'@'%';
CREATE USER 'otelu'@'localhost' IDENTIFIED BY 'otelp';
GRANT ALL PRIVILEGES ON *.* TO 'otelu'@'localhost' WITH GRANT OPTION;

CREATE DATABASE otel;

USE otel;

CREATE TABLE dummytable (myfield VARCHAR(20));

INSERT INTO dummytable VALUES ('bar'), ('foo');
flush privileges;
9 changes: 2 additions & 7 deletions tests/receivers/mysql/bundled_test.go
Expand Up @@ -18,7 +18,6 @@ package tests

import (
"fmt"
"path"
"runtime"
"testing"

Expand All @@ -29,14 +28,10 @@ func TestMysqlDockerObserver(t *testing.T) {
if runtime.GOOS == "darwin" {
t.Skip("unable to share sockets between mac and d4m vm: https://github.com/docker/for-mac/issues/483#issuecomment-758836836")
}
port := "3306"
mysql := []testutils.Container{testutils.NewContainer().WithContext(
path.Join(".", "testdata", "server"),
).WithName("mysql").WithExposedPorts(port + ":" + port).WillWaitForPorts(port).WillWaitForLogs("")}
testutils.SkipIfNotContainerTest(t)

testutils.AssertAllMetricsReceived(t, "bundled.yaml", "otlp_exporter.yaml",
mysql, []testutils.CollectorBuilder{
nil, []testutils.CollectorBuilder{
func(c testutils.Collector) testutils.Collector {
cc := c.(*testutils.CollectorContainer)
cc.Container = cc.Container.WithBinds("/var/run/docker.sock:/var/run/docker.sock:ro")
Expand All @@ -53,7 +48,7 @@ func TestMysqlDockerObserver(t *testing.T) {
"--set", `splunk.discovery.extensions.k8s_observer.enabled=false`,
"--set", `splunk.discovery.extensions.host_observer.enabled=false`,
"--set", `splunk.discovery.receivers.mysql.config.username=root`,
"--set", `splunk.discovery.receivers.mysql.config.password=testuser`,
"--set", `splunk.discovery.receivers.mysql.config.password=testpass`,
)
},
},
Expand Down
11 changes: 3 additions & 8 deletions tests/receivers/mysql/mysql_test.go
Expand Up @@ -18,7 +18,6 @@
package tests

import (
"path"
"testing"

"github.com/signalfx/splunk-otel-collector/tests/testutils"
Expand All @@ -29,18 +28,14 @@ import (
// The reported telemetry may need to be updated (resource metric file changes),
// They can detect breaking changes or bugs that may have been missed upstream.
func TestMysqlIntegration(t *testing.T) {
port := "3306"
mysql := []testutils.Container{testutils.NewContainer().WithContext(
path.Join(".", "testdata", "server"),
).WithName("mysql").WithExposedPorts(port + ":" + port).WillWaitForPorts(port).WillWaitForLogs("X Plugin ready for connections. Bind-address:")}

testutils.AssertAllMetricsReceived(t, "all.yaml", "all_metrics_config.yaml",
mysql, []testutils.CollectorBuilder{
nil, []testutils.CollectorBuilder{
func(collector testutils.Collector) testutils.Collector {
return collector.WithEnv(map[string]string{
"MYSQLDB_ENDPOINT": "127.0.0.1:" + port,
"MYSQLDB_ENDPOINT": "127.0.0.1:3306",
"MYSQLDB_USERNAME": "root",
"MYSQLDB_PASSWORD": "testuser",
"MYSQLDB_PASSWORD": "testpass",
})
},
},
Expand Down
36 changes: 0 additions & 36 deletions tests/receivers/smartagent/collectd-mysql/collectd_mysql_test.go
Expand Up @@ -17,10 +17,8 @@
package tests

import (
"context"
"database/sql"
"fmt"
"io"
"strings"
"testing"
"time"
Expand All @@ -39,42 +37,11 @@ const (
dbName = "testdb"
)

var mysqlServer = testutils.NewContainer().WithImage("mysql:latest").WithEnv(
map[string]string{
"MYSQL_DATABASE": dbName,
"MYSQL_USER": user,
"MYSQL_PASSWORD": password,
"MYSQL_ROOT_PASSWORD": password,
}).WithExposedPorts("3306:3306").WithName("mysql-server").WithNetworks(
"mysql",
).WillWaitForPorts("3306").WillWaitForLogs(
"MySQL init process done. Ready for start up.",
"ready for connections. Bind-address:",
)

func TestCollectdMySQLProvidesAllMetrics(t *testing.T) {
tc := testutils.NewTestcase(t)
defer tc.PrintLogsOnFailure()
defer tc.ShutdownOTLPReceiverSink()

cntrs, shutdown := tc.Containers(mysqlServer)
defer shutdown()

ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
defer cancel()
rc, r, err := cntrs[0].Exec(ctx, []string{"mysql", "-uroot", "-ptestpass", "-e", "grant PROCESS on *.* TO 'testuser'@'%'; flush privileges;"})
if r != nil {
defer func() {
if t.Failed() {
out, readErr := io.ReadAll(r)
require.NoError(t, readErr)
fmt.Printf("mysql:\n%s\n", string(out))
}
}()
}
require.NoError(t, err)
require.Zero(t, rc)

cfg := mysql.Config{
User: user,
Passwd: password,
Expand Down Expand Up @@ -112,9 +79,6 @@ func TestCollectdIsolatedLogger(t *testing.T) {
tc := testutils.NewTestcase(t)
defer tc.ShutdownOTLPReceiverSink()

_, shutdown := tc.Containers(mysqlServer)
defer shutdown()

for _, test := range []struct {
config string
expectedLogContent map[string]bool
Expand Down

0 comments on commit f9b8dd5

Please sign in to comment.