Commit graph

289 commits

Author SHA1 Message Date
Morgan Haskel
23c192df9f Merge pull request #634 from cyberious/ResourceTest
MODULES-1520 add test to assert it does not break
2015-01-02 11:52:06 -05:00
Travis Fields
d9d02718b8 MODULES-1520 add test to assert it does not break 2014-12-31 16:48:54 -08:00
Morgan Haskel
f92a24ef3d MODULES-1520 - update username validation
Don't fail on validation where the user isn't quoted with special
characters. The providers quote these strings by default.
2014-12-31 11:50:48 -08:00
Morgan Haskel
3c872abcd2 Remove mysqltuner, fetch with staging instead
mysqltuner is licensed under GPL so we don't want to package it with the
module.
2014-12-16 10:52:39 -08:00
Morgan Haskel
93615453b5 Use puppet() instead of shell() to install module dependencies 2014-12-12 12:55:31 -08:00
Sébastien Lavoie
60838a5837 Reworked all identifier quoting detections
Otherwise, trying to manage `debian-sys-maint` will fail miserably, quoted or not.

Fixes #609
2014-11-27 12:47:09 -05:00
Michael Chapman
fe0365e80d Support size 15 and 16 quoted usernames
As usernames containing special characters must be quoted, they
may have two extra characters that are not counted against the
size limit of 16 characters. This patch adds a regex to handle
this case.
2014-11-20 17:23:11 +11:00
Morgan Haskel
11fb01c736 Fix test issues
Remove the dependency on stdlib 4.x puppetlabs/puppetlabs-mysql#574
introduced, add some input validation, and improve test checks.
2014-11-14 13:16:01 -08:00
Igor Galić
ab84a671f9 Merge pull request #574 from Mylezeem/allow_multiple_import_at_a_time
(MODULES-1338) Allow mysql::db to import several files
2014-11-14 17:15:13 +01:00
Mason Malone
4f0d4311d9 Fix regression in username validation
Commit cdd7132ff9 added logic to catch invalid database usernames,
but the regex it uses fails to match usernames with special characters that are properly quoted,
causing errors with usernames that used to work in versions < 3.0.0. This fixes the regex so that
if the username is quoted, anything is allowed between the quotes.

