blob: 66d58fdd74f720892a2e2a56a30da098a493eca0 [file] [log] [blame]
Jamie Hannaford936a5472015-02-10 14:38:28 +01001package instances
2
3import (
4 "testing"
5
Jamie Hannaford2e817322015-02-16 15:29:17 +01006 "github.com/rackspace/gophercloud/pagination"
7 "github.com/rackspace/gophercloud/rackspace/db/v1/backups"
Jamie Hannaford936a5472015-02-10 14:38:28 +01008 th "github.com/rackspace/gophercloud/testhelper"
9 fake "github.com/rackspace/gophercloud/testhelper/client"
10)
11
12func TestGetConfig(t *testing.T) {
13 th.SetupHTTP()
14 defer th.TeardownHTTP()
15
Jamie Hannafordf77fc102015-02-10 14:56:02 +010016 HandleGetConfigSuccessfully(t, instanceID)
Jamie Hannaford936a5472015-02-10 14:38:28 +010017
Jamie Hannafordf77fc102015-02-10 14:56:02 +010018 config, err := GetDefaultConfig(fake.ServiceClient(), instanceID).Extract()
Jamie Hannaford936a5472015-02-10 14:38:28 +010019
20 expected := map[string]string{
21 "basedir": "/usr",
22 "connect_timeout": "15",
23 "datadir": "/var/lib/mysql",
24 "default_storage_engine": "innodb",
25 "innodb_buffer_pool_instances": "1",
26 "innodb_buffer_pool_size": "175M",
27 "innodb_checksum_algorithm": "crc32",
28 "innodb_data_file_path": "ibdata1:10M:autoextend",
29 "innodb_file_per_table": "1",
30 "innodb_io_capacity": "200",
31 "innodb_log_file_size": "256M",
32 "innodb_log_files_in_group": "2",
33 "innodb_open_files": "8192",
34 "innodb_thread_concurrency": "0",
35 "join_buffer_size": "1M",
36 "key_buffer_size": "50M",
37 "local-infile": "0",
38 "log-error": "/var/log/mysql/mysqld.log",
39 "max_allowed_packet": "16M",
40 "max_connect_errors": "10000",
41 "max_connections": "40",
42 "max_heap_table_size": "16M",
43 "myisam-recover": "BACKUP",
44 "open_files_limit": "8192",
45 "performance_schema": "off",
46 "pid_file": "/var/run/mysqld/mysqld.pid",
47 "port": "3306",
48 "query_cache_limit": "1M",
49 "query_cache_size": "8M",
50 "query_cache_type": "1",
51 "read_buffer_size": "256K",
52 "read_rnd_buffer_size": "1M",
53 "server_id": "1",
54 "skip-external-locking": "1",
55 "skip_name_resolve": "1",
56 "sort_buffer_size": "256K",
57 "table_open_cache": "4096",
58 "thread_stack": "192K",
59 "tmp_table_size": "16M",
60 "tmpdir": "/var/tmp",
61 "user": "mysql",
62 "wait_timeout": "3600",
63 }
64
65 th.AssertNoErr(t, err)
66 th.AssertDeepEquals(t, expected, config)
67}
Jamie Hannafordf77fc102015-02-10 14:56:02 +010068
69func TestAssociateWithConfigGroup(t *testing.T) {
70 th.SetupHTTP()
71 defer th.TeardownHTTP()
72
73 HandleAssociateGroupSuccessfully(t, instanceID)
74
75 configGroupID := "{configGroupID}"
76 res := AssociateWithConfigGroup(fake.ServiceClient(), instanceID, configGroupID)
77 th.AssertNoErr(t, res.Err)
78}
Jamie Hannaford2e817322015-02-16 15:29:17 +010079
80func TestListBackups(t *testing.T) {
81 th.SetupHTTP()
82 defer th.TeardownHTTP()
83
84 HandleListBackupsSuccessfully(t, instanceID)
85 count := 0
86
87 ListBackups(fake.ServiceClient(), instanceID).EachPage(func(page pagination.Page) (bool, error) {
88 count++
89 actual, err := backups.ExtractBackups(page)
90 th.AssertNoErr(t, err)
91
92 expected := []backups.Backup{
93 backups.Backup{
94 Created: "2014-06-18T21:23:35",
95 Description: "Backup from Restored Instance",
96 ID: "87972694-4be2-40f5-83f8-501656e0032a",
97 InstanceID: "29af2cd9-0674-48ab-b87a-b160f00208e6",
98 LocationRef: "http://localhost/path/to/backup",
99 Name: "restored_backup",
100 ParentID: "",
101 Size: 0.141026,
102 Status: "COMPLETED",
103 Updated: "2014-06-18T21:24:39",
104 Datastore: backups.Datastore{Version: "5.1", Type: "MySQL", VersionID: "20000000-0000-0000-0000-000000000002"},
105 },
106 }
107
108 th.AssertDeepEquals(t, expected, actual)
109
110 return true, nil
111 })
112
113 if count != 1 {
114 t.Errorf("Expected 1 page, got %d", count)
115 }
116}