ntt

module
v0.6.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 19, 2021 License: BSD-3-Clause

README

Go Report Card Build Status

About

This project provides open tools and libraries for testing with TTCN-3. It builds upon 15 years of experience of running production workloads at Nokia. This repository contains:

Note, the libraries are still internal, to give us some more time for stabilizing the API. The first releases will be for Go. C and Python will follow later.

What's TTCN-3?

TTCN-3 is a standardized language for scripting tests. It supports various types of testing and is a good addition to unit tests. Despite being clearly from the last millennium, TTCN-3 offers some excellent features for testing protocols and services:

  • Native support for concurrency and alternate code flows (similar to Go).
  • A powerful matching mechanism. Think supercharged regular expressions for arbitrary data types.
  • And it's language agnostic: Adapters and codecs are implemented in any language you see fit. So you can leverage any ecosystem you need.

For a nice introduction have a look at this video: https://media.ccc.de/v/XQKBZG

Why not just use Titan?

Titan is a mature tool with an extensive set of adapters and modules. If you just need a TTCN-3 compiler or runtime, use Titan!

If you need a language server, extra tooling or if you want to develop new TTCN-3 tools you have come to the right place.

Contact us

If you have questions, you are welcome to contact us at ntt@groups.io.

You want to contribute? That's great! Kindly read our contribution guide for more details.

Install

You can choose between installing the pre-built binaries or compiling NTT from source. Using the binaries is usually easier. Compiling from source means you have more control.

Install pre-built binaries

NTT provides pre-built binaries for Linux x64 and i386. As soon as we are confident that the Linux binaries work nicely, we'll explore other deployments, like for Windows, MacOS or in containers.

If you are running ntt already in Windows or any other platform we don't support yet, it would be great if you could share your work and create a quick PR.

Debian Packages

Download the .deb package from the releases page and install with dpkg -i.

RPM Packages

Download the .rpm package from the releases page and install with package manager of your choice. You can also install directly from the internet:

sudo dnf install https://github.com/nokia/ntt/releases/download/v0.1/ntt.x86_64.rpm

Compiling from Source

NTT requires a Go compiler >= 1.10, git and make to build. To build and install simply call:

make
sudo make install

You may control installation by specifying PREFIX and DESTDIR variables. For example:

make PREFIX=/
make install DESTDIR=$HOME/.local

Getting Started

Command Line Interface

NTT tools provide a uniform user interface, where possible:

ntt <command> [<sources>...] [--] [<args>...]
  • <command>: The command you want to execute, sub-commands are possible.
  • <sources>...: The test suite sources. This might be a list of .ttcn3 files or the test suite root directory. If your test suite requires additional adapters, the test suite root directory must contain a manifest file (see below).
  • --: This marker is required to separate the sources list from the remaining arguments.
  • <args>...: Remaining arguments.

Example:

ntt show foo.ttcn3 bar.ttcn3 -- name sources

Available Commands

Command Details
ntt version Displays version, git revision and build time if available.
ntt list Lists tests, imports and modules of a test suite.
ntt show Shows manifest information and variables.
ntt tags Creates a tags file with exuberant ctags format.
ntt lint Shows warnings and errors. This is a work in progress.
ntt mcov Reads a NTT runtime log and reports message coverage.
ntt langserver Starts a language server waiting on stdin.

Custom Commands

You can extend and customize NTT through custom commands. Place any executable with a name like ntt-jaegerschnitzel in your PATH and ntt will automatically make it available as a subcommand. You can then call it just like any other ntt command:

$ ntt jaegerschnitzel +6000

Environment variables

You may define environment variable NTT_SOURCE_DIR to specify a test suite root directory:

$ ntt list                      # Lists tests in current working directory

$ export NTT_SOURCE_DIR=~/foo
$ ntt list                      # Now, ntt lists tests in ~/foo

Environment variable NTT_CACHE is a colon-separated list of directories and has similar purpose and behaviour like GNU Make's VPATH. It is use to find files like ntt.env:

$ echo "FOO=23" > ntt.env
$ mkdir -p build && cd build
$ NTT_CACHE=.. ntt show -- FOO
23

The Test Suite Manifest

