tools/boruta.git
6 years agoWorkers: remove unused mapWorker member 86/190486/3 master
Maciej Wereski [Tue, 2 Oct 2018 11:15:56 +0000 (13:15 +0200)]
Workers: remove unused mapWorker member

Change-Id: I7a55b9c19019dec363bf808debd4aa67e76314c2
Signed-off-by: Maciej Wereski <m.wereski@partner.samsung.com>
6 years agoWorkers: Deregister when worker is in FAIL state 68/189968/5
Maciej Wereski [Tue, 25 Sep 2018 07:57:04 +0000 (09:57 +0200)]
Workers: Deregister when worker is in FAIL state

Currently worker may be deregistered only when in MAINTENANCE state.
This isn't convenient to change state of FAILED worker only to
deregister it. Also setting MAINTENANCE state may fail, which makes
deregistering worker impossible.

Change-Id: Id7e378b65b2ea7da678a0f71ec70bcfdeae9295d
Signed-off-by: Maciej Wereski <m.wereski@partner.samsung.com>
6 years agoFix generating HTTP API v1 test fixtures 85/190485/3
Maciej Wereski [Tue, 2 Oct 2018 11:06:30 +0000 (13:06 +0200)]
Fix generating HTTP API v1 test fixtures

Empty files shouldn't be generated when server responds with '204 No
Content'. All such files were removed.

Change-Id: I97823f9a476d7699bc5cf88b7da9f342c4b1ac71
Signed-off-by: Maciej Wereski <m.wereski@partner.samsung.com>
6 years agoHTTP API: Change error JSON format 53/189953/6
Maciej Wereski [Tue, 2 Oct 2018 11:03:21 +0000 (13:03 +0200)]
HTTP API: Change error JSON format

Swagger in case of error passes its details in "message" field in JSON.
Change "error" to "message" in Boruta error JSONs to comply with Swagger
(which is used in Weles).

Change-Id: I6bcbd3355392467696044f304d5b83ccc410c354
Signed-off-by: Maciej Wereski <m.wereski@partner.samsung.com>
6 years agoHTTP API: Change default status code of setWorkerStateHandler 58/189558/8
Maciej Wereski [Tue, 18 Sep 2018 12:59:25 +0000 (14:59 +0200)]
HTTP API: Change default status code of setWorkerStateHandler

Changing state of worker is long operation which require RPC call to the
dryad. workers.SetState() returns nil before such action are finished.
Moreover there may occur error after nil was returned. Because of this
user should explicitly check if the state of the dryad was changed.

Change-Id: I5e15d53598a73e8a5d7dd4014fa97aaa0f8b9e74
Signed-off-by: Maciej Wereski <m.wereski@partner.samsung.com>
6 years agoFix go vet warnings about usage of unkeyed fields 30/190530/4
Lukasz Wojciechowski [Wed, 3 Oct 2018 10:12:31 +0000 (12:12 +0200)]
Fix go vet warnings about usage of unkeyed fields

Change-Id: Ie30636704b6311c6223d346aeb89da85f20e2028
Signed-off-by: Lukasz Wojciechowski <l.wojciechow@partner.samsung.com>
6 years agoFix finishing a Job 36/189136/10
Lukasz Wojciechowski [Thu, 13 Sep 2018 16:39:05 +0000 (18:39 +0200)]
Fix finishing a Job

There are some situations, when Job is finished:
* when the request was completed either by CloseRequest
    or Job timeout;
* when Job was interrupted by Dryad failure or by putting
    Dryad into MAINTENANCE state.

The Worker must be prepared only in the first situation.

In the second situation Worker should remain in FAIL or MAINTENANCE
state.

This patch enhances JobsManager interface's Finish method
with additional boolean parameter informing if worker should
be prepared.

Change-Id: I5e527da610b3e34d034b3aaf5fbea7719bbe5e56
Signed-off-by: Lukasz Wojciechowski <l.wojciechow@partner.samsung.com>
6 years agoFix situations when request's job is not set 34/189134/11
Lukasz Wojciechowski [Thu, 13 Sep 2018 15:20:48 +0000 (17:20 +0200)]
Fix situations when request's job is not set

It is a good practice to check if pointer is not nil, before
dereferencing it. Verification if Job field of request is set
in closeRequest is such situation.

It is not an error situation if Worker state transition:
RUN->MAINTENANCE or RUN->FAIL happen and a request's is not run
by any Job. It can occur e.g. when worker is already booked for
a Job (in RUN state) and creation of Job is not yet completed
or failed.

Change-Id: Ib1790fdaab293b9478dc67f86b69f04a6808c50b
Signed-off-by: Lukasz Wojciechowski <l.wojciechow@partner.samsung.com>
6 years agoFix workers state changing behaviour 02/188902/13
Lukasz Wojciechowski [Tue, 11 Sep 2018 12:53:05 +0000 (14:53 +0200)]
Fix workers state changing behaviour

Changing state to IDLE (with key generation) or to MAINTENANCE is
a time consuming operation. That's why new workers' states are
introduced:
* PREPARE - when entering IDLE;
* BUSY - when entering MAINTENANCE.

Without them, state of workers can be changed during these long
operations as another method call can change the worker state
or initiate another long operations breaking actual state of workers.

To fix this issue not only new states are introduced, but also
an additional goroutine for every registered worker is started.
The goroutine is responsible for running long operations
in background. It is controlled with a channel through which
new worker state is sent every time setState is called.
The goroutine breaks execution of current long operation if new
state is set for worker.

As new states appear some changes in workers' methods behaviour
needs to be changed:
* SetFail returns ErrInMaintenance also for BUSY state
    (formerly for MAINTENANCE only).
* SetState ignores attempts to set MAINTENANCE when worker is BUSY
    and to set IDLE when worker is in PREPARE because requested
    state changes are already in progress.
* PrepareWorker is allowed to be run only for workers in RUN state.
    This method is used in two cases: when Job is finished
    or when matching of reserved worker and request fails to create
    the Job. In both cases worker should be bring to IDLE state
    only if if it was in RUN state. If it was in MAINTENANCE
    or FAILED it should be kept that way.
* OnWorkerFail is sent when worker's Job was interrupted (if it was
    in RUN state, and enters any other than IDLE or PREPARE states).

Naming of methods parameters has been unified. All methods running
for a boruta.WorkerUUID use uuid variable and a worker variable
is used for mapWorker structure.

Change-Id: I8d1d8b55e48e432746ebf819650a77698b8c27ab
Signed-off-by: Lukasz Wojciechowski <l.wojciechow@partner.samsung.com>
6 years agoAdd tests for rpc/dryad package 69/189269/7
Lukasz Wojciechowski [Fri, 14 Sep 2018 16:28:56 +0000 (18:28 +0200)]
Add tests for rpc/dryad package

Tests of rpc/dryad package verify both service and client sides
of RPC communication connected together.

On service side instead of true operations on Dryad mockup is used.
The mockup of Dryad interface is generated by go:generate mechanism
embedded in boruta.go file and is stored in mocks/mock_dryad.go file.

Change-Id: Id7ceaab9a70cc1404b1df9a66978ba0eb551f8bb
Signed-off-by: Lukasz Wojciechowski <l.wojciechow@partner.samsung.com>
6 years agoFix inability to send SSH keys over RPC 18/189418/6
Michal Sidor [Mon, 17 Sep 2018 10:05:35 +0000 (12:05 +0200)]
Fix inability to send SSH keys over RPC

Gob is used by auto-generated RPC services to (de)serialize structures
used in method calls. Because ssh.PublicKey is an interface, gob is
unable to serialize it, unless its underlying concrete types are
registered using `gob.Register(anythingOfAforementionedType)`.

Change-Id: I0e28e5d58a2b69a6d726bb1ddb73e2f6d8e3f99e
Signed-off-by: Michal Sidor <m.sidor@samsung.com>
6 years agoNotify ChangeListener if worker's groups change 16/188716/6 logger
Lukasz Wojciechowski [Fri, 7 Sep 2018 22:35:35 +0000 (00:35 +0200)]
Notify ChangeListener if worker's groups change

After changing groups of IDLE worker, matcher should be notified
(via ChangeListener interface) to be able to check for match
of pending requests with updated worker.

Change-Id: I94337ac49d07bd9c4d767f517244284ddd75e4f2
Signed-off-by: Lukasz Wojciechowski <l.wojciechow@partner.samsung.com>
6 years agoFix rpc and workers separation 15/188715/6
Lukasz Wojciechowski [Fri, 7 Sep 2018 18:08:33 +0000 (20:08 +0200)]
Fix rpc and workers separation

rpc package:

The rpc package should use Superviser interface for accessing workers,
but the implementation was based on direct access to WorkerList.
Tests also used methods not included in Superviser interface.

This patch fixes that, making rpc package independent of workers package.
It uses Superviser interface and MockSuperviser type for tests.

The test coverage of the rpc package has been increased
from 75.9% to 96.3% leaving only errors from net package's functions
not covered.

workers package:

All internal functions from workers package have been changed
to lowercase, unexported methods.

All exported methods are part of interfaces now:
* Superviser (used by Dryad through RPC calls):
 > Register
 > SetFail
* Workers (used by external HTTP clients):
 > SetState
 > SetGroups
 > Deregister
 > ListWorkers
 > GetWorkerInfo
* WorkersManager (used by higher internal layers (matcher, requests)):
 > GetWorkerSSHAddr
 > GetWorkerKey
 > TakeBestMatchingWorker
 > PrepareWorker
 > SetChangeListener

Change-Id: Ied9763b276ca02d05a904f4df2a7757a1892a772
Signed-off-by: Lukasz Wojciechowski <l.wojciechow@partner.samsung.com>
6 years agoReplace DialTCP with Dial in reception test 20/188620/4
Lukasz Wojciechowski [Tue, 4 Sep 2018 10:45:54 +0000 (12:45 +0200)]
Replace DialTCP with Dial in reception test

The DialTCP command called with a pair of addresses can be used only
for setting a 'simultaneous connection', when two TCP clients dial
each other, without calling listen on any side.

On some of the machines this behaviour can be buggy as described below.

In boruta no such functionality as simultaneous connection is used.
There is a server client architecture with Listen and Dial.
The DialTCP can be also used by such approach,
when only a single address is passed to the call.

The client code in boruta uses Dial function, not a DialTCP.

So it is better to replace the DialTCP function used in test
with Dial making tests code more similar to the boruta's source code
and eliminating possibility of the bug.

Details copied from go/src/net/tcpsock_posix.go:64:

TCP has a rarely used mechanism called a 'simultaneous connection' in
which Dial("tcp", addr1, addr2) run on the machine at addr1 can
connect to a simultaneous Dial("tcp", addr2, addr1) run on the machine
at addr2, without either machine executing Listen. If laddr == nil,
it means we want the kernel to pick an appropriate originating local
address. Some Linux kernels cycle blindly through a fixed range of
local ports, regardless of destination port. If a kernel happens to
pick local port 50001 as the source for a Dial("tcp", "", "localhost:50001"),
then the Dial will succeed, having simultaneously connected to itself.
This can only happen when we are letting the kernel pick a port (laddr == nil)
and when there is no listener for the destination address.
It's hard to argue this is anything other than a kernel bug. If we
see this happen, rather than expose the buggy effect to users, we
close the fd and try again. If it happens twice more, we relent and
use the result. See also:
     https://golang.org/issue/2690
     http://stackoverflow.com/questions/4949858/

Change-Id: I9a9825c85c8903c0842347b8e9c9644a26e631e1
Signed-off-by: Lukasz Wojciechowski <l.wojciechow@partner.samsung.com>
6 years agoAdd Boruta server executable 04/184104/4
Maciej Wereski [Thu, 19 Oct 2017 13:34:02 +0000 (15:34 +0200)]
Add Boruta server executable

Change-Id: I05f9509a372efc8326af9f35c122f674f60e7e70
Signed-off-by: Maciej Wereski <m.wereski@partner.samsung.com>
Signed-off-by: Aleksander Mistewicz <a.mistewicz@samsung.com>
6 years agoGet rid of dot imports of boruta package 32/186932/4
Maciej Wereski [Fri, 13 Jul 2018 14:46:15 +0000 (16:46 +0200)]
Get rid of dot imports of boruta package

Using dot imports should be avoided. Such imports were left only in some
tests.

Change-Id: I1d4db1e2b89e2fd8475c8c657ea72b70bba32c5b
Signed-off-by: Maciej Wereski <m.wereski@partner.samsung.com>
6 years agoChange rsa.PublicKey to ssh.PublicKey in Dryad Prepare 59/186159/3
Maciej Wereski [Tue, 7 Aug 2018 14:04:09 +0000 (16:04 +0200)]
Change rsa.PublicKey to ssh.PublicKey in Dryad Prepare

Users will use SSH keys rather than plain RSA keys, so Dryad interface
should accept SSH public key instead of generating it from RSA public
key.

Change-Id: I6e757199a7e8a0d3258c1c17ac0eee8412f2b415
Signed-off-by: Maciej Wereski <m.wereski@partner.samsung.com>
6 years agoInstall public key on dryad 42/181342/8
Aleksander Mistewicz [Tue, 12 Jun 2018 08:42:30 +0000 (10:42 +0200)]
Install public key on dryad

This patch changes interface and communication between boruta server and
dryads. Key is generated on boruta server, public part is installed on
dryad and private part is stored internally. It is a preparation for
using user's public keys provided by an external service.

Change-Id: Ic6fb087aba02553c6b2b8f7cc13cc6bd67eff36a
Signed-off-by: Aleksander Mistewicz <a.mistewicz@samsung.com>
6 years agoUse address of ssh daemon when creating a tunnel 17/180917/9
Aleksander Mistewicz [Mon, 4 Jun 2018 08:10:56 +0000 (10:10 +0200)]
Use address of ssh daemon when creating a tunnel

Change-Id: Ie66daa17104be1ea06849eccaaee78b2b4353c2e
Signed-off-by: Aleksander Mistewicz <a.mistewicz@samsung.com>
Use net.TCPAddr instead of net.IP as it contains Port field.

Some methods were renamed to reflect migration from net.IP to
net.TCPAddr. It allows multiple dryads to coexist behind NAT or on
a single host. Currently, it is possible to provide network addresses to
non-existent address or to a different dryad than expected. Addresses in
Register() call are checked only for resolvability.

