[ARVADOS] created: 1.3.0-2580-gf7a456442

Git user git at public.arvados.org
Mon May 18 19:38:00 UTC 2020


        at  f7a456442db1b4513742ed7970167c044a0ef8f4 (commit)


commit f7a456442db1b4513742ed7970167c044a0ef8f4
Author: Tom Clegg <tom at tomclegg.ca>
Date:   Mon May 18 15:37:08 2020 -0400

    16319: Specify en_US.UTF-8 collation when creating test database.
    
    Arvados-DCO-1.1-Signed-off-by: Tom Clegg <tom at tomclegg.ca>

diff --git a/lib/install/deps.go b/lib/install/deps.go
index 4e1dc7374..507815c9d 100644
--- a/lib/install/deps.go
+++ b/lib/install/deps.go
@@ -311,7 +311,7 @@ rm ${zip}
 			}
 			defer func() {
 				cmd.Process.Signal(syscall.SIGTERM)
-				logger.Infof("sent SIGTERM; waiting for postgres to shut down")
+				logger.Info("sent SIGTERM; waiting for postgres to shut down")
 				cmd.Wait()
 			}()
 			for deadline := time.Now().Add(10 * time.Second); ; {
@@ -334,6 +334,32 @@ rm ${zip}
 			// might never have been run.
 		}
 
+		// If the en_US.UTF-8 locale wasn't installed when
+		// postgresql initdb ran, it needs to be added
+		// explicitly before we can use it in our test suite.
+		for _, collname := range []string{"en_US", "en_US.UTF-8"} {
+			cmd := exec.Command("sudo", "-u", "postgres", "psql", "-t", "-c", "SELECT 1 FROM pg_catalog.pg_collation WHERE collname='"+collname+"' AND collcollate IN ('en_US.UTF-8', 'en_US.utf8')")
+			cmd.Dir = "/"
+			out, err2 := cmd.CombinedOutput()
+			if err != nil {
+				err = fmt.Errorf("error while checking postgresql collations: %s", err2)
+				return 1
+			}
+			if strings.Contains(string(out), "1") {
+				logger.Infof("postgresql supports collation %s", collname)
+			} else {
+				cmd = exec.Command("sudo", "-u", "postgres", "psql", "-c", "CREATE COLLATION \""+collname+"\" (LOCALE = \"en_US.UTF-8\")")
+				cmd.Stdout = stdout
+				cmd.Stderr = stderr
+				cmd.Dir = "/"
+				err = cmd.Run()
+				if err != nil {
+					err = fmt.Errorf("error adding postgresql collation %s: %s", collname, err)
+					return 1
+				}
+			}
+		}
+
 		withstuff := "WITH LOGIN SUPERUSER ENCRYPTED PASSWORD " + pq.QuoteLiteral(devtestDatabasePassword)
 		cmd := exec.Command("sudo", "-u", "postgres", "psql", "-c", "ALTER ROLE arvados "+withstuff)
 		cmd.Dir = "/"
diff --git a/services/api/config/arvados_config.rb b/services/api/config/arvados_config.rb
index 7dc648100..f63f8af03 100644
--- a/services/api/config/arvados_config.rb
+++ b/services/api/config/arvados_config.rb
@@ -190,6 +190,7 @@ dbcfg.declare_config "PostgreSQL.Connection.password", String, :password
 dbcfg.declare_config "PostgreSQL.Connection.dbname", String, :database
 dbcfg.declare_config "PostgreSQL.Connection.template", String, :template
 dbcfg.declare_config "PostgreSQL.Connection.encoding", String, :encoding
+dbcfg.declare_config "PostgreSQL.Connection.collation", String, :collation
 
 application_config = {}
 %w(application.default application).each do |cfgfile|
@@ -257,6 +258,8 @@ if ::Rails.env.to_s == "test"
   # Use template0 when creating a new database. Avoids
   # character-encoding/collation problems.
   $arvados_config["PostgreSQL"]["Connection"]["template"] = "template0"
+  # Some test cases depend on en_US.UTF-8 collation.
+  $arvados_config["PostgreSQL"]["Connection"]["collation"] = "en_US.UTF-8"
 end
 
 if $arvados_config["PostgreSQL"]["Connection"]["password"].empty?
@@ -279,6 +282,7 @@ ENV["DATABASE_URL"] = "postgresql://#{$arvados_config["PostgreSQL"]["Connection"
                       "#{dbhost}/#{$arvados_config["PostgreSQL"]["Connection"]["dbname"]}?"+
                       "template=#{$arvados_config["PostgreSQL"]["Connection"]["template"]}&"+
                       "encoding=#{$arvados_config["PostgreSQL"]["Connection"]["client_encoding"]}&"+
+                      "collation=#{$arvados_config["PostgreSQL"]["Connection"]["collation"]}&"+
                       "pool=#{$arvados_config["PostgreSQL"]["ConnectionPool"]}"
 
 Server::Application.configure do

-----------------------------------------------------------------------


hooks/post-receive
-- 




More information about the arvados-commits mailing list