To execute a test suite you usually need more than just a bunch of TTCN-3 source files: You need generators, adapters, codecs, a lot of scripting, compile time configuration, runtime configuration, post processing tools, caching of build-artifacts and more. A manifest file provides a stable frame for tools to work together nicely.

Every NTT test suite should provide a manifest file package.yml at the root of the test suite directory structure. Supported fields:

Name Type Details
name string Name of the test suite.
sources string[] TTCN-3 Source files containing tests.
imports string[] Packages the suite depends on. This could be adapters, codecs, generators, ...
timeout number Default timeout for tests in seconds.
test_hook string Path to test hook script.
parameters_file string Path to module parameters file.
variables map[string]string A key value list of custom variables.

Environment Variables

Manifest values can be overwritten by environment variables. Environment variables will always take precedence over regular variables. Regular variables have to be declared in a TOML formatted file ntt.env or in variables section in the manifest:

$ echo '{"variables": {"NTT_NAME": "OrignalName" }, "name": "$NTT_NAME" }' > package.yml

$ ntt show -- name
OriginalName

$ NTT_NAME=NewName ntt show -- name
NewName

You also can overwrite arrays like sources or imports with environment variables (NTT_SOURCES="foo.ttcn3 bar.ttcn3" ...), but note that spaces might become problematic.

TTCN-3 Language Server

We are currently implementing the Language Server Protocol:

Features

Name Method
Workspace Symbols workspace/symbol
Execute Command workspace/executeCommand
Diagnostics textDocument/publishDiagnostics
Completion textDocument/completion
Hover textDocument/hover
Signature Help textDocument/signatureHelp
Goto Definition textDocument/definition
Goto Type Definition textDocument/typeDefinition
Goto Implementation textDocument/implementation
Find References textDocument/references
Document Highlights textDocument/documentHighlight
Document Symbols textDocument/documentSymbol
Code Action textDocument/codeAction
Code Lens textDocument/codeLens
Document Formatting textDocument/formatting
Document Range Formatting textDocument/rangeFormatting
Document on Type Formatting textDocument/onTypeFormatting
Rename textDocument/rename

The set of workspace folders

This is very important. When you open multiple folders, the first one is considered root folder. If you do not open the right folders, very little will work. This is the most common issue of ntt language server that we see.

Unfortunately there isn't much you can do, yet. we are currently working on diagnostics and additional debug messages, so we can figure out what relevant use cases for editing test suites are.

Visual Studio Code

For TTCN-3 support in Visual Studio Code have a look at our co-project vscode-ttcn3

Vim

Use prabirshrestha/vim-lsp, with the following configuration:

if executable('ntt')
    au User lsp_setup call lsp#register_server({
        \ 'name': 'ntt',
        \ 'cmd': {server_info->['ntt', 'langserver']},
        \ 'whitelist': ['ttcn3'],
        \ })
endif

function! s:on_lsp_buffer_enabled() abort
    setlocal omnifunc=lsp#complete
    setlocal signcolumn=yes
    nmap <buffer> gd <plug>(lsp-definition)
    nmap <buffer> <f2> <plug>(lsp-rename)
endfunction

augroup lsp_install
    au!
    autocmd User lsp_buffer_enabled call s:on_lsp_buffer_enabled()
augroup END

Future Development

Our goal is to improve the TTCN-3 user experience by providing modern tools. We will focus on adding features to the language server.
Of course you are very welcome to contribute. Check the feature requests if something suits you or create your own feature request.

License

This project is licensed under the BSD-3-Clause license - see the LICENSE.

Directories