Change-Id: I46cecb8ad6f06fabb88f2262d95c0678329915ab
Signed-off-by: Aleksander Mistewicz <a.mistewicz@samsung.com>
6 years agoAdd dryadAddress and sshAddress to Register 15/180915/7
Aleksander Mistewicz [Tue, 29 May 2018 09:20:44 +0000 (11:20 +0200)]
Add dryadAddress and sshAddress to Register

When running multiple dryads on a single host or behind NAT, they must
listen on different ports and inform boruta about this fact.

Change-Id: I35e084b8ee2e2177d36055f7dedacb53ac74bbf0
Signed-off-by: Aleksander Mistewicz <a.mistewicz@samsung.com>
6 years agoInform Dryad about SSH listen address 14/180914/4
Aleksander Mistewicz [Mon, 28 May 2018 14:51:57 +0000 (16:51 +0200)]
Inform Dryad about SSH listen address

When multiple Dryads run under the same IP address, SSH and Dryad listen
ports must be different.

Change-Id: Iedf8dd5aafb0c45c6d8c6c6b45bc61d47c720041
Signed-off-by: Aleksander Mistewicz <a.mistewicz@samsung.com>
6 years agoGenerate UUID with a new configuration file 29/185329/3
Aleksander Mistewicz [Fri, 27 Jul 2018 15:32:17 +0000 (17:32 +0200)]
Generate UUID with a new configuration file

It is a quality of life change. Generated config requires minimal
modifications (boruta address) to work.

Change-Id: I713886ca8595ba528247087fb49587ef0f27b72a
Signed-off-by: Aleksander Mistewicz <a.mistewicz@samsung.com>
6 years agoFix tests in CI 80/184380/6
Aleksander Mistewicz [Tue, 17 Jul 2018 13:04:34 +0000 (15:04 +0200)]
Fix tests in CI

It skips tests when information on current running user is unavailable.
Local IP address is retrieved by lookup of "localhost". IP addresses are
used instead of nil values.

Interface of uuid package has been changed so code using it has been
adapted.

Mock generated for stm.Interface has been updated.

Change-Id: Ide48575fa7a589c0cad00478898c2a651fda77d5
Signed-off-by: Aleksander Mistewicz <a.mistewicz@samsung.com>
6 years agoMake ReqID and Priority types implement Stringer 13/183813/2 docker ui
Maciej Wereski [Tue, 3 Jul 2018 10:41:27 +0000 (12:41 +0200)]
Make ReqID and Priority types implement Stringer

Change-Id: I3b8e271e38f8b13fa43ded590e1f31c09922bf5d
Signed-off-by: Maciej Wereski <m.wereski@partner.samsung.com>
6 years agoMerge branch 'httpapi-client' 12/183812/1
Maciej Wereski [Wed, 11 Jul 2018 06:57:57 +0000 (08:57 +0200)]
Merge branch 'httpapi-client'

This branch provides Boruta REST API client package. It implements
Requests and Workers interfaces, and provides additional convenient
methods to check request/worker state or request timeout. This package
is meant for services that want to use Boruta as its device farm (e.g.
Weles).

Change-Id: I2b116abdcb924f7443fad1c4c5401ba71d8d24fa

6 years agoHTTP API Client: Add example to documentation 22/182922/6 httpapi-client
Maciej Wereski [Thu, 28 Jun 2018 14:19:02 +0000 (16:19 +0200)]
HTTP API Client: Add example to documentation

Change-Id: I73d3b6e53bbae98130af1f0861752f84444e9265
Signed-off-by: Maciej Wereski <m.wereski@partner.samsung.com>
6 years agoHTTP API: Pass job timeout in HTTP headers 21/182921/6
Maciej Wereski [Fri, 1 Jun 2018 12:49:10 +0000 (14:49 +0200)]
HTTP API: Pass job timeout in HTTP headers

Users may want to check timeout value when request gets its resources
or access to worker is prolonged. Currently it can be only done with
GetRequestInfo() which returns all information about given request. To
make this action more convenient HTTP API server will set
Boruta-Job-Timeout header when request is in "IN PROGRESS" state. On the
client side GetJobTimeout is added. It should be also faster way to
obtain timeout value as HEAD method is used instead of GET and there's
no JSON parsing.

Change-Id: I9533f64be063e97b09c5e378a87968395d6b4072
Signed-off-by: Maciej Wereski <m.wereski@partner.samsung.com>
6 years agoHTTP API Client: Add method to check worker state 16/182616/7
Maciej Wereski [Tue, 26 Jun 2018 12:50:20 +0000 (14:50 +0200)]
HTTP API Client: Add method to check worker state

GetWorkerState() is convenient method for checking status of worker. It
uses HEAD HTTP method, so it's faster than calling GetWorkerInfo and
checking boruta.WorkerInfo.State. As HEAD method is used it may be
harder to debug when an issue occurs, only HTTP status code is returned.

Change-Id: Ie58934e0c520c6033f0ff28e82ea43eb675353a2
Signed-off-by: Maciej Wereski <m.wereski@partner.samsung.com>
6 years agoHTTP API Client: Add method to check request state 15/182615/7
Maciej Wereski [Tue, 26 Jun 2018 10:08:08 +0000 (12:08 +0200)]
HTTP API Client: Add method to check request state

GetRequestState() is convenient method for checking status of request.
It uses HEAD HTTP method, so it's faster than calling GetRequestInfo and
checking boruta.ReqInfo.State. As HEAD method is used it may be harder
to debug when an issue occurs, only HTTP status code is returned.

Change-Id: Ia2c33e0294e7840d7acec1896090f29c38163913
Signed-off-by: Maciej Wereski <m.wereski@partner.samsung.com>
6 years agoHTTP API Client: Deregister worker 41/182241/7
Maciej Wereski [Thu, 21 Jun 2018 13:31:50 +0000 (15:31 +0200)]
HTTP API Client: Deregister worker

Change-Id: I0a622bea2265ffbced657921d8cba03a97053cd9
Signed-off-by: Maciej Wereski <m.wereski@partner.samsung.com>
6 years agoHTTP API Client: Set worker groups 40/182240/7
Maciej Wereski [Thu, 21 Jun 2018 13:25:26 +0000 (15:25 +0200)]
HTTP API Client: Set worker groups

Change-Id: I546f528cd57e88fc9aacaabde447313748dfbdfd
Signed-off-by: Maciej Wereski <m.wereski@partner.samsung.com>
6 years agoHTTP API Client: Set worker state 39/182239/7
Maciej Wereski [Thu, 21 Jun 2018 13:13:45 +0000 (15:13 +0200)]
HTTP API Client: Set worker state

Change-Id: I96b3e4cab8827dd00fa02f5c4ced3e8b8bc58bff
Signed-off-by: Maciej Wereski <m.wereski@partner.samsung.com>
6 years agoHTTP API Client: Get worker information 38/182238/7
Maciej Wereski [Thu, 21 Jun 2018 12:40:02 +0000 (14:40 +0200)]
HTTP API Client: Get worker information

Change-Id: Ie0ef143db2e88cf96cef4267c3257223efb0df63
Signed-off-by: Maciej Wereski <m.wereski@partner.samsung.com>
6 years agoHTTP API Client: List and filter workers 37/182237/7
Maciej Wereski [Thu, 21 Jun 2018 08:26:09 +0000 (10:26 +0200)]
HTTP API Client: List and filter workers

Change-Id: I3e3c59c4c7f5a22e97de867daede6587f4673cfc
Signed-off-by: Maciej Wereski <m.wereski@partner.samsung.com>
6 years agoHTTP API Client: Prolong access to worker 75/181675/9
Maciej Wereski [Fri, 10 Nov 2017 14:16:55 +0000 (15:16 +0100)]
HTTP API Client: Prolong access to worker

Change-Id: Icd4ad6dfbdd226a3c6a11bb420488299465bd716
Signed-off-by: Maciej Wereski <m.wereski@partner.samsung.com>
6 years agoHTTP API Client: Acquire worker 74/181674/9
Maciej Wereski [Fri, 10 Nov 2017 14:12:31 +0000 (15:12 +0100)]
HTTP API Client: Acquire worker

Definition of boruta/http.AccessInfo2.Addr had to be changed to specific
type (new.TCPAddr) rather than interface, as it's not possible to marshal
interface type to JSON.

Change-Id: I37afd203db356ba4621ad7448a554b59f6553ce9
Signed-off-by: Maciej Wereski <m.wereski@partner.samsung.com>
6 years agoHTTP API Client: List and filter requests 73/181673/8
Maciej Wereski [Fri, 10 Nov 2017 14:05:57 +0000 (15:05 +0100)]
HTTP API Client: List and filter requests

Change-Id: I550ebfd6e87b916e15adf39519568b18828d6ae2
Signed-off-by: Maciej Wereski <m.wereski@partner.samsung.com>
6 years agoHTTP API Client: Get request information 72/181672/7
Maciej Wereski [Fri, 10 Nov 2017 12:57:53 +0000 (13:57 +0100)]
HTTP API Client: Get request information

Change-Id: Ic2b18ea346c78b50cf0f6754848a31feb753c253
Signed-off-by: Maciej Wereski <m.wereski@partner.samsung.com>
6 years agoHTTP API Client: Update request 71/181671/7
Maciej Wereski [Fri, 10 Nov 2017 12:46:06 +0000 (13:46 +0100)]
HTTP API Client: Update request

Change-Id: I7bac5be49bfd0f2a410720ec008c31c5d35cabd1
Signed-off-by: Maciej Wereski <m.wereski@partner.samsung.com>
6 years agoHTTP API Client: Close request 70/181670/7
Maciej Wereski [Fri, 10 Nov 2017 11:48:26 +0000 (12:48 +0100)]
HTTP API Client: Close request

Change-Id: Ief5f66a3d89bf55694506bbf9f8d8fcb24f51274
Signed-off-by: Maciej Wereski <m.wereski@partner.samsung.com>
6 years agoHTTP API Client: New request 69/181669/7
Maciej Wereski [Thu, 9 Nov 2017 11:28:40 +0000 (12:28 +0100)]
HTTP API Client: New request

Change-Id: Id974791f22f96b1408d9bcd0514291c6672cb6ed
Signed-off-by: Maciej Wereski <m.wereski@partner.samsung.com>
6 years agoAdd HTTP client package skeleton 68/181668/6
Maciej Wereski [Tue, 7 Nov 2017 13:38:38 +0000 (14:38 +0100)]
Add HTTP client package skeleton

Client package is intended to be utilized by HTTP API users. It will
be more convenient way to interact with Boruta server then directly
calling HTTP methods and parsing JSON by hand.

Change-Id: Ic27b90fc1559403f56358bd5677c36b2c2e57e71
Signed-off-by: Maciej Wereski <m.wereski@partner.samsung.com>
6 years agoMake ServerError implement error interface 67/181667/2
Maciej Wereski [Thu, 9 Nov 2017 15:09:09 +0000 (16:09 +0100)]
Make ServerError implement error interface

Change-Id: Ie804197ca5b777ad6afd2c01d55a853ae8c287ee
Signed-off-by: Maciej Wereski <m.wereski@partner.samsung.com>
6 years agoHTTP API: Don't loop redirecting when URL wasn't found 29/182229/2
Maciej Wereski [Thu, 21 Jun 2018 10:38:50 +0000 (12:38 +0200)]
HTTP API: Don't loop redirecting when URL wasn't found

Currently when api version isn't provided in URL then request is
redirected to default one. If requested resource isn't found there then
the redirected will be served by the same handler, so it will be
redirected which results in another redirection and so on. This change
introduces new handler that responds with 404 error when page wasn't
found in default version of API.

Change-Id: I1b67f7166d3b0d92500ab2f5727c2827b485d940
Signed-off-by: Maciej Wereski <m.wereski@partner.samsung.com>
6 years agoAdd STMsocket to dryad/conf 80/181880/1
Aleksander Mistewicz [Tue, 23 Jan 2018 15:05:44 +0000 (16:05 +0100)]
Add STMsocket to dryad/conf

Due to change in git.tizen.org/tools/muxpi/sw/nanopi/stm communication
medium has changed. Preferably, dryad should connect to the running
process of stm via unix socket exposing Go RPC interface.

It is possible to use it in the old way by assigning "" to stm_socket
configuration entry.

Change-Id: If6f4b41c9dbf467e3d40772eb52b55cbbc79d749
Signed-off-by: Aleksander Mistewicz <a.mistewicz@samsung.com>
6 years agoRefactor tests to use mock instead of real STM 79/181879/1
Aleksander Mistewicz [Mon, 18 Jun 2018 11:37:49 +0000 (13:37 +0200)]
Refactor tests to use mock instead of real STM

Testing this part of code was troublesome as a working MuxPi was needed.
Due to recent changes in git.tizen.org/tools/muxpi/sw/nanopi/stm,
functions of STM are exposed with Interface. It is easier to test using
a mockup.

Change-Id: I5c2be2ae717b448f3182896074faefd8f2ea1971
Signed-off-by: Aleksander Mistewicz <a.mistewicz@samsung.com>
6 years agoMerge branch 'httpapi' 03/180903/3
Maciej Wereski [Tue, 5 Jun 2018 10:58:00 +0000 (12:58 +0200)]
Merge branch 'httpapi'

This branch provides first version of Boruta REST API. It maps
functionality of Requests, Workers and Superviser interface. There is
also API aggregation package which will make it possible to run multiple
API version simultaneously. Generic Boruta HTTP types and functions are
provided in separate package and may be reused by Boruta HTTP client
package.

Change-Id: I9127f1f9f3681fd3b8037b316acc921098dcb773

6 years agoAdd custom Boruta HTTP headers httpapi
Maciej Wereski [Fri, 22 Dec 2017 09:18:29 +0000 (10:18 +0100)]
Add custom Boruta HTTP headers

This patch introduces two custom Boruta headers to replies for some REST
API functions:
* Boruta-Request-Status - contains current status of request. It is
  convenient to request HEAD on GetRequestInfo path to check only status
  of given request.
* Boruta-Request-Count - contains number of requests returned for
  Request List/Filter operation.
* Boruta-Worker-Status - contains current status of worker.
* Boruta-Worker-Count - conttains number of workers returned for Worker
  List/Filter operation.

Change-Id: I871c63058b2690bac50046f0dc500c795843b958
Signed-off-by: Maciej Wereski <m.wereski@partner.samsung.com>
6 years agoHTTP API: Add agregation package
Maciej Wereski [Thu, 23 Nov 2017 15:12:27 +0000 (16:12 +0100)]
HTTP API: Add agregation package

Its purpose is to create and aggregate all Boruta HTTP API version. It
also provides handler for panics and redirect ambiguous request to a
default API version.

