我正在將構建測驗從 travis-ci 遷移到 github 操作,但是在嘗試運行“nosetests”時遇到了障礙。似乎我無法對之前創建的用戶和資料庫進行身份驗證以進行處理。
.travis.yml 檔案中的相關邏輯如下所示:
services:
- postgresql
before_script:
- psql -c 'create role awips superuser createdb createrole inherit login;' -U postgres
- psql -c 'create database metadata;' -U postgres
- psql -c 'grant all privileges on database metadata to awips;' -U postgres
# command to run tests
script:
- nosetests -a UNIT --with-coverage --cover-package=mi
我嘗試將上述內容翻譯為與 github 操作一起使用,如下所示:
services:
postgres:
image: postgres:latest
env:
POSTGRES_DB: postgres
POSTGRES_HOST: postgres
POSTGRES_PORT: 5432
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
ports:
- 5432:5432
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
- name: Install PostgreSQL client
run: |
sudo apt-get update
sudo apt-get install --yes postgresql-client
- run: psql -c 'create role awips superuser createdb createrole inherit login;' -h localhost -U postgres postgres
env:
PGPASSWORD: postgres
- name create metadata database and awips role
run: psql -c 'create database metadata;' -h localhost -U postgres postgres
env:
PGPASSWORD: postgres
- run: psql -c 'grant all privileges on database metadata to awips;' -h localhost -U postgres postgres
env:
PGPASSWORD: postgres
- name: Run tests
run: nosetests -a UNIT --with-coverage --cover-package=mi
env:
POSTGRES_DB: metadata
POSTGRES_USER: awips
POSTGRES_PASSWORD: awips
POSTGRES_HOST: localhost
POSTGRES_PORT: 5432
運行 15 分鐘左右后,nosetests 命令失敗并出現許多錯誤,其中大部分如下所示:
======================================================================
ERROR: test_createRecords_fail_badItemType (mi.core.test.test_persistent_store.TestPersistentStoreDict)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/home/runner/work/mi-instrument/mi-instrument/mi/core/test/test_persistent_store.py", line 38, in setUp
self.persistentStoreDict = PersistentStoreDict("unit_test", "GI01SUMO-00001")
File "/home/runner/work/mi-instrument/mi-instrument/mi/core/persistent_store.py", line 68, in __init__
self.__setupDatabase()
File "/home/runner/work/mi-instrument/mi-instrument/mi/core/persistent_store.py", line 132, in __setupDatabase
with self.databaseSession as cur:
File "/home/runner/work/mi-instrument/mi-instrument/mi/core/persistent_store.py", line 31, in __enter__
self.conn = psycopg2.connect(database = self.database, user = self.user, password = self.password, host = self.host, port = self.port)
File "/usr/share/miniconda/envs/test/lib/python2.7/site-packages/psycopg2/__init__.py", line 126, in connect
conn = _connect(dsn, connection_factory=connection_factory, **kwasync)
OperationalError: FATAL: password authentication failed for user "awips"
任何有關進一步故障排除的幫助或指示將不勝感激。我應該補充一點,我是 Github Actions 的新手,到目前為止已經遷移了相對簡單的作業流程。這是迄今為止最復雜的。
uj5u.com熱心網友回復:
似乎沒有為用戶設定密碼,但您嘗試在測驗用例中使用密碼登錄。
CREATE ROLL:
[ ENCRYPTED ] PASSWORD 'password'
PASSWORD NULL
設定角色的密碼。... 如果未指定密碼,則密碼將設定為空,并且該用戶的密碼驗證將始終失敗。
我沒有看到POSTGRES_USER您的 Travis 配置中是否分配了 etc.,所以也許在 Travis 中它確實是以 rootpostgres用戶身份登錄而不是awips.
轉載請註明出處,本文鏈接:https://www.uj5u.com/ruanti/312268.html
標籤:PostgreSQL 码头工人 python-2.7 psycopg2 github-actions
上一篇:回圈給出多個布林值
