Skip to content

Commit

Permalink
Add ability to set/increase timeout for openoffice conversion. (2600h…
Browse files Browse the repository at this point in the history
…z#5853)

Include the whole hon_trie_lru_pqc test in the ifdef(PROPER) block so that macros are available in the whole file

Add documentation for getting kazoo to build on Mac OS

Fix link in mac documentation

Make the dependency installation clearer in the mac documentation

Add more dependencies to the mac installation documentation

Cleanup formatting. Add details to the mac os documentation to make running `make fmt` work.

Add the installing-on-mac md file to the documentation. Add some details to the doc about running `make docs`

Fix the header level on the installing mac docs

formatting and naming updates
  • Loading branch information
kdiedrickpgi authored and jamesaimonetti committed Jun 25, 2019
1 parent 5ee729e commit 95753d0
Show file tree
Hide file tree
Showing 6 changed files with 158 additions and 93 deletions.
4 changes: 2 additions & 2 deletions applications/hotornot/test/hon_trie_lru_pqc.erl
Original file line number Diff line number Diff line change
Expand Up @@ -268,8 +268,6 @@ longest_prefix({Prefix, Rates}
Acc
end.

-endif.

-spec recreate_parallel(any()) -> any().
recreate_parallel({Seq, Parallel}) ->
hon_trie_lru:stop(?KZ_RATES_DB),
Expand All @@ -287,3 +285,5 @@ seq([{set, Var, {call, M, F, Args}} | Seq], Vars) ->

parallel(Parallel, Vars) ->
[spawn(fun() -> seq(Seq, Vars) end) || Seq <- Parallel].

-endif.
2 changes: 1 addition & 1 deletion core/kazoo_convert/src/kz_fax_converter.hrl
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

-define(TIFF_TO_PDF_CMD, <<"tiff2pdf -o $TO $FROM">>).
-define(CONVERT_PDF_CMD
,<<"/usr/bin/gs -q "
,<<"gs -q "
"-r200x200 "
"-g1728x2200 "
"-dPDFFitPage "
Expand Down
3 changes: 2 additions & 1 deletion core/kazoo_convert/src/kz_openoffice_server.erl
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
-define(TIMEOUT_CANCEL_JOB, 120 * ?MILLISECONDS_IN_SECOND).
-define(TIMEOUT_DEQUEUE, 'dequeue').
-define(TIMEOUT_CANCEL, 'cancel_job').
-define(SERVER_TIMEOUT, 10 * ?MILLISECONDS_IN_SECOND).

-record(state, {queue = queue:new() :: queue:queue()
,timer_ref :: reference()
Expand Down Expand Up @@ -60,7 +61,7 @@ start_link() ->
%%------------------------------------------------------------------------------
-spec add(kz_term:ne_binary(), map()) -> {'ok', kz_term:ne_binary()}|{'error', kz_term:ne_binary()}.
add(Source, Options) ->
gen_server:call(?MODULE, {'add', Source, Options}).
gen_server:call(?MODULE, {'add', Source, Options}, ?SERVER_TIMEOUT).

%%%=============================================================================
%%% gen_server callbacks
Expand Down
181 changes: 92 additions & 89 deletions core/kazoo_convert/test/kz_convert_tests.erl
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,10 @@
-include_lib("eunit/include/eunit.hrl").
-include_lib("kazoo_convert/include/kz_convert.hrl").

-define(OPENOFFICE_TIMEOUT_S, 15).

fax_test_() ->
{setup
{'setup'
,fun setup/0
,fun cleanup/1
,fun(_) ->
Expand Down Expand Up @@ -164,49 +166,49 @@ test_openoffice_to_pdf_binary() ->
JobId = kz_binary:rand_hex(16),
From = read_test_file("valid.docx"),
Expected = <<"/tmp/", JobId/binary, ".pdf" >>,
[?_assertMatch({'ok', Expected}, kz_convert:fax(<<"application/vnd.openxmlformats-officedocument.wordprocessingml.document">>
,<<"application/pdf">>
,From
,[{<<"job_id">>, JobId}]
)
)
].
{'timeout', ?OPENOFFICE_TIMEOUT_S, ?_assertMatch({'ok', Expected}, kz_convert:fax(<<"application/vnd.openxmlformats-officedocument.wordprocessingml.document">>
,<<"application/pdf">>
,From
,[{<<"job_id">>, JobId}]
)
)
}.

test_openoffice_to_pdf_tuple() ->
JobId = kz_binary:rand_hex(16),
Src = copy_fixture_to_tmp("valid.docx"),
Expected = <<"/tmp/", JobId/binary, ".pdf" >>,
[?_assertMatch({'ok', Expected}, kz_convert:fax(<<"application/vnd.openxmlformats-officedocument.wordprocessingml.document">>
,<<"application/pdf">>
,{'file', Src}
,[{<<"job_id">>, JobId}]
)
)
].
{'timeout', ?OPENOFFICE_TIMEOUT_S, ?_assertMatch({'ok', Expected}, kz_convert:fax(<<"application/vnd.openxmlformats-officedocument.wordprocessingml.document">>
,<<"application/pdf">>
,{'file', Src}
,[{<<"job_id">>, JobId}]
)
)
}.

test_openoffice_to_tiff_binary() ->
JobId = kz_binary:rand_hex(16),
From = read_test_file("valid.docx"),
Expected = <<"/tmp/", JobId/binary, ".tiff" >>,
[?_assertMatch({'ok', Expected}, kz_convert:fax(<<"application/vnd.openxmlformats-officedocument.wordprocessingml.document">>
,<<"image/tiff">>
,From
,[{<<"job_id">>, JobId}]
)
)
].
{'timeout', ?OPENOFFICE_TIMEOUT_S, ?_assertMatch({'ok', Expected}, kz_convert:fax(<<"application/vnd.openxmlformats-officedocument.wordprocessingml.document">>
,<<"image/tiff">>
,From
,[{<<"job_id">>, JobId}]
)
)
}.

test_openoffice_to_tiff_tuple() ->
JobId = kz_binary:rand_hex(16),
Src = copy_fixture_to_tmp("valid.docx"),
Expected = <<"/tmp/", JobId/binary, ".tiff" >>,
[?_assertMatch({'ok', Expected}, kz_convert:fax(<<"application/vnd.openxmlformats-officedocument.wordprocessingml.document">>
,<<"image/tiff">>
,{'file', Src}
,[{<<"job_id">>, JobId}]
)
)
].
{'timeout', ?OPENOFFICE_TIMEOUT_S, ?_assertMatch({'ok', Expected}, kz_convert:fax(<<"application/vnd.openxmlformats-officedocument.wordprocessingml.document">>
,<<"image/tiff">>
,{'file', Src}
,[{<<"job_id">>, JobId}]
)
)
}.

test_tiff_to_pdf_binary_output_binary() ->
JobId = kz_binary:rand_hex(16),
Expand Down Expand Up @@ -278,49 +280,49 @@ test_pdf_to_tiff_tuple_output_binary() ->
test_openoffice_to_pdf_binary_output_binary() ->
JobId = kz_binary:rand_hex(16),
From = read_test_file("valid.docx"),
[?_assertMatch({'ok', _}, kz_convert:fax(<<"application/vnd.openxmlformats-officedocument.wordprocessingml.document">>
,<<"application/pdf">>
,From
,[{<<"job_id">>, JobId},{<<"output_type">>, 'binary'}]
)
)
].
{'timeout', ?OPENOFFICE_TIMEOUT_S, ?_assertMatch({'ok', _}, kz_convert:fax(<<"application/vnd.openxmlformats-officedocument.wordprocessingml.document">>
,<<"application/pdf">>
,From
,[{<<"job_id">>, JobId},{<<"output_type">>, 'binary'}]
)
)
}.

test_openoffice_to_pdf_tuple_output_binary() ->
JobId = kz_binary:rand_hex(16),
Src = copy_fixture_to_tmp("valid.docx"),
[?_assertMatch({'ok', _}, kz_convert:fax(<<"application/vnd.openxmlformats-officedocument.wordprocessingml.document">>
,<<"application/pdf">>
,{'file', Src}
,[{<<"job_id">>, JobId}
,{<<"output_type">>, 'binary'}]
)
)
].
{'timeout', ?OPENOFFICE_TIMEOUT_S, ?_assertMatch({'ok', _}, kz_convert:fax(<<"application/vnd.openxmlformats-officedocument.wordprocessingml.document">>
,<<"application/pdf">>
,{'file', Src}
,[{<<"job_id">>, JobId}
,{<<"output_type">>, 'binary'}]
)
)
}.

test_openoffice_to_tiff_binary_output_binary() ->
JobId = kz_binary:rand_hex(16),
From = read_test_file("valid.docx"),
[?_assertMatch({'ok', _}, kz_convert:fax(<<"application/vnd.openxmlformats-officedocument.wordprocessingml.document">>
,<<"image/tiff">>
,From
,[{<<"job_id">>, JobId}
,{<<"output_type">>, 'binary'}]
)
)
].
{'timeout', ?OPENOFFICE_TIMEOUT_S, ?_assertMatch({'ok', _}, kz_convert:fax(<<"application/vnd.openxmlformats-officedocument.wordprocessingml.document">>
,<<"image/tiff">>
,From
,[{<<"job_id">>, JobId}
,{<<"output_type">>, 'binary'}]
)
)
}.

test_openoffice_to_tiff_tuple_output_binary() ->
JobId = kz_binary:rand_hex(16),
Src = copy_fixture_to_tmp("valid.docx"),
[?_assertMatch({'ok', _}
,kz_convert:fax(<<"application/vnd.openxmlformats-officedocument.wordprocessingml.document">>
,<<"image/tiff">>
,{'file', Src}
,[{<<"job_id">>, JobId}]
)
)
].
{'timeout', ?OPENOFFICE_TIMEOUT_S, ?_assertMatch({'ok', _}
,kz_convert:fax(<<"application/vnd.openxmlformats-officedocument.wordprocessingml.document">>
,<<"image/tiff">>
,{'file', Src}
,[{<<"job_id">>, JobId}]
)
)
}.

test_tiff_to_pdf_binary_invalid() ->
JobId = kz_binary:rand_hex(16),
Expand Down Expand Up @@ -496,16 +498,16 @@ test_openoffice_to_tiff_to_filename() ->
JobId = kz_binary:rand_hex(16),
From = read_test_file("valid.docx"),
Expected = <<"/tmp/", (kz_binary:rand_hex(16))/binary, ".tiff" >>,
[?_assertMatch({'ok', Expected}
,kz_convert:fax(<<"application/vnd.openxmlformats-officedocument.wordprocessingml.document">>
,<<"image/tiff">>
,From
,[{<<"job_id">>, JobId}
,{<<"to_filename">>, Expected}
]
)
)
].
{'timeout', ?OPENOFFICE_TIMEOUT_S, ?_assertMatch({'ok', Expected}
,kz_convert:fax(<<"application/vnd.openxmlformats-officedocument.wordprocessingml.document">>
,<<"image/tiff">>
,From
,[{<<"job_id">>, JobId}
,{<<"to_filename">>, Expected}
]
)
)
}.

test_tiff_to_tiff_read_metadata() ->
JobId = kz_binary:rand_hex(16),
Expand All @@ -522,7 +524,7 @@ test_tiff_to_tiff_read_metadata() ->
,<<"image/tiff">>
,From
,[{<<"job_id">>, JobId}
,{<<"read_metadata">>, true}
,{<<"read_metadata">>, 'true'}
]
)
)
Expand All @@ -543,7 +545,7 @@ test_tiff_to_tiff_small_file_read_metadata() ->
,<<"image/tiff">>
,From
,[{<<"job_id">>, JobId}
,{<<"read_metadata">>, true}
,{<<"read_metadata">>, 'true'}
]
)
)
Expand All @@ -564,7 +566,7 @@ test_pdf_to_tiff_read_metadata() ->
,<<"image/tiff">>
,From
,[{<<"job_id">>, JobId}
,{<<"read_metadata">>, true}
,{<<"read_metadata">>, 'true'}
]
)
)
Expand All @@ -574,22 +576,23 @@ test_openoffice_to_tiff_read_metadata() ->
JobId = kz_binary:rand_hex(16),
From = read_test_file("valid.docx"),
Expected = <<"/tmp/", JobId/binary, ".tiff">>,
[?_assertMatch({'ok', Expected
,[{<<"page_count">>, 1}
,{<<"size">>, _}
,{<<"mimetype">>, <<"image/tiff">>}
,{<<"filetype">>, <<"tiff">>}
]
}
,kz_convert:fax(<<"application/vnd.openxmlformats-officedocument.wordprocessingml.document">>
,<<"image/tiff">>
,From
,[{<<"job_id">>, JobId}
,{<<"read_metadata">>, true}
]
)
)
].

{'timeout', ?OPENOFFICE_TIMEOUT_S, ?_assertMatch({'ok', Expected
,[{<<"page_count">>, 1}
,{<<"size">>, _}
,{<<"mimetype">>, <<"image/tiff">>}
,{<<"filetype">>, <<"tiff">>}
]
}
,kz_convert:fax(<<"application/vnd.openxmlformats-officedocument.wordprocessingml.document">>
,<<"image/tiff">>
,From
,[{<<"job_id">>, JobId}
,{<<"read_metadata">>, 'true'}
]
)
)
}.

test_read_metadata() ->
Src = copy_fixture_to_tmp("valid.tiff"),
Expand Down
60 changes: 60 additions & 0 deletions doc/engineering/installing-on-mac.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
# Installing on Mac (for development)

Make sure you have run `xcode-select --install` to install various build tools that are available(such as zlib.

Some additional dependencies are required to get things up and running on Mac. The easiest way to
install these dependencies is via `brew` so [install brew](https://brew.sh/) if you have not already.

Run the brew install command below to install dependencies:

```brew install python@2 libxslt openssl ncurses expat imagemagick ghostscript htmldoc```

And you can skip installing these (they are included via the Apple command line tools or the brew packages):

* build-essential
* zlib1g-dev
* git-core
* libexpat1-dev

## Additional Dependencies

Some applications are very old or configured differently in Mac OS, so use brew
to install these to bring them up to date:
Note: Make sure to follow the directions on symlinking executables or adding executables
to your path(brew will tell you about it after install completes)

* gnu-sed
* md5sha1sum
* make

You can install all of the above with:
```brew install gnu-sed md5sha1sum make```

Next install libreoffice, which can be done via `brew cask install libreoffice`.

## Tooling Dependencies

Several build commands require the gnu version of utilities. For simplicity you can install
the `coreutils` bundle from brew to get the gnu version of utility applications:
```brew install coreutils```
Again, make sure to follow the instructions to add them to your path with their default names.

The version of Emacs that comes with MacOS is very out of date, and you will need it for running
the auto formatting command. Install a newer version via brew:
```brew cask install emacs```

To build the docs you will need to upgrade bash to version 5. You can do this through:
```brew install bash``` and then removing (Perhaps just rename it) your existing bash
from `/usr/local/bin/bash` and symlinking the brew bash into its place:
```ln -s /usr/local/Cellar/bash/5.0.7/bin/bash /usr/local/bin/bash```
You may also want to do this for `/bin/bash` for consistency but it is not required.

## Fix executable paths

gnu-sed, md5 etc need their executables added to your path. When you install
them via brew they give you the instructions on what to add.

You will also want to add a symlink for libreoffice somewhere in your path because the default
executable name is `soffice` but kazoo expects it to be `libreoffice`. Something like:

```ln -s /usr/local/bin/soffice /usr/local/bin/libreoffice```
1 change: 1 addition & 0 deletions doc/mkdocs/mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -483,6 +483,7 @@ pages:
- 'Erlang VM Tracing': 'doc/engineering/tracing.md'
- 'Flame Graphs': 'doc/engineering/flame_graphs.md'
- 'Install/Build Kazoo': 'doc/installation.md'
- 'Install/Build Kazoo on MacOS': 'doc/engineering/installing-on-mac.md'
- 'Kazoo Globals Registry': 'doc/engineering/kz_globals.md'
- 'Kazoo Scripts': 'scripts/README.md'
- 'Loopback Channels': 'doc/engineering/loopback.md'
Expand Down

0 comments on commit 95753d0

Please sign in to comment.