Change-Id: Ida94aed412951744557db6c30dd658d36ff3e47e
Signed-off-by: Maciej Wereski <m.wereski@partner.samsung.com>
6 years agoCreate new package for http datatypes
Maciej Wereski [Thu, 9 Nov 2017 12:54:46 +0000 (13:54 +0100)]
Create new package for http datatypes

Few datatypes will be shared between server and client, such as server
errors and filters. Move these datatypes to separate package.

Change-Id: I06f025ba8449d2e2c045fbdd84fe59fd76b065ca
Signed-off-by: Maciej Wereski <m.wereski@partner.samsung.com>
6 years agoHTTP API: Implement filtering workers
Maciej Wereski [Tue, 17 Oct 2017 10:53:38 +0000 (12:53 +0200)]
HTTP API: Implement filtering workers

Change-Id: I93137f8e3c7dc66c859de671c316a443ec4aad9e
Signed-off-by: Maciej Wereski <m.wereski@partner.samsung.com>
6 years agoHTTP API: Implement worker deregistration
Maciej Wereski [Tue, 17 Oct 2017 09:49:19 +0000 (11:49 +0200)]
HTTP API: Implement worker deregistration

Change-Id: Ie0eeb5b8958111f980230eb186e44a1a14663b7a
Signed-off-by: Maciej Wereski <m.wereski@partner.samsung.com>
6 years agoHTTP API: Implement setting state of a worker
Maciej Wereski [Tue, 17 Oct 2017 09:43:13 +0000 (11:43 +0200)]
HTTP API: Implement setting state of a worker

Change-Id: Ib413efb68b1c6c63ae07d878ee6929cdb4049948
Signed-off-by: Maciej Wereski <m.wereski@partner.samsung.com>
6 years agoHTTP API: Implement setting worker groups
Maciej Wereski [Fri, 13 Oct 2017 10:57:05 +0000 (12:57 +0200)]
HTTP API: Implement setting worker groups

Change-Id: I7d0c6ad8da766c0716ab1186b3894079044e58d8
Signed-off-by: Maciej Wereski <m.wereski@partner.samsung.com>
6 years agoHTTP API: Implement getting information about worker
Maciej Wereski [Tue, 10 Oct 2017 14:57:30 +0000 (16:57 +0200)]
HTTP API: Implement getting information about worker

Change-Id: Iae6bc7a4f936defc409396f43a56bd13f37a532b
Signed-off-by: Maciej Wereski <m.wereski@partner.samsung.com>
6 years agoHTTP API: Add Superviser API skeleton
Maciej Wereski [Tue, 10 Oct 2017 10:30:54 +0000 (12:30 +0200)]
HTTP API: Add Superviser API skeleton

Currently only Requests and handlers of 2 Workers functions were
present, although HTTP API should cover full Workers API.

Tests will use mocked Workers and Superviser interfaces, so
generation line was added to boruta.go.

Change-Id: Id6d82a8c6e61121a2e75d5c90445edf35b2268a5
Signed-off-by: Maciej Wereski <m.wereski@partner.samsung.com>
6 years agoHTTP API: Implement modification of Boruta requests
Maciej Wereski [Fri, 6 Oct 2017 15:43:18 +0000 (17:43 +0200)]
HTTP API: Implement modification of Boruta requests

Change-Id: I8d91554776871dfd7be85f64d868c81911682491
Signed-off-by: Maciej Wereski <m.wereski@partner.samsung.com>
6 years agoHTTP API: Implement access to worker prolongation
Maciej Wereski [Fri, 29 Sep 2017 10:27:17 +0000 (12:27 +0200)]
HTTP API: Implement access to worker prolongation

Change-Id: Iecc19c55a9c1b4a674d742e7922776da671fc3c9
Signed-off-by: Maciej Wereski <m.wereski@partner.samsung.com>
6 years agoHTTP API: Implement acquiring worker
Maciej Wereski [Fri, 29 Sep 2017 10:22:28 +0000 (12:22 +0200)]
HTTP API: Implement acquiring worker

AccessInfo structure provides key in golang rsa.PrivateKey format, so
handler repacks it and replies with AccessInfo2 structure, which has key
in PEM format. This is temporary solution - private keys will be removed
when proper user support is added (user public key will be used).

Change-Id: Ia4b8bc4a0ed007f0a6a0c0ff8e3ef48750646e51
Signed-off-by: Maciej Wereski <m.wereski@partner.samsung.com>
6 years agoHTTP API: Implement listing and filtering requests
Maciej Wereski [Fri, 29 Sep 2017 09:14:22 +0000 (11:14 +0200)]
HTTP API: Implement listing and filtering requests

Change-Id: I27f8d037978ef0f0f60ea5c7ee406f8459a90796
Signed-off-by: Maciej Wereski <m.wereski@partner.samsung.com>
6 years agoHTTP API: Implement ListFilter interface
Maciej Wereski [Thu, 28 Sep 2017 15:18:05 +0000 (17:18 +0200)]
HTTP API: Implement ListFilter interface

To filter requests method ListRequests() from Requests interface will be
called. This method needs to be passed argument that implements
ListFilter interface. This interface provides appropriate Match()
method, which is used by ListRequests() to decide if request should be
appended to the results.

Change-Id: Ic284a5c2b173328f079184c7c4eac56e723db533
Signed-off-by: Maciej Wereski <m.wereski@partner.samsung.com>
6 years agoHTTP API: Implement getting information about requests
Maciej Wereski [Thu, 28 Sep 2017 13:42:24 +0000 (15:42 +0200)]
HTTP API: Implement getting information about requests

Change-Id: Ia0e7675dbcaad1ac90c6bc50f9d9de0c4a02b32d
Signed-off-by: Maciej Wereski <m.wereski@partner.samsung.com>
6 years agoHTTP API: Implement closing requests
Maciej Wereski [Wed, 27 Sep 2017 10:49:13 +0000 (12:49 +0200)]
HTTP API: Implement closing requests

Change-Id: Iae3aec7a4a4d3cf34e4b3b01b9121efcece94436
Signed-off-by: Maciej Wereski <m.wereski@partner.samsung.com>
6 years agoHTTP API: Creating new requests
Maciej Wereski [Wed, 6 Sep 2017 15:45:01 +0000 (17:45 +0200)]
HTTP API: Creating new requests

Change-Id: I42423080832d0bba13f9b219d05c0e9fa48c7d06
Signed-off-by: Maciej Wereski <m.wereski@partner.samsung.com>
6 years agoAdd HTTP API package
Maciej Wereski [Thu, 31 Aug 2017 14:11:31 +0000 (16:11 +0200)]
Add HTTP API package

HTTP API package will provide all HTTP API which will be exposed to the
Boruta clients. Only User API counterpart of Boruta is added for now.
Currently the package provides only one function, which takes pointer to
httprouter.Router and registers all paths and HTTP methods in it.

HTTP API module will have a lot of test cases agregated in test tables.
To improve test cases development time and readability of test files,
flag '-update' is added to test. It will run tests and for all
testcases a file with results will be generated in 'testdata'
subdirectory. During testing (running without '-update' flag) those
files are read and compared with results of tested functions.

Generating testcase files:
$ go test git.tizen.org/tools/boruta/server/api/v1 -update
Testing (as usual):
$ go test git.tizen.org/tools/boruta/server/api/v1

After updating testcase files output must be inspected by developer
before commiting to the repository (and should be also checked by
reviewers before merging).

Change-Id: I6d98f093cce116512dc305e07a8614990580faff
Signed-off-by: Maciej Wereski <m.wereski@partner.samsung.com>
6 years agoAdd LICENSE file 82/178282/4
Maciej Wereski [Wed, 9 May 2018 06:48:37 +0000 (08:48 +0200)]
Add LICENSE file

Change-Id: Ie73b74954425d30994f0e6de9c971bb970a93696
Signed-off-by: Maciej Wereski <m.wereski@partner.samsung.com>
6 years agoMerge branch 'matcher'
Maciej Wereski [Fri, 27 Apr 2018 16:52:38 +0000 (18:52 +0200)]
Merge branch 'matcher'

This branch provides logic for matching pending requests with
appropriate workers and reacting to time events (validAfters, deadlines
and timeouts). When succesfully matched, tunnel to dryad is created and
owner of request may get access info and ssh to the dryad.

6 years agoSet ReqsCollection as WorkerChange listener
Lukasz Wojciechowski [Tue, 24 Oct 2017 09:59:52 +0000 (11:59 +0200)]
Set ReqsCollection as WorkerChange listener

WorkerChange listener is notified about changes of worker state:
* when worker becomes IDLE;
* when worker's work has been broken by entering FAIL
 or MAINTENANCE state.

The ReqsCollection implementing WorkerChange interface reacts by:
* matching new pending request to IDLE worker;
* finishing request execution with FAILED state if worker's job has
 been broken.

Change-Id: Icff6a91e3173712243bf6d8ee382d1f1222b4735
Signed-off-by: Lukasz Wojciechowski <l.wojciechow@partner.samsung.com>
6 years agoUse change listener in workers
Lukasz Wojciechowski [Tue, 24 Oct 2017 09:55:06 +0000 (11:55 +0200)]
Use change listener in workers

Notify WorkerChange listener (if registered) about changes of worker state:
* when worker becomes IDLE;
* when worker's work was break by entering FAIL or MAINTENANCE state.

Change-Id: Ia5350912871d7ac6d1454dc5f0ae74155e811850
Signed-off-by: Lukasz Wojciechowski <l.wojciechow@partner.samsung.com>
6 years agoTrigger appropriate actions on Drayd in SetState
Aleksander Mistewicz [Thu, 19 Oct 2017 12:35:55 +0000 (14:35 +0200)]
Trigger appropriate actions on Drayd in SetState

Usage of mutexes is added into tests, as now more goroutines
can operate on WorkerList at the same time.
SetState changes are updated and enhanced to cover all possible
scenarios.

Change-Id: I99b00309e5ab937720d5848e3a3279e966c0cbad
Signed-off-by: Lukasz Wojciechowski <l.wojciechow@partner.samsung.com>
6 years agoImplement WorkerChange in requests
Lukasz Wojciechowski [Tue, 24 Oct 2017 09:13:48 +0000 (11:13 +0200)]
Implement WorkerChange in requests

Implementation covers OnWorkerIdle and OnWorkerFail methods.
The tests for both functions are available in requests_workerchange_test.go.

Change-Id: I0b35bf275e61448e2d9cf1ec943745592bb85394
Signed-off-by: Lukasz Wojciechowski <l.wojciechow@partner.samsung.com>
6 years agoImplement closing request
Lukasz Wojciechowski [Mon, 23 Oct 2017 08:41:54 +0000 (10:41 +0200)]
Implement closing request

Adjust test for CloseRequest.

Change-Id: I0bc0399206f3285cdd8e20eacf1a5d25815e54f7
Signed-off-by: Lukasz Wojciechowski <l.wojciechow@partner.samsung.com>
6 years agoUse Job information in Acquire and Prolong
Lukasz Wojciechowski [Wed, 18 Oct 2017 11:32:48 +0000 (13:32 +0200)]
Use Job information in Acquire and Prolong

Implement AcquireWorker and ProlongAccess in ReqsCollection.
Adjust tests to the usage of JobsManager in AcquireWorker
and cover new functionality.

Usage of mocked up JobsManager in tests is required.
The MockJobsManager has been generated using command:

mockgen -package requests \
-destination=requests/jobsmanager_mock_test.go \
-write_package_comment=false \
git.tizen.org/tools/boruta/matcher JobsManager

Change-Id: Ia925e556ddbb86a7998e982d760901e9e80666f2
Signed-off-by: Lukasz Wojciechowski <l.wojciechow@partner.samsung.com>
6 years agoSetup job when request processing starts
Lukasz Wojciechowski [Wed, 18 Oct 2017 10:14:57 +0000 (12:14 +0200)]
Setup job when request processing starts

In this patch timeout for Job is set to one hour.
It should be changed when proper timeout can be read from configuration
of boruta or user capabilities.

Change-Id: Iefe93f436a481797958d6563b2708b8f29c9652e
Signed-off-by: Lukasz Wojciechowski <l.wojciechow@partner.samsung.com>
6 years agoCreate matchers in requests
Lukasz Wojciechowski [Wed, 18 Oct 2017 09:43:25 +0000 (11:43 +0200)]
Create matchers in requests

Pass WorkersManager and JobsManager to requests. They are required
to control workers and jobs by matchers.
Create timeRequests time events monitors for ValidAfter, Deadline
and Timeout events and creates matchers for handling them.
Update timeRequests after creation and changing pending requests.

Update tests to fit changes in code.

As tests required usage of WorkersManager, a mockup type
MockWorkersManager has been generated using following command:

mockgen -package requests \
-destination=requests/workersmanager_mock_test.go \
-write_package_comment=false \
git.tizen.org/tools/boruta/matcher WorkersManager

Change-Id: Id6bbcf650859e27e137d462a11540589a3620385
Signed-off-by: Lukasz Wojciechowski <l.wojciechow@partner.samsung.com>
6 years agoImplement WorkersManager interface in WorkerList
Lukasz Wojciechowski [Fri, 27 Oct 2017 19:41:56 +0000 (21:41 +0200)]
Implement WorkersManager interface in WorkerList

Implementation of WorkersManager from matcher package makes WorkerList usable
as interface for acquiring workers by Matcher.

The implemnetation adds 2 new fields:
* changeListener which is notified after Worker's state changes;
* newDryadClient which provides dryad.ClientManager.

The implementation is covered by tests.
2 mock up types: MockDryadClientManager and MockWorkerChange for mocking up
rpc.dryad.ClientManager and WorkerChange.

Change-Id: I2177824aef7aea564cd0a9900d9970c8a8386ca7
Signed-off-by: Lukasz Wojciechowski <l.wojciechow@partner.samsung.com>
6 years agoAdd TCP Dial RPC client creation to DryadClient
Lukasz Wojciechowski [Mon, 5 Mar 2018 19:08:46 +0000 (20:08 +0100)]
Add TCP Dial RPC client creation to DryadClient

The Create function implements ClientManager interface.
It sets up a new TCP dialled RPC client in DryadClient structure.

The connection created this way will be used for managing Dryad
(key generation, putting in maintenance state, preparation).

Change-Id: I2d9c48d05f65e38b49aa6fe7ded10e324248f84e
Signed-off-by: Lukasz Wojciechowski <l.wojciechow@partner.samsung.com>
6 years agoAdd rpc.dryad.ClientManager interface
Lukasz Wojciechowski [Mon, 6 Nov 2017 15:53:36 +0000 (16:53 +0100)]
Add rpc.dryad.ClientManager interface