Path Synopsis
cmd
k3objdump command
ntt command
ntt-mcov command
ttcn3c command
ttcn3c-gen-t3xf command
internal
loc
Package loc provides space-efficient mapping of source code locations.
Package loc provides space-efficient mapping of source code locations.
log
Package log provides uniform logging and tracing interfaces for ntt.
Package log provides uniform logging and tracing interfaces for ntt.
lsp
Package lsp implements LSP for gopls.
Package lsp implements LSP for gopls.
lsp/helper command
Invoke with //go:generate helper/helper -t Server -d protocol/tsserver.go -u lsp -o server_gen.go invoke in internal/lsp
Invoke with //go:generate helper/helper -t Server -d protocol/tsserver.go -u lsp -o server_gen.go invoke in internal/lsp
lsp/jsonrpc2
Package jsonrpc2 is a minimal implementation of the JSON RPC 2 spec.
Package jsonrpc2 is a minimal implementation of the JSON RPC 2 spec.
lsp/jsonrpc2/servertest
Package servertest provides utilities for running tests against a remote LSP server.
Package servertest provides utilities for running tests against a remote LSP server.
lsp/protocol
Package protocol contains the structs that map directly to the wire format of the "Language Server Protocol".
Package protocol contains the structs that map directly to the wire format of the "Language Server Protocol".
memoize
Package memoize supports memoizing the return values of functions with idempotent results that are expensive to compute.
Package memoize supports memoizing the return values of functions with idempotent results that are expensive to compute.
ntt
Package ntt provides test suite configuration.
Package ntt provides test suite configuration.
session
Package session provides machine-wide unique sessions.
Package session provides machine-wide unique sessions.
session/flock
Package flock implements a thread-safe interface for file locking.
Package flock implements a thread-safe interface for file locking.
span
Package span contains support for representing with positions and ranges in text files.
Package span contains support for representing with positions and ranges in text files.
telemetry
Package telemetry provides an opinionated set of packages that cover the main concepts of telemetry in an implementation agnostic way.
Package telemetry provides an opinionated set of packages that cover the main concepts of telemetry in an implementation agnostic way.
telemetry/export
Package export holds the definition of the telemetry Exporter interface, along with some simple implementations.
Package export holds the definition of the telemetry Exporter interface, along with some simple implementations.
telemetry/export/ocagent
Package ocagent adds the ability to export all telemetry to an ocagent.
Package ocagent adds the ability to export all telemetry to an ocagent.
telemetry/log
Package log is a context based logging package, designed to interact well with both the lsp protocol and the other telemetry packages.
Package log is a context based logging package, designed to interact well with both the lsp protocol and the other telemetry packages.
telemetry/metric
Package metric aggregates stats into metrics that can be exported.
Package metric aggregates stats into metrics that can be exported.
telemetry/stats
Package stats provides support for recording telemetry statistics.
Package stats provides support for recording telemetry statistics.
telemetry/tag
Package tag provides support for telemetry tagging.
Package tag provides support for telemetry tagging.
telemetry/trace
Package trace adds support for telemetry tracing.
Package trace adds support for telemetry tracing.
telemetry/unit
Package unit holds the definitions for the units you can use in telemetry.
Package unit holds the definitions for the units you can use in telemetry.
ttcn3/ast
Package ast provides TTCN-3 syntax tree nodes and functions for tree traversal.
Package ast provides TTCN-3 syntax tree nodes and functions for tree traversal.
ttcn3/doc
package doc provides helper functions to extract test tags and documents from TTCN-3 comments.
package doc provides helper functions to extract test tags and documents from TTCN-3 comments.
ttcn3/parser
Package parser implements a tolerant TTCN-3 parser library.
Package parser implements a tolerant TTCN-3 parser library.
ttcn3/scanner
Package scanner provides a TTCN-3 scanner
Package scanner provides a TTCN-3 scanner
ttcn3/token
Package token defines constants representing the lexical tokens of the TTCN-3 programming language and basic operations on tokens (printing, predicates).
Package token defines constants representing the lexical tokens of the TTCN-3 programming language and basic operations on tokens (printing, predicates).
ttcn3/types
Package types provides TTCN-3 types, functions for compatibilty checks and a builder to create and resolve types from a TTCN-3 syntax tree.
Package types provides TTCN-3 types, functions for compatibilty checks and a builder to create and resolve types from a TTCN-3 syntax tree.
xcontext
Package xcontext is a package to offer the extra functionality we need from contexts that is not available from the standard context package.
Package xcontext is a package to offer the extra functionality we need from contexts that is not available from the standard context package.
Package t3xf provides routines for decoding and loading t3xf encoded files.
Package t3xf provides routines for decoding and loading t3xf encoded files.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL