Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit0b4ac3a

Browse files
committed
Merge branch 'master' into repslot
2 parents59dbe42 +7251c95 commit0b4ac3a

18 files changed

+669
-35
lines changed

‎.dockerignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
dist
2+
env
3+
venv
4+
*.egg-info

‎.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
.eggs/
55
dist/
66
build/
7+
docs/build/
78

89
env/
910
venv/

‎Dockerfile.tmpl

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,12 @@ FROM postgres:${PG_VERSION}-alpine
22

33
ENV PYTHON=python${PYTHON_VERSION}
44
RUN if [ "${PYTHON_VERSION}" = "2" ] ; then \
5-
apk add --no-cache curl python2 py-virtualenv py-pip; \
5+
apk add --no-cache curl python2 python2-dev build-base musl-dev \
6+
linux-headers py-virtualenv py-pip; \
67
fi
78
RUN if [ "${PYTHON_VERSION}" = "3" ] ; then \
8-
apk add --no-cache curl python3 py-virtualenv; \
9+
apk add --no-cache curl python3 python3-dev build-base musl-dev \
10+
linux-headers py-virtualenv; \
911
fi
1012
ENV LANG=C.UTF-8
1113

‎docs/Makefile

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# Minimal makefile for Sphinx documentation
2+
#
3+
4+
# You can set these variables from the command line.
5+
SPHINXOPTS =
6+
SPHINXBUILD = sphinx-build
7+
SPHINXPROJ = testgres
8+
SOURCEDIR = source
9+
BUILDDIR = build
10+
11+
# Put it first so that "make" without argument is like "make help".
12+
help:
13+
@$(SPHINXBUILD) -Mhelp"$(SOURCEDIR)""$(BUILDDIR)"$(SPHINXOPTS)$(O)
14+
15+
.PHONY: help Makefile
16+
17+
# Catch-all target: route all unknown targets to Sphinx using the new
18+
# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
19+
%: Makefile
20+
@$(SPHINXBUILD) -M$@"$(SOURCEDIR)""$(BUILDDIR)"$(SPHINXOPTS)$(O)

‎docs/README.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#Building the documentation
2+
3+
Make sure you have`Sphinx` and`sphinxcontrib-napoleon` packages installed:
4+
5+
```
6+
pip install Sphinx sphinxcontrib-napoleon
7+
```
8+
9+
Then just run
10+
11+
```
12+
make html
13+
```
14+
15+
Documentation will be built in`build/html` directory. Other output formats are also available; run`make` without arguments to see the options.

‎docs/source/conf.py