This interface allows adding an abstraction layer between Dryad's
client implementation and usage. It can be used also for using
mocked up implementation od Dryad's client for test purposes.

The mock implementation of interface is provided in workers package.
It is generated using mockgen command:

mockgen -package workers \
-destination=workers/dryadclientmanager_mock_test.go \
-write_package_comment=false \
-mock_names ClientManager=MockDryadClientManager \
git.tizen.org/tools/boruta/rpc/dryad ClientManager

Change-Id: I7366a0e68a355c98b898fb00ec8efb3c642a725d
Signed-off-by: Lukasz Wojciechowski <l.wojciechow@partner.samsung.com>
6 years agoAdd RW mutex based synchronization to WorkersList
Lukasz Wojciechowski [Wed, 11 Oct 2017 18:12:10 +0000 (20:12 +0200)]
Add RW mutex based synchronization to WorkersList

Change-Id: I43cea0084c1001b61cfbef6c5be7968f841b584b
Signed-off-by: Lukasz Wojciechowski <l.wojciechow@partner.samsung.com>
6 years agoImplement RequestsManager in ReqsCollection
Lukasz Wojciechowski [Tue, 10 Oct 2017 08:25:06 +0000 (10:25 +0200)]
Implement RequestsManager in ReqsCollection

Add implementation of RequestsManager interface by *ReqsCollection.
Implementation is required for internal boruta access to requests
structures to react on time passed events.

requests_requestsmanager_test.go file contains tests
of this implementation.

Change-Id: I2480138ca2625c8dca84b8191ef62d47fb9bc164
Signed-off-by: Lukasz Wojciechowski <l.wojciechow@partner.samsung.com>
6 years agoAdd TimeoutMatcher with tests
Lukasz Wojciechowski [Fri, 6 Oct 2017 20:04:50 +0000 (22:04 +0200)]
Add TimeoutMatcher with tests

TimeoutMatcher is a Matcher interface implementation for handling
running requests timeouts caused by expiration of requests' job timeout.

It tries to run Close on all reported requests. Some of the timeouts
might be invalid, because the request has changed it's state to done
or failed.

Tests base on using MockRequestsManager for mocking up RequestsManager
interface.

Change-Id: I6540ab50eb84f8ab1b9737ad71e7ae3a5ddd3170
Signed-off-by: Lukasz Wojciechowski <l.wojciechow@partner.samsung.com>
6 years agoAdd DeadlineMatcher with tests
Lukasz Wojciechowski [Fri, 6 Oct 2017 19:52:53 +0000 (21:52 +0200)]
Add DeadlineMatcher with tests

DeadlineMatcher is a Matcher interface implementation for handling
pending requests timeouts caused by expiration of Deadline times.

It tries to set Timeout on all reported requests. Some of the timeouts
might be invalid, because the request has change it's state
to canceled or running; or the Deadline time itself has been changed.

Tests base on using MockRequestsManager for mocking up RequestsManager
interface.

Change-Id: I4d790b58a26aa7389250ff57b6bfad662d4d3f7b
Signed-off-by: Lukasz Wojciechowski <l.wojciechow@partner.samsung.com>
6 years agoAdd ValidMatcher with tests
Lukasz Wojciechowski [Fri, 6 Oct 2017 19:34:06 +0000 (21:34 +0200)]
Add ValidMatcher with tests

ValidMatcher is a Matcher interface implementation for handling events
related to validation of requests after ValidAfter time is passed.
It matches pending, ready to be run requests with idle workers that are
capable to fulfill request capabilities and belong to group for which
request owner has rights.

Tests base on using MockRequestsManager, MockWorkersManager
and MockJobsManager for mocking up RequestsManager, WorkersManager
and JobsManager interfaces.

Change-Id: Ib654f1ef276eecb14dc4ad3114afcccd83a7bf5d
Signed-off-by: Lukasz Wojciechowski <l.wojciechow@partner.samsung.com>
6 years agoAdd RequestsManager interface
Lukasz Wojciechowski [Fri, 6 Oct 2017 17:49:32 +0000 (19:49 +0200)]
Add RequestsManager interface

RequestsManager interface defines API for taking actions
triggered by matcher events on requests structures.

The mock implementation of interface is provided in matcher package.
It is generated using mockgen command:

mockgen -package matcher \
-destination=matcher/requestsmanager_mock_test.go \
-write_package_comment=false \
git.tizen.org/tools/boruta/matcher RequestsManager

Change-Id: Idbf83988dba4cfa761dbfe8cae0a33d0a39245ac
Signed-off-by: Lukasz Wojciechowski <l.wojciechow@partner.samsung.com>
6 years agoAdd JobsManager implementation with tests
Lukasz Wojciechowski [Thu, 26 Apr 2018 10:16:28 +0000 (12:16 +0200)]
Add JobsManager implementation with tests

JobsManagerImpl implements JobsManager interface providing support
for jobs management. It uses provided WorkManager for managing
workers and Tunnels implementation of Tunneler for handling tunnels.

Tests base on usage of MockWorkersManager and MockTunneler
for mockuping access to workers and tunnels.

Change-Id: I4c469f32fc4f918641f69843567b39bfcce8da4c
Signed-off-by: Lukasz Wojciechowski <l.wojciechow@partner.samsung.com>
Signed-off-by: Maciej Wereski <m.wereski@partner.samsung.com>
6 years agoAdd JobsManager interface
Lukasz Wojciechowski [Fri, 27 Oct 2017 18:39:23 +0000 (20:39 +0200)]
Add JobsManager interface

JobsManager interface defines API for taking actions on jobs.

The mock implementation of interface is provided in matcher package.
It is generated using mockgen command:

mockgen -package matcher \
-destination=matcher/jobsmanager_mock_test.go \
-write_package_comment=false \
git.tizen.org/tools/boruta/matcher JobsManager

Change-Id: I950b68cbadd2a2e7be3d65406d36082d6ac29ee4
Signed-off-by: Lukasz Wojciechowski <l.wojciechow@partner.samsung.com>
6 years agoMove tunnels from workers to separate package
Lukasz Wojciechowski [Tue, 31 Oct 2017 08:59:38 +0000 (09:59 +0100)]
Move tunnels from workers to separate package

Tunnels package provides implementation of simple data forwarding
tunnels between IP addresses pairs.

The implementation has been moved from workers package and adjusted
to newly defined Tunneler interface. The interface defines basic
operations on tunnels (creation, getting address, closing).
It provides additional layer of abstraction allowing mockuping tests
of parts of the code using tunnels.

The mock implementation of interface is provided in matcher package.
It is generated using mockgen command:

mockgen -package matcher \
-destination=matcher/tunneler_mock_test.go \
-write_package_comment=false \
git.tizen.org/tools/boruta/tunnels Tunneler

Change-Id: Ida42f0134f0c365c8f1ffe772b859a0218c301ed
Signed-off-by: Lukasz Wojciechowski <l.wojciechow@partner.samsung.com>
Signed-off-by: Maciej Wereski <m.wereski@partner.samsung.com>
6 years agoAdd fields to AccessInfo struct
Lukasz Wojciechowski [Mon, 16 Oct 2017 08:23:52 +0000 (10:23 +0200)]
Add fields to AccessInfo struct