From the docs (http://dev.mysql.com/doc/refman/5.5/en/identifiers.html):
"Permitted characters in quoted identifiers include the full Unicode Basic Multilingual Plane (BMP),
except U+0000"
2014-11-13 18:18:02 -05:00
Yanis Guenane
5e6a1c418a (MODULES-1338) Allow mysql::db to import several files
A user might need to import several files on database creation.
Currently the module only allows the import of a single file.
This commit allows one to, from now on, import severals.

Before :

  mysql::db { 'test' :
    sql => '/tmp/my_import1.sql',
  }

Now :

  mysql::db { 'test' :
    sql => [
      '/tmp/my_import1.sql',
      '/tmp/my_import2.sql',
    ]
  }
2014-11-13 14:17:50 -05:00
Maxence Dunnewind
cdd7132ff9 Improve checks for MySQL user's name.
As per http://dev.mysql.com/doc/refman/5.5/en/identifiers.html , MySQL
allows for more than '\w-'. This commit improves the check to ensure
that:
 - if username only contains [0-9a-zA-Z$_], it might be quoted. It is
   not a requirement though
 - if username contains anything else, it MUST be quoted

I kept 2 checks, but the 2nd one can probably be removed (I can't find a
username which match the 2nd one but not the first.)
2014-11-06 08:51:07 +01:00
Morgan Haskel
91e57102d6 Merge pull request #580 from cmurphy/fix_bzcat
Install bzip2 on RHEL 7 and Fedora hosts
2014-10-07 18:52:11 -04:00
Colleen Murphy
c291be44eb Install bzip2 on RHEL 7 and Fedora hosts
The backup script needs the bzcat command, which does not come
installed on RHEL 7 and Fedora hosts by default. This patch installs
the bzip2 package before attempting to run tests that use bzcat.
2014-10-07 15:43:57 -07:00
Igor Galić
400d3b29cf Merge pull request #570 from fnerdwq/mysql_grant_column_privs
(MODULES-552) Add capability to specify column_privileges
2014-10-07 15:46:08 +02:00
Franz Schwartau
02564bfe08 Add new parameters create_root_user and create_root_my_cnf.
This allows the galera module and others to write ${::root_home}/.my.cnf
independently from create the mysql user. This is useful for cluster
setups where you want to create ${::root_home}/.my.cnf on every node
but create the user only once.
2014-10-06 10:53:30 +02:00
Frederik Wagner
f88719b52f (MODULES-552) Add capability to specify column_privileges 2014-10-06 08:11:01 +02:00
Morgan Haskel
ba4830cbbe Trailing commas were breaking things on 1.8.7 2014-09-19 09:42:35 -07:00
Matthew Monaco
d986a87558 mysql_database: prevent syntax error with collate=>'binary'
On MySQL v5.5.38, creating a database such as:

	CREATE DATABASE `mydb` CHARACTER SET binary COLLATE binary;

seems to hit a parser bug. A workaround is simply to quote COLLATE
`binary`. As the quoting is harmless, and for aesthetics, quote both
the CHARACTER SET and COLLATE arguments.
2014-09-15 23:22:59 -06:00
Igor Galić
f8dca35b8e Merge pull request #559 from nhinds/file_per_database_username_and_password
(MODULES-1287) Pass the backup credentials to 'SHOW DATABASES'
2014-09-08 14:54:17 +02:00
Morgan Haskel
058053b5bc Update spec_helper for more consistency 2014-08-28 17:49:18 -04:00
Nicholas Hinds
462dbf7a1c (MODULES-1287) Pass the backup credentials to 'SHOW DATABASES'
Pass the backup username and password to mysql when running SHOW DATABASES in
mysqlbackup.sh if `file_per_database` is true and `backupdatabases` is empty.
2014-08-24 15:44:47 +12:00
Ashley Penney
9cb685da47 Split out the template tests and rework both sets of tests. 2014-08-14 14:55:20 -04:00
Ashley Penney
c4e4a56a47 Fix this to be more concise and consistent.
This was a surprisingly large amount of work.
2014-08-08 16:47:45 -04:00
Ashley Penney
5b10f3e773 Clean these up to be more readable. 2014-08-08 16:47:44 -04:00
Ashley Penney
00a191f9ed Convert specs to RSpec 2.99.1 syntax with Transpec
This conversion is done by Transpec 2.3.6 with the following command:
    transpec -f -c "bundle exec rake spec"

* 69 conversions
    from: it { should ... }
      to: it { is_expected.to ... }

* 48 conversions
    from: obj.should
      to: expect(obj).to

* 34 conversions
    from: == expected
      to: eq(expected)

* 4 conversions
    from: it { should_not ... }
      to: it { is_expected.not_to ... }

* 3 conversions
    from: obj.should_not
      to: expect(obj).not_to

* 2 conversions
    from: lambda { }.should
      to: expect { }.to

* 2 conversions
    from: pending
      to: skip

For more details: https://github.com/yujinakayama/transpec#supported-conversions
2014-08-08 16:47:44 -04:00
Ashley Penney
bb205ad2f0 Remove all the deprecated code. 2014-08-08 14:13:22 -04:00
Ashley Penney
cf2ffc6821 Handle graceful failure on RHEL4 and improve the messaging. 2014-08-08 11:55:31 -04:00
Ashley Penney
138820b3b8 Don't check the variable here, we can trust mysql to work. 2014-08-07 17:53:26 -04:00
Hunter Haugen
1812fbca25 Rewrite some of the unit tests to work on more platforms.
This commit introduces puppet_facts, a gem that allows easier testing
against PE platforms.  We're using this gem to automatically parse the
metadata.json and test against appropriate versions of PE on platforms
we support.

We start by only running against centos-6-x86_64 and ubuntu 14.04 on a
regular basis but this is implemented as an ENV so it can be overwritten
by CI systems to test against all PE platforms.
2014-08-07 16:27:17 -04:00
Ashley Penney
994ac1a058 Rebuild the acceptance tests. 2014-08-07 15:52:19 -04:00
Ray Lehtiniemi
548952a6f9 Prevent ERROR 1008 in mysql_database provider
Check for database existence when dropping to prevent

  ERROR 1008 (HY000): Can't drop database 'test'; database doesn't exist

Signed-off-by: Ray Lehtiniemi <rayl@mail.com>
2014-07-23 21:41:16 -06:00
I'm on Vacation until 18th of July
70cafdc283 Merge pull request #509 from xbezdick/master
Parametrize !includedir
2014-07-23 12:38:18 +02:00
Gael Chamoulaud
7b3cdd234a Adds Support for CentOS and Scientific Linux 7
CentOS Project has adopted a new rule for versioning numbers. The major number
matches the RHEL major number, but the minor number is generated from the
release date. For example, CentOS 7.0.1406.

Uses $::operatingsystemmajrelease instead of $::operatingsystemrelease for
avoiding issue like "Comparison of String with 7 failed" for CentOS 7.

Signed-off-by: Gael Chamoulaud <gchamoul@redhat.com>
2014-07-21 20:13:26 +02:00
Hunter Haugen
52d44be30f Merge pull request #536 from apenney/mysql_install
Handle changing the datadir properly.
2014-07-08 14:55:11 -07:00
Ashley Penney
5959715ff6 Rework the mysql initdb functionality.
This reworks a previously unmerged PR to clean up the code a little and
adds a test for it.
2014-07-08 12:53:20 -04:00
Jaakko
3cfbb581cc Change grant provider to ignore grants for non existing users.
In the grant provider users are fetched by querying mysql.user table. Grants
for those users are fetched using show grants for... syntax. This can lead to
errors, when some of the users in mysql.user table do not have currently
active grants.

This happens at least when MySQL is started with --skip-name-resolve option,
when there are users with the hostname part specified as a FQDN. Such users are
created by mysql_install_db. This leads to problems if mysql::account_security
is included for the node and skip-name-resolve is specified in override_options
hash for mysql::server.

Includes acceptance test for the change.
2014-06-17 13:07:56 +02:00
Jaakko
16002dfe09 Fix acceptance test for mysql::bindings.
Fix acceptance test for bindings to use correct parameter names, when
instantiating mysql::bindings class. Fix client and server dev package names
for couple of distros.
2014-06-11 18:01:16 +02:00
Ashley Penney
d884e2fc1e Merge pull request #522 from cmurphy/fix_mysql_grant_MODULES-1040
Require title of mysql_grant resource to match form user/table
2014-06-05 13:07:40 -04:00
Igor Galić
b39ebdcf74 Merge pull request #505 from larsks/bz/1093367
lowercase hostname values in qualified usernames
2014-06-05 12:17:04 +02:00
Colleen Murphy
07b661dcea Require title of mysql_grant resource to match form user/table
This addresses https://tickets.puppetlabs.com/browse/MODULES-1040.
The user parameter is required to have the form username@host. A grant
is identified in the instances method by a name of the form
username@host/table. The resource will fail to be identified as already
existing if the name given to the resource does not match this form.
2014-06-04 10:44:36 -07:00
Lars Kellogg-Stedman
0afb8f09e8 lowercase hostname values in qualified usernames
MySQL/MariaDB automatically downcase hostnames:

  MariaDB [mysql]> create user 'testuser'@'HOSTNAME';
  MariaDB [mysql]> select user,host from user where host = 'hostname';
  +----------+----------+
  | user     | host     |
  +----------+----------+
  | testuser | hostname |
  +----------+----------+

This causes problems when a mysql_user or datbase_user has an hostname
with non-lowercase characters:

  database_user { "root@HOSTNAME":
    ensure => absent,
  }

The SELECT statements used to determine if the user exists will fail
because the comparisons use "HOSTNAME" but the database has "hostname".
This patch forces the hostname part of "user@hostname" to lower case in
the custom type definitions.
2014-06-04 09:30:45 -04:00
Lukas Bezdicka
26204437ef Prametrize !includedir
Hardcoded path provided by puppet is now replaced by providing only the final directory as on
most systems includedir is provided by package and it's matter of user to provide it if he
wants to override it. This also allows disabling including at all.
2014-06-04 14:07:49 +02:00
William Van Hevelingen
669466c315 RSpec renamed be_true to be_truthy in 3.0
This commits updates the spec tests to use the renamed function.
2014-06-03 23:31:19 -07:00
Igor Galić
6769677e74 Merge pull request #510 from Aethylred/dev_libs
Install MySQL client and daemon dev libraries.
2014-06-03 06:34:43 +02:00
Ashley Penney
8f73cfcce0 Fix test so it doesn't fail on deprecation warnings. 2014-05-29 14:49:00 -04:00
Aaron Hicks
b2090194f5 Install MySQL client and daemon dev libraries. 2014-05-19 09:41:25 +12:00
Morgan Haskel
3871ca4206 Fixes to get tests running on RHEL5.
Existing EPEL addition in spec_helper_acceptance wasn't actually working, so pulled in stahnma-epel and applied that in the bindings test, since that's the only place it's actually required.
2014-05-12 12:32:20 -04:00
Morgan Haskel
d8a5043cc7 Fix the path for the hiera file. 2014-05-09 17:15:09 -04:00
Ashley Penney
b719956252 Replace the symlink with the actual file to resolve a PMT issue. 2014-05-09 16:53:12 -04:00
Ashley Penney
1999625fe2 Missed a couple of tests to gate off for unsupported platforms. 2014-05-09 16:53:11 -04:00
Ashley Penney
2bf1759f76 Fix hiera.yaml creation on PE. 2014-05-09 16:53:11 -04:00
Morgan Haskel
c57c762810 Package rename in Ubuntu 14.04. 2014-05-09 16:39:10 -04:00
Morgan Haskel
625cdf0e9f Allow the tests to run on RHEL7. 2014-05-09 15:54:08 -04:00
Morgan Haskel
bb4640d64a Change package/service for MariaDB. 2014-05-09 15:35:16 -04:00
Morgan Haskel
ad5381d67a Fix to install ruby-mysql from gem. 2014-05-09 15:11:57 -04:00
Morgan Haskel
7c16c52ef4 Try to add some checks so the test doesn't do an rm -rf / 2014-05-09 13:58:46 -04:00
Morgan Haskel
a6bacbd144 Fix backup test, install bzip2. 2014-05-09 13:05:00 -04:00
Ashley Penney
81a1a19f24 Improve this so it works on Ubuntu 14.04. 2014-05-02 19:52:05 +02:00
Ashley Penney
7f4c067350 Remove all rspec-system traces. 2014-04-24 22:05:43 +02:00
Igor Galić
aa82f83ace Merge pull request #500 from nerdlich/patch-1
User needs PROCESS privilege when doing file-per-database backup
2014-04-22 14:22:54 +02:00
nerdlich
b40865d740 Backup user needs PROCESS privilege when doing file-per-database backups
The following error occured:
mysqldump: Couldn't execute 'SELECT /*!40001 SQL_NO_CACHE */ * FROM `INNODB_BUFFER_PAGE`': Access denied; you need (at least one of) the PROCESS privilege(s) for this operation (1227)
2014-04-22 13:08:58 +02:00
Igor Galić
50612ab6ff fix spec tests, by adding osrelease facts 2014-04-22 12:38:29 +02:00
Ashley Penney
71d1f24bd9 Merge pull request #457 from igalic/independent-backup
mysqlbackup.sh should be able to find mysql
2014-04-10 13:46:19 -04:00
Pan
2834498e4d Allow use different name for db resource other than db name
When defining the mysql::db as exported resources, there are chances that the
same resource names are defined across the site, which will cause puppet agent
fail. By adding an optional dbname parameter, default to the $name, it allows the
resouce name to be defined differently, e.g. ${dbname}_${domain}.
Also updated test and docs for dbname parameter and add acceptance test for
dbname parameter feature
2014-03-15 13:38:13 -07:00
Ashley Penney
ec1cc59d03 Merge pull request #479 from igalic/better-backup-test
backup script test: Actually loop through a list
2014-03-06 14:48:04 -05:00
Robin Gloster
5c8d97f81b add test for ssl-disable 2014-03-04 14:58:37 +01:00
Igor Galić
53af16e601 backup script test: Actually loop through a list
we do this by creating more than one database to backup.
2014-03-02 13:30:30 +01:00
Ben Kero
ce6effe736 change box parameter to ensure vbox436 on centos65 type in acceptance test 2014-02-26 14:10:34 -08:00
Ben Kero
86d2051a5e change vbox version and ensure correct path 2014-02-26 14:09:02 -08:00
Ben Kero
046580323e add centos-65-x64 acceptance test yml file, slight change from 64 2014-02-26 14:04:09 -08:00
Ashley Penney
d1f4597e47 Add unsupported infrastructure for excluding OSes we can't test on. 2014-02-26 17:54:48 +00:00
Ashley Penney
e7f1e8de9b Last SLES fix, don't use the deprecated parameter name. 2014-02-26 16:39:59 +00:00
Ashley Penney
c3a3e3ae13 Further SLES fixes to tests. 2014-02-26 15:45:38 +00:00
Ashley Penney
2d1a9f981a This fixes:
* Bindings on SLES
* Makes sure we don't kill the service while testing conf file locations.
2014-02-26 14:54:54 +00:00
Ashley Penney
cbe562b5de As we're deleting /etc/my.cnf, lets not restart MySQL in the middle
of this and cause a terrible explosion.
2014-02-25 01:21:08 +00:00
Ashley Penney
6271f71aa8 Fix the case of this, ARGH. 2014-02-25 01:18:45 +00:00
Ashley Penney
6a93d67bb8 Make this work in SLES as well As RedHat. 2014-02-24 20:39:08 +00:00
Ashley Penney
820344f13a This should help tests on Oracle 6, the lack of epel was breaking the binding
tests.
2014-02-24 20:14:00 +00:00
Dan Carley
b7445ad859 [#434] Acceptance tests for mysql_database
Includes a test for the regression fixed in 30ce3e0.

NB: The `ensure => present` on the resource without any `charset` or
`collate` arguments is intentional because of issue described in #458
2014-02-20 16:57:51 +00:00
Igor Galić
d2b24e40d3 mysqlbackup.sh should be able to find mysql
anywhere. This should enable use to use mysql::server::backup
idependantly, even if mysql is preinstalled, and preinstalled in non
standard locations
2014-02-20 17:17:41 +01:00
Ashley Penney
f107531113 Fix this test for Debian. This is a total hack for now. 2014-02-18 20:33:52 -05:00
Ashley Penney
5eb6e7084d Fixes for Ubuntu/Debian. 2014-02-18 16:25:42 -05:00
Ashley Penney
30ce3e0e12 Repair this by ensuring calls to mysql include the database name.
A prior commit accidently broke this, meaning that mysql_database
was querying the mysql defaults instead of each individual database
when trying to determine the current collate settings.
2014-02-18 14:38:21 -05:00
Ashley Penney
27a70f5b52 Update nodesets. 2014-02-12 19:30:51 -05:00
Ashley Penney
a38e37546a Fix this so it installs PE appropriately. 2014-02-12 19:27:24 -05:00
Igor Galić
12ef27bc72 Merge pull request #445 from Phil0xF7/fix_multiple_rpm_install
Add check for puppet rpm before trying to install
2014-02-12 11:03:16 +01:00
Phil Pham
e1eed1c3eb update to install package using yum instead of rpm 2014-02-11 14:51:56 -08:00
Ashley Penney
eee60088dd (maint) Fix the specs due to changes to backup. 2014-02-11 17:10:35 -05:00
Ashley Penney
aefbf567c5 Merge pull request #443 from igalic/fix-failing-backup-spec
Fix failing backup spec test
2014-02-10 17:07:20 -05:00
Phillip Pham
92046f6a35 Add check for puppet rpm before trying to install
This fixes an issue where subsequent tests will fail when the RS_PROVISION=no and RS_DESTROY=no flag is set for centos. The error is caused by attempting to install the puppet rpm on a machine that already has the puppet rpm installed.
2014-02-07 16:32:57 -08:00
Igor Galić
51b09b7bc8 Fix failing backup spec tests
This partially reverts 7224f12c25
since after #416 the warnings are actually fixed at the source
2014-02-06 17:21:49 +01:00
Igor Galić
63e0da0b71 option to specify a script that runs after backups
This script could be used to sync backups to a central server, or just
to create a file to let external scripts know that backups are
(sucessfully) done and can be picked up.

The postscript option (defaults to false) and can be either a string or
an array of strings. These strings will be directly put into the
mysqlbackup.sh and as such can either be shell commands, or externally
managed files.
2014-02-06 16:44:07 +01:00
John Bond
10f346eaca Add logic to ignore mysql.events 2014-01-30 12:31:21 +01:00
Igor Galić
c747ea7ab5 Merge pull request #422 from stevesaliman/master
fixed a quoting problem with the mysql_database provider
2014-01-25 03:50:23 -08:00
Ashley Penney
3f9f0f632f Merge pull request #428 from radford/mysql-equates-dash-and-underscore
mysql_deepmerge should treat underscore and dash equivalently, as mysql does
2014-01-24 12:16:50 -08:00
Steve Saliman
80b97d295d Fixed a couple of failing tests 2014-01-24 13:06:34 -07:00
Jim Radford
16baff686c mysql_deepmerge should treat underscore and dash equivalently, as mysql does 2014-01-23 22:41:58 -08:00
Jim Radford
136b1aa646 Allow options with values of false to override things that mysql default to true
instead of being elided, leaving the default.
2014-01-23 16:53:57 -08:00
Dejan Golja
4f12b0c7f9 Add system test to cover procedure creation scenario 2014-01-20 23:56:26 +11:00