Lines changed: 145 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,145 @@
1+
# -*- coding: utf-8 -*-
2+
#
3+
# Configuration file for the Sphinx documentation builder.
4+
#
5+
# This file does only contain a selection of the most common options. For a
6+
# full list see the documentation:
7+
# http://www.sphinx-doc.org/en/stable/config
8+
9+
# -- Path setup --------------------------------------------------------------
10+
11+
# If extensions (or modules to document with autodoc) are in another directory,
12+
# add these directories to sys.path here. If the directory is relative to the
13+
# documentation root, use os.path.abspath to make it absolute, like shown here.
14+
#
15+
importos
16+
importsys
17+
sys.path.insert(0,os.path.abspath('../..'))
18+
19+
# -- Project information -----------------------------------------------------
20+
21+
project=u'testgres'
22+
copyright=u'2016-2018, Postgres Professional'
23+
author=u'Postgres Professional'
24+
25+
# The short X.Y version
26+
version=u''
27+
# The full version, including alpha/beta/rc tags
28+
release=u'1.5'
29+
30+
# -- General configuration ---------------------------------------------------
31+
32+
# If your documentation needs a minimal Sphinx version, state it here.
33+
#
34+
# needs_sphinx = '1.0'
35+
36+
# Add any Sphinx extension module names here, as strings. They can be
37+
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
38+
# ones.
39+
extensions= ['sphinx.ext.autodoc','sphinxcontrib.napoleon']
40+
41+
# Add any paths that contain templates here, relative to this directory.
42+
templates_path= ['_templates']
43+
44+
# The suffix(es) of source filenames.
45+
# You can specify multiple suffix as a list of string:
46+
#
47+
# source_suffix = ['.rst', '.md']
48+
source_suffix='.rst'
49+
50+
# The master toctree document.
51+
master_doc='index'
52+
53+
# The language for content autogenerated by Sphinx. Refer to documentation
54+
# for a list of supported languages.
55+
#
56+
# This is also used if you do content translation via gettext catalogs.
57+
# Usually you set "language" from the command line for these cases.
58+
language=None
59+
60+
# List of patterns, relative to source directory, that match files and
61+
# directories to ignore when looking for source files.
62+
# This pattern also affects html_static_path and html_extra_path .
63+
exclude_patterns= []
64+
65+
# The name of the Pygments (syntax highlighting) style to use.
66+
pygments_style='sphinx'
67+
68+
# -- Options for HTML output -------------------------------------------------
69+
70+
# The theme to use for HTML and HTML Help pages. See the documentation for
71+
# a list of builtin themes.
72+
#
73+
html_theme='alabaster'
74+
75+
# Theme options are theme-specific and customize the look and feel of a theme
76+
# further. For a list of options available for each theme, see the
77+
# documentation.
78+
#
79+
# html_theme_options = {}
80+
81+
# Add any paths that contain custom static files (such as style sheets) here,
82+
# relative to this directory. They are copied after the builtin static files,
83+
# so a file named "default.css" will overwrite the builtin "default.css".
84+
html_static_path= []
85+
86+
# Custom sidebar templates, must be a dictionary that maps document names
87+
# to template names.
88+
#
89+
# The default sidebars (for documents that don't match any pattern) are
90+
# defined by theme itself. Builtin themes are using these templates by
91+
# default: ``['localtoc.html', 'relations.html', 'sourcelink.html',
92+
# 'searchbox.html']``.
93+
#
94+
# html_sidebars = {}
95+
96+
# -- Options for HTMLHelp output ---------------------------------------------
97+
98+
# Output file base name for HTML help builder.
99+
htmlhelp_basename='testgresdoc'
100+
101+
# -- Options for LaTeX output ------------------------------------------------
102+
103+
latex_elements= {
104+
# The paper size ('letterpaper' or 'a4paper').
105+
#
106+
# 'papersize': 'letterpaper',
107+
108+
# The font size ('10pt', '11pt' or '12pt').
109+
#
110+
# 'pointsize': '10pt',
111+
112+
# Additional stuff for the LaTeX preamble.
113+
#
114+
# 'preamble': '',
115+
116+
# Latex figure (float) alignment
117+
#
118+
# 'figure_align': 'htbp',
119+
}
120+
121+
# Grouping the document tree into LaTeX files. List of tuples
122+
# (source start file, target name, title,
123+
# author, documentclass [howto, manual, or own class]).
124+
latex_documents= [
125+
(master_doc,'testgres.tex',u'testgres Documentation',
126+
u'Postgres Professional','manual'),
127+
]
128+
129+
# -- Options for manual page output ------------------------------------------
130+
131+
# One entry per manual page. List of tuples
132+
# (source start file, name, description, authors, manual section).
133+
man_pages= [(master_doc,'testgres',u'testgres Documentation', [author],1)]
134+
135+
# -- Options for Texinfo output ----------------------------------------------
136+
137+
# Grouping the document tree into Texinfo files. List of tuples
138+
# (source start file, target name, title, author,
139+
# dir menu entry, description, category)
140+
texinfo_documents= [
141+
(master_doc,'testgres',u'testgres Documentation',author,'testgres',
142+
'One line description of project.','Miscellaneous'),
143+
]
144+
145+
# -- Extension configuration -------------------------------------------------

‎docs/source/index.rst

Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
2+
Testgres documentation
3+
======================
4+
5+
Testgres is a PostgreSQL testing framework.
6+
7+
Installation
8+
============
9+
10+
To install testgres, run:
11+
12+
..code-block::bash
13+
14+
pip install testgres
15+
16+
We encourage you to use ``virtualenv`` for your testing environment.
17+
18+
Usage
19+
=====
20+
21+
Environment
22+
-----------
23+
24+
Note: by default testgres runs ``initdb``, ``pg_ctl``, ``psql`` provided by ``PATH``.
25+
26+
There are several ways to specify a custom postgres installation:
27+
28+
- export ``PG_CONFIG`` environment variable pointing to the ``pg_config`` executable;
29+
- export ``PG_BIN`` environment variable pointing to the directory with executable files.
30+
31+
Example:
32+
33+
..code-block::bash
34+
35+
export PG_BIN=$HOME/pg_10/bin
36+
python my_tests.py
37+
38+
Examples
39+
--------
40+
41+
Here is an example of what you can do with ``testgres``:
42+
43+
..code-block::python
44+
45+
# create a node with random name, port, etc
46+
with testgres.get_new_node()as node:
47+
48+
# run inidb
49+
node.init()
50+
51+
# start PostgreSQL
52+
node.start()
53+
54+
# execute a query in a default DB
55+
print(node.execute('select 1'))
56+
57+
# ... node stops and its files are about to be removed
58+
59+
Backup & replication
60+
--------------------
61+
62+
It's quite easy to create a backup and start a new replica:
63+
64+
..code-block::python
65+
66+
with testgres.get_new_node('master')as master:
67+
master.init().start()
68+
69+
# create a backup
70+
with master.backup()as backup:
71+
72+
# create and start a new replica
73+
replica= backup.spawn_replica('replica').start()
74+
75+
# catch up with master node
76+
replica.catchup()
77+
78+
# execute a dummy query
79+
print(replica.execute('postgres','select 1'))
80+
81+
Modules
82+
=======
83+
84+
..toctree::
85+
:maxdepth:2
86+
87+
testgres
88+
89+
90+
.. Indices and tables
91+
.. ==================
92+
93+
.. * :ref:`genindex`
94+
.. * :ref:`modindex`
95+
.. * :ref:`search`

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp