Skip to content

Commit

Permalink
Add tuning test
Browse files Browse the repository at this point in the history
- Do not run the tuning test when running bin/test-acceptance

[#147896081]

Signed-off-by: Joseph Palermo <[email protected]>
  • Loading branch information
zankich authored and jpalermo committed Jul 22, 2017
1 parent 3942407 commit f2e1074
Show file tree
Hide file tree
Showing 6 changed files with 240 additions and 1 deletion.
32 changes: 32 additions & 0 deletions assets/tuning/everything_enabled.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
{
"max_connections": "1400",
"character_set_server": "latin1",
"collation_server": "latin1_swedish_ci",
"innodb_buffer_pool_instances": "50",
"innodb_lock_wait_timeout": "200",
"innodb_log_buffer_size": "67108864",
"innodb_flush_log_at_trx_commit": "2",
"innodb_flush_method": "O_DIRECT",
"innodb_strict_mode": "ON",
"max_allowed_packet": "249999360",
"max_heap_table_size": "14999552",
"table_definition_cache": "8000",
"table_open_cache": "1500",
"tmp_table_size": "30000000",
"wsrep_max_ws_rows": "20000",
"wsrep_max_ws_size": "500000000",
"skip_name_resolve": "OFF",
"innodb_log_file_size": "891289600",
"server_audit_events": "CONNECT",
"server_audit_logging": "ON",
"server_audit_excl_users": "cluster-health-logger,quota-enforcer,galera-healthcheck,user1,user2,csv_user1,csv_user2",
"wsrep_cluster_name": "my_cluster",
"userstat": "ON",
"log_bin": "ON",
"expire_logs_days": "3",
"wsrep_debug": "ON",
"wsrep_log_conflicts": "OFF",
"log_queries_not_using_indexes": "ON",
"event_scheduler": "ON",
"local_infile": "ON"
}
120 changes: 120 additions & 0 deletions assets/tuning/everything_enabled.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,120 @@
---
- type: replace
path: /properties/cf_mysql/mysql/max_connections?
value: 1400

- type: replace
path: /properties/cf_mysql/mysql/character_set_server?
value: latin1

- type: replace
path: /properties/cf_mysql/mysql/collation_server?
value: latin1_swedish_ci

- type: replace
path: /properties/cf_mysql/mysql/innodb_buffer_pool_instances?
value: 50

- type: replace
path: /properties/cf_mysql/mysql/innodb_lock_wait_timeout?
value: 200

- type: replace
path: /properties/cf_mysql/mysql/innodb_log_buffer_size?
value: 67108864

- type: replace
path: /properties/cf_mysql/mysql/innodb_flush_log_at_trx_commit?
value: 2

- type: replace
path: /properties/cf_mysql/mysql/innodb_flush_method?
value: O_DIRECT

- type: replace
path: /properties/cf_mysql/mysql/innodb_strict_mode?
value: true

- type: replace
path: /properties/cf_mysql/mysql/max_allowed_packet?
value: 249999360

- type: replace
path: /properties/cf_mysql/mysql/max_heap_table_size?
value: 14999552

- type: replace
path: /properties/cf_mysql/mysql/table_definition_cache_size?
value: 8000

- type: replace
path: /properties/cf_mysql/mysql/table_open_cache?
value: 1500

- type: replace
path: /properties/cf_mysql/mysql/tmp_table_size?
value: 30000000

- type: replace
path: /properties/cf_mysql/mysql/wsrep_max_ws_rows?
value: 20000

- type: replace
path: /properties/cf_mysql/mysql/wsrep_max_ws_size?
value: 500000000

- type: replace
path: /properties/cf_mysql/mysql/skip_name_resolve?
value: false

- type: replace
path: /properties/cf_mysql/mysql/ib_log_file_size?
value: 850

- type: replace
path: /properties/cf_mysql/mysql/server_audit_events?
value: connect

- type: replace
path: /properties/cf_mysql/mysql/server_audit_excluded_users?
value: [user1, user2]

- type: replace
path: /properties/cf_mysql/mysql/server_audit_excluded_users_csv?
value: csv_user1,csv_user2

- type: replace
path: /properties/cf_mysql/mysql/cluster_name?
value: my_cluster

- type: replace
path: /properties/cf_mysql/mysql/userstat?
value: true

- type: replace
path: /properties/cf_mysql/mysql/binlog_enabled?
value: true

- type: replace
path: /properties/cf_mysql/mysql/binlog_expire_days?
value: 3

- type: replace
path: /properties/cf_mysql/mysql/wsrep_debug?
value: true

- type: replace
path: /properties/cf_mysql/mysql/log_conflicts?
value: false

- type: replace
path: /properties/cf_mysql/mysql/log_queries_not_using_indexes?
value: true

- type: replace
path: /properties/cf_mysql/mysql/event_scheduler?
value: "ON"

- type: replace
path: /properties/cf_mysql/mysql/enable_local_file?
value: "ON"
2 changes: 1 addition & 1 deletion bin/test-acceptance
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,5 @@ source $MY_DIR/test-options.sh

ginkgo $GINKGO_OPTS \
"$@" \
-r -skipPackage="failover,standalone" \
-r -skipPackage="failover,standalone,tuning" \
"${TEST_DIR}"
11 changes: 11 additions & 0 deletions cf-mysql-service/tuning/tuning_suite_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package tuning_test

import (
"testing"

"github.com/cloudfoundry-incubator/cf-mysql-acceptance-tests/helpers"
)

func TestService(t *testing.T) {
helpers.PrepareAndRunTests("Tuning", t, false)
}
71 changes: 71 additions & 0 deletions cf-mysql-service/tuning/tuning_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
package tuning_test

import (
"database/sql"
"encoding/json"
"fmt"
"io/ioutil"

"github.com/cloudfoundry-incubator/cf-mysql-acceptance-tests/helpers"
_ "github.com/go-sql-driver/mysql"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
)

var _ = Describe("MySQL Server Tuning Configuration", func() {
var (
db *sql.DB
)

BeforeEach(func() {
standalone := helpers.TestConfig.Standalone
connectionString := fmt.Sprintf("%s:%s@tcp(%s:%d)/",
standalone.MySQLUsername,
standalone.MySQLPassword,
standalone.Host,
standalone.Port)

var err error
db, err = sql.Open("mysql", connectionString)
Expect(err).ToNot(HaveOccurred())

err = db.Ping()
Expect(err).ToNot(HaveOccurred())
})

AfterEach(func() {
err := db.Close()
Expect(err).ToNot(HaveOccurred())
})

It("Correctly sets MySQL internal variables based on values in the manifest", func() {
rows, err := db.Query("SHOW VARIABLES;")
Expect(err).ToNot(HaveOccurred())

mysqlVariables := map[string]string{}

defer rows.Close()
for rows.Next() {
var name, value string
err = rows.Scan(&name, &value)
Expect(err).ToNot(HaveOccurred())
mysqlVariables[name] = value
}

err = rows.Err()
Expect(err).ToNot(HaveOccurred())

buf, err := ioutil.ReadFile(helpers.TestConfig.Tuning.ExpectationFilePath)
Expect(err).ToNot(HaveOccurred())

compareConfig := map[string]string{}

if err := json.Unmarshal(buf, &compareConfig); err != nil {
Expect(err).ToNot(HaveOccurred())
}

for k, v := range compareConfig {
Expect(mysqlVariables[k]).To(Equal(v), fmt.Sprintf("mismatch in %v", k))
}
})
})
5 changes: 5 additions & 0 deletions helpers/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,10 @@ type Standalone struct {
Port int `json:"port"`
}

type Tuning struct {
ExpectationFilePath string `json:"expectation_file_path"`
}

type MysqlIntegrationConfig struct {
services.Config
BrokerHost string `json:"broker_host,omitempty"`
Expand All @@ -45,6 +49,7 @@ type MysqlIntegrationConfig struct {
Proxy Proxy `json:"proxy"`
Standalone Standalone `json:"standalone,omitempty"`
StandaloneOnly bool `json:"standalone_only,omitempty"`
Tuning Tuning `json:"tuning,omitempty"`
}

func (c MysqlIntegrationConfig) AppURI(appname string) string {
Expand Down

0 comments on commit f2e1074

Please sign in to comment.