Added fields define required connection data for the request owner
who want to connect to the Dryad running job.

Change-Id: I372abac096d5b1cacc2744cbbbce2d1b0740cf81
Signed-off-by: Lukasz Wojciechowski <l.wojciechow@partner.samsung.com>
6 years agoAdd WorkersManager interface
Lukasz Wojciechowski [Fri, 6 Oct 2017 18:52:00 +0000 (20:52 +0200)]
Add WorkersManager interface

WorkersManager interface defines API for taking actions
triggered by matcher events on workers structures.

The mock implementation of interface is provided in matcher package.
It is generated using mockgen command:

mockgen -package matcher \
-destination=matcher/workersmanager_mock_test.go \
-write_package_comment=false \
git.tizen.org/tools/boruta/matcher WorkersManager

Change-Id: I026c661696b19a3443afc430e46d96abf9a272d5
Signed-off-by: Lukasz Wojciechowski <l.wojciechow@partner.samsung.com>
6 years agoAdd WorkerChange interface
Lukasz Wojciechowski [Tue, 24 Oct 2017 09:11:34 +0000 (11:11 +0200)]
Add WorkerChange interface

WorkerChange interface defines API for implementation to be informed
about changes in workers.

The mock implementation of interface is provided in workers package.
It is generated using mockgen command:

mockgen -package workers \
-destination=workers/workerchange_mock_test.go \
-write_package_comment=false \
git.tizen.org/tools/boruta/workers WorkerChange

Change-Id: Ia17aefd747057868bf2b4b57332397a591ac038a
Signed-off-by: Lukasz Wojciechowski <l.wojciechow@partner.samsung.com>
6 years agoAdd Groups to UserInfo
Lukasz Wojciechowski [Fri, 6 Oct 2017 09:33:02 +0000 (11:33 +0200)]
Add Groups to UserInfo

Change-Id: Ie8369804df2eb6fa79bffe1895b6737c14ad74d1
Signed-off-by: Lukasz Wojciechowski <l.wojciechow@partner.samsung.com>
6 years agoAdd requestTimes with tests
Lukasz Wojciechowski [Wed, 13 Sep 2017 18:02:18 +0000 (20:02 +0200)]
Add requestTimes with tests

requestTimes collects requestTime objects and notifies registered
matcher.Matcher when the time comes. Past times are removed from
collection. timesHeap is used for storing requestTime objects.
Notifications are called asynchronously from dedicated goroutine.
requestTimes will be used by requests package for monitoring ValidAfter,
Deadline and Timeout time of requests.

Change-Id: Ib27608f89057791bb1d615ec881ba2c06512f6f0
Signed-off-by: Lukasz Wojciechowski <l.wojciechow@partner.samsung.com>
6 years agoAdd matcher interface
Lukasz Wojciechowski [Wed, 13 Sep 2017 18:00:16 +0000 (20:00 +0200)]
Add matcher interface

Matcher is an interface for taking actions related to assigning requests
to workers and reacting to requests time events.
It should be implemented by objects that are notified about such events.

Change-Id: I8c7e3931e16fea8ce8be8f7dbdf28f5a3c13c11e
Signed-off-by: Lukasz Wojciechowski <l.wojciechow@partner.samsung.com>
6 years agoAdd timesHeap with tests
Lukasz Wojciechowski [Tue, 5 Sep 2017 15:38:10 +0000 (17:38 +0200)]
Add timesHeap with tests

timesHeap uses timesHeapContainer for heap implementation.
It provides API to heap of requestTime for higher layers of requests
package.
It will be used for finding minimum time among ValidAfter, Deadline
and Timeout requests' times. Every time the minimum time will come
requests-workers matcher will be notified.

Change-Id: Ifb30ff0180c39fe9d8c4748253a0391e1cf8bc75
Signed-off-by: Lukasz Wojciechowski <l.wojciechow@partner.samsung.com>
6 years agoAdd timesHeapContainer with tests
Lukasz Wojciechowski [Tue, 5 Sep 2017 15:35:50 +0000 (17:35 +0200)]
Add timesHeapContainer with tests

timesHeapContainer is a slice based implementation of heap.Interface
for requestTime structure (combines time.Time with ReqID).
Defined type is required for creating a heap of time structures with
additional data identifying request related to the time.
It will be used by requests package for getting minimal ValidAfter,
Deadline and Timeout times of requests. The special goroutine will
notify request-worker matcher, when proper time comes.

Change-Id: I2b71f84d2f3843bb47c0c9b7c7279ca224fba64b
Signed-off-by: Lukasz Wojciechowski <l.wojciechow@partner.samsung.com>
6 years agoFix Guard requests collection with mutex
Lukasz Wojciechowski [Tue, 30 Jan 2018 10:07:00 +0000 (11:07 +0100)]
Fix Guard requests collection with mutex

Change-Id: I580c7f44f6c412908b09f595f4eed768dca30b0a
Signed-off-by: Lukasz Wojciechowski <l.wojciechow@partner.samsung.com>
6 years agoMerge branch 'workers'
Maciej Wereski [Fri, 30 Mar 2018 10:08:37 +0000 (12:08 +0200)]
Merge branch 'workers'

Small improvements for listing workers and fixes for tunnel creation.

Change-Id: I6fb9e462a0039be0b1fb2808669eb9b385e74459

6 years agoImprove NewTunnel and remove global variable
Aleksander Mistewicz [Mon, 9 Oct 2017 08:19:54 +0000 (10:19 +0200)]
Improve NewTunnel and remove global variable

Only a constant for a default value of SSH port is left. Non-public
function newTunnel() takes port number as a parameter and is called by
a public function with a default value.

This patch also avoids possible allocation of not used memory by moving
error path in the NewTunnel earlier, before structure is initialized.

Change-Id: I26355af115187d9b36d7633ba47591fcb98d0ebb
Signed-off-by: Aleksander Mistewicz <a.mistewicz@samsung.com>
Reviewed-on: https://mcdsrvbld02.digital.local/review/49834
Reviewed-by: Maciej Wereski <m.wereski@partner.samsung.com>
Tested-by: Maciej Wereski <m.wereski@partner.samsung.com>
6 years agoSimplify implementation of ListWorkers
Aleksander Mistewicz [Fri, 6 Oct 2017 16:34:04 +0000 (18:34 +0200)]
Simplify implementation of ListWorkers

For unknown reason it was a little more complicated than necessary.
It also slightly improves perfomance - around 10%.

Change-Id: I6fc6555e3a92a5b79762b0d9f5a1ed570f39c45c
Signed-off-by: Aleksander Mistewicz <a.mistewicz@samsung.com>
Reviewed-on: https://mcdsrvbld02.digital.local/review/49582
Reviewed-by: Maciej Wereski <m.wereski@partner.samsung.com>
Tested-by: Maciej Wereski <m.wereski@partner.samsung.com>
6 years agoMerge branch 'dryad'
Maciej Wereski [Mon, 5 Mar 2018 17:45:57 +0000 (18:45 +0100)]
Merge branch 'dryad'

    Superviser and Dryad interfaces defined how Dryads and Boruta will
    interact. Merged changes provide RPC implementation for aforementioned
    interfaces together with a service that should run on a Dryad.

    Change-Id: I0ef4a8dbd1dab5f3db3d7bdb5b509959e3c64ef3