tools/weles.git
4 years agoMerge branch 'doc' into master 77/214177/1 master
Pawel Wieczorek [Wed, 18 Sep 2019 16:32:07 +0000 (18:32 +0200)]
Merge branch 'doc' into master

Change-Id: I7d91b0d81f8d61c151d5e8693430c5e73a995e58

5 years agoExclude all generated files in .gometalinterconfig
Alexander Mazuruk [Fri, 28 Dec 2018 12:19:29 +0000 (13:19 +0100)]
Exclude all generated files in .gometalinterconfig

Additionally deadline parameter was added as Weles verification took
more than default 60s.

Change-Id: I839d234cc9ba1918f5f091ebb1ac5a090958ce0f
Signed-off-by: Alexander Mazuruk <a.mazuruk@samsung.com>
5 years agoAdd link to documentation to README 32/195932/3 doc
Alexander Mazuruk [Wed, 19 Dec 2018 17:16:52 +0000 (18:16 +0100)]
Add link to documentation to README

Change-Id: Ifda97af1f758b6ffd5f8e94920d876982e5e1f68
Signed-off-by: Alexander Mazuruk <a.mazuruk@samsung.com>
5 years agoAdjustments after github transition 31/195931/3
Alexander Mazuruk [Wed, 19 Dec 2018 17:12:50 +0000 (18:12 +0100)]
Adjustments after github transition

Change-Id: Ic78791c89965b36111cc48ef1e94fabc37eaa3a9
Signed-off-by: Alexander Mazuruk <a.mazuruk@samsung.com>
5 years agoFix wrong artifact type (RESULTS were marked TEST)
Alexander Mazuruk [Tue, 18 Dec 2018 17:23:43 +0000 (18:23 +0100)]
Fix wrong artifact type (RESULTS were marked TEST)

Change-Id: Ieba45f569c2f2a8daa2c7fa7a0eb2dd56514764a
Signed-off-by: Alexander Mazuruk <a.mazuruk@samsung.com>
5 years agoFix linter errors
Alexander Mazuruk [Fri, 23 Nov 2018 15:32:43 +0000 (16:32 +0100)]
Fix linter errors

Few errors introduced while CI was off, few due to updated checkers.
All fixed in this commit.

Command line help message was adjusted.

Additionally unified "// nolint:linter" comments - one space between text
and "//", rest made as short as possible (no spaces)

Verification:
$ gometalinter --deadline=60s --config .gometalinter.json ./...

Change-Id: Ibc18c019385bfb7207b4375d19cb5812bbbf987a
Signed-off-by: Alexander Mazuruk <a.mazuruk@samsung.com>
5 years agoAdd Weles requirements/dependencies to docs 28/189928/9
Alexander Mazuruk [Mon, 24 Sep 2018 06:44:03 +0000 (08:44 +0200)]
Add Weles requirements/dependencies to docs

Change-Id: Id520f1fa9c6757cf22bb04e31bb5f1ce07076375
Signed-off-by: Alexander Mazuruk <a.mazuruk@samsung.com>
5 years agoDocument creating a job 27/189927/9
Alexander Mazuruk [Mon, 24 Sep 2018 06:26:25 +0000 (08:26 +0200)]
Document creating a job

Quickly written guide on how to create Weles job yaml.

Change-Id: Id7b2949dfb7d332d37f557068646bb338e12c892
Signed-off-by: Alexander Mazuruk <a.mazuruk@samsung.com>
5 years agoAdjust CSS for generated API documentation 24/191224/5
Katarzyna Gorska [Fri, 12 Oct 2018 14:37:18 +0000 (16:37 +0200)]
Adjust CSS for generated API documentation

Hotfix due to conflict between alabaster theme and generated html
document from swagger. Changing theme across repositories requires more
work thus css fix is applied.

Verification:

  $ make docs

  $ xdg-open doc/build/html/api.html
  $ sensible-browser doc/build/html/api.html

Should not have any unreadable text.

Change-Id: I2c588e376a55b5da163cfe31bfacb752cd83dcfd
Signed-off-by: Katarzyna Gorska <k.gorska@samsung.com>
5 years agoAdd API documentation 96/189796/13
Alexander Mazuruk [Thu, 20 Sep 2018 13:46:17 +0000 (15:46 +0200)]
Add API documentation

Generated using:
$ make docs-swagger

Needs css adjustments to alabaster theme.

Change-Id: I90eb6277ef046a1d7e5f716bffa29d9523d50616
Signed-off-by: Alexander Mazuruk <a.mazuruk@samsung.com>
5 years agoInclude README in documentation 04/189804/12
Alexander Mazuruk [Thu, 20 Sep 2018 15:01:11 +0000 (17:01 +0200)]
Include README in documentation

This patch also adds two missing colons to the README to render all code
blocks properly.

Change-Id: Icd9a73bfb761037000ecf35c9cb5d372d1ffc88b
Signed-off-by: Alexander Mazuruk <a.mazuruk@samsung.com>
5 years agoAdjust Makefile 83/189683/14
Alexander Mazuruk [Thu, 20 Sep 2018 16:52:16 +0000 (18:52 +0200)]
Adjust Makefile

Change-Id: Iee1d410de72f70617751c22218b08aafa9406c28
Signed-off-by: Alexander Mazuruk <a.mazuruk@samsung.com>
Signed-off-by: Michal Sidor <m.sidor@samsung.com>
5 years agoAdd Sphinx build environment in Docker 91/185791/19
Michal Sidor [Thu, 2 Aug 2018 09:11:05 +0000 (11:11 +0200)]
Add Sphinx build environment in Docker

Docker file same as for MuxPi and Boruta including:
 - support for Python (required by Sphinx)
 - Java (required by plantuml plugin)
 - a few Sphinx plugins such as seqdiag

Change-Id: I154b7def3e147faee5090940aaf14459933aacc9
Signed-off-by: Michal Sidor <m.sidor@samsung.com>
5 years agoInitialize Sphinx documentation 80/185880/16
Michal Sidor [Fri, 3 Aug 2018 07:00:49 +0000 (09:00 +0200)]
Initialize Sphinx documentation

Generated using Sphinx v1.8.0:

    cd doc
    sphinx-quickstart --quiet --sep --project="Weles" --no-batchfile \
    --author="Samsung Electronics Co., Ltd" --suffix .txt \
    --language en -v 0.0.1 .
    sed -i -e '/modindex/d' source/index.txt

Headline of index.txt was altered to avoid awkward "Weles's".

Change-Id: I215c8b9e70d64165d8c309a117beb438bd0a0f12
Signed-off-by: Michal Sidor <m.sidor@samsung.com>
5 years agoUpdate gometalinter config
Alexander Mazuruk [Wed, 21 Nov 2018 17:32:45 +0000 (18:32 +0100)]
Update gometalinter config

One of the linters was renamed, update was necessary for consistent
checkers between SLAV repositories.

Change-Id: I2247b442c0dd1fca324ffb0b9c7f83e42f073a87
Signed-off-by: Alexander Mazuruk <a.mazuruk@samsung.com>
5 years agoRelease version 0.1.0
Pawel Wieczorek [Tue, 9 Oct 2018 14:20:36 +0000 (16:20 +0200)]
Release version 0.1.0

Change-Id: I93d02f936e619418c1c06b326e60f89a33484847
Signed-off-by: Alexander Mazuruk <a.mazuruk@samsung.com>
Signed-off-by: Pawel Wieczorek <p.wieczorek2@samsung.com>
5 years agoAdjust README 08/189908/4
Alexander Mazuruk [Fri, 21 Sep 2018 11:42:27 +0000 (13:42 +0200)]
Adjust README

* Add info regarding docker build
* Remove tizen.org related stuff in favor of github.com
* Add reminder about setting boruta flag
* Fix rst error - lack of newline after a list
* Unify lists to use *

Change-Id: I3fd43674fc8e482fa1e2e8015c070c056bcbe32a
Signed-off-by: Alexander Mazuruk <a.mazuruk@samsung.com>
5 years agoAdd build Dockerfile
Alexander Mazuruk [Sat, 21 Jul 2018 04:03:12 +0000 (06:03 +0200)]
Add build Dockerfile

Verification:

1. Modify swagger.yml

2. Build Weles using Dockerfile (should yield server binary in bin/)

$ make

3. Run it:

$ ./bin/weles --port 5010

4. Check 127.0.0.1:5010/api/v1/docs for changes applied to swagger.yml

Change-Id: Ic80f530a3e84a868162634e40e5c94c64fd4ba5d
Signed-off-by: Alexander Mazuruk <a.mazuruk@samsung.com>
Signed-off-by: Pawel Wieczorek <p.wieczorek2@samsung.com>
5 years agoMove to GitHub
Pawel Wieczorek [Fri, 5 Oct 2018 12:37:54 +0000 (14:37 +0200)]
Move to GitHub

Boruta no longer has to be ignored by dep since it is now go-gettable.

This patch also skips models in swagger server generation. Even though
swagger generation has been split, server still forced models update.

Relevant: Change-Id: Iada8947bb2006fee318caf9ed87731a925ca10bf

Verification:

$ go get -u github.com/golang/dep/cmd/dep && \
  make dep-update && make mocks && make swagger-server-generate

Change-Id: Icff1ecb2fa547ad99e9980ef88c58a9480deb0ff
Signed-off-by: Pawel Wieczorek <p.wieczorek2@samsung.com>
5 years agoMerge branch 'prerelease' 78/190678/1
Pawel Wieczorek [Thu, 4 Oct 2018 14:10:25 +0000 (16:10 +0200)]
Merge branch 'prerelease'

Change-Id: Ic2f9724e715404ecc2165843f657482ea7751e6b

5 years agoAdd transaction rollback in database filter 69/190669/4
Alexander Mazuruk [Thu, 4 Oct 2018 13:07:33 +0000 (15:07 +0200)]
Add transaction rollback in database filter

When error ocurred, transactions where not rolled back which caused
one error to render whole artifacts module unusable.

Thanks @Michal for catching this.

Change-Id: I434e9c24819e01d703e304765f841a6b55f65385
Signed-off-by: Alexander Mazuruk <a.mazuruk@samsung.com>
5 years agoRename device type capability in Boruta request 01/190501/2
Pawel Wieczorek [Tue, 2 Oct 2018 13:08:09 +0000 (15:08 +0200)]
Rename device type capability in Boruta request

In order to avoid confusion, unify capability naming convention and
comply with LAVA YAML job submission files [1], Dryads shall declare
"device_type" capability. It will be used in Dryad config files, Boruta
requests and Weles job descriptions.

[1] https://validation.linaro.org/static/docs/v2/dispatcher-format.html

Change-Id: Icac66490570569d4a7c02c9318130163a9e45950
Signed-off-by: Pawel Wieczorek <p.wieczorek2@samsung.com>
5 years agoFix database is locked error 99/188399/13
Alexander Mazuruk [Tue, 4 Sep 2018 11:56:26 +0000 (13:56 +0200)]
Fix database is locked error

Bug:
1. Create quickly around 10-30 job requests (same .yml can be used)
2. List Weles jobs after few seconds.
3. Some of the jobs should have following:
 "info": "Internal Weles error while creating file path in ArtifactDB : database is locked",

When Weles received requests in quick succession it tried to write to
database in more than 1 goroutine. This resulted in "database is locked"
error. This should be resolved by handling this error or customizing
sqlite3 settings.

The issue is described in the following thread:
https://github.com/mattn/go-sqlite3/issues/274

This commit:
- adds logging of artifact insert failure
- sets _BUSY_TIMEOUT of sqlite3 to 5s
- limits max No of open db connections to 1
- fixes tests which failed inconsistently in CI

Verification:
Build Weles with this commit, go through steps below "Bug:". Jobs should
not fail due to "database is locked"

Change-Id: I45dd00e832df0cb234d49b219ad736c37a4be629
Signed-off-by: Alexander Mazuruk <a.mazuruk@samsung.com>
5 years agoAdjust validation to allow empty values 08/188908/13
Alexander Mazuruk [Mon, 10 Sep 2018 18:37:07 +0000 (20:37 +0200)]
Adjust validation to allow empty values

After user input is marshalled, swagger server validates data. When
input data is enum, it was strictly validated against enum values.
There is no empty value thus user receives an error and is forced to
always set enum fields in e.g. JobFilter.Status.

Modifying generated code is a bad practice but it was not possible (to
the best of the authors knowledge) to achieve this by simply modyfing
swagger.yml and re-generating models.

Possible solutions:
- adding and using new type (which would satisfy swaggers interfaces)
- customizing code generation

Change-Id: Ifc381a12936277db9938032dadb31fe865e84ad1
Signed-off-by: Alexander Mazuruk <a.mazuruk@samsung.com>
5 years agoSplit swagger generation into server and models 36/189436/6
Alexander Mazuruk [Mon, 17 Sep 2018 15:24:12 +0000 (17:24 +0200)]
Split swagger generation into server and models

This change will allow to adjust generated models validation.

Change-Id: Iada8947bb2006fee318caf9ed87731a925ca10bf
Signed-off-by: Alexander Mazuruk <a.mazuruk@samsung.com>
5 years agoAdjust database tests 30/186930/18
Alexander Mazuruk [Wed, 15 Aug 2018 12:41:49 +0000 (14:41 +0200)]
Adjust database tests

Make artifacts/database tests faster (8s->2.5s) by restructurizing
before/afterEach clauses to omit unneccessary setup before TCs.
Finished packing setups into single transactions with db.

Merged tests for pagination into database tests.

Add tests for sorting

Less magic

Change-Id: I49c82c4d0bfc000498b555c0d56490d939e24713
Signed-off-by: Alexander Mazuruk <a.mazuruk@samsung.com>
5 years agoAdd coding style guide to CONTRIBUTING 20/187520/4
Alexander Mazuruk [Thu, 23 Aug 2018 16:20:13 +0000 (18:20 +0200)]
Add coding style guide to CONTRIBUTING

Change-Id: I72909d21cf7b7c6e19ea4b3c50ce6cec2ec03245
Signed-off-by: Alexander Mazuruk <a.mazuruk@samsung.com>
5 years agoAdd CONTRIBUTING 52/184552/10
Alexander Mazuruk [Wed, 18 Jul 2018 12:23:14 +0000 (14:23 +0200)]
Add CONTRIBUTING

Change-Id: I79a957e52e9c28f70bc2d127611613c3222c3b1c
Signed-off-by: Alexander Mazuruk <a.mazuruk@samsung.com>
5 years agoRefactor job lister tests 35/189435/3
Alexander Mazuruk [Mon, 17 Sep 2018 16:45:29 +0000 (18:45 +0200)]
Refactor job lister tests

Previous tests of job lister had little to no value.

Change-Id: Iae66d511b9610b03102a1a4e84aca9d3e8a47a89
Signed-off-by: Alexander Mazuruk <a.mazuruk@samsung.com>
5 years agoRefactor artifact lister tests 44/186444/18
Alexander Mazuruk [Thu, 2 Aug 2018 09:39:13 +0000 (11:39 +0200)]
Refactor artifact lister tests

Previous tests of artifact lister handler had little to no value.

Change-Id: I95dc0e3b1a74e009b1de031ebb315f251d1d8601
Signed-off-by: Alexander Mazuruk <a.mazuruk@samsung.com>
5 years agoUnify JobFilter returned by server 34/189434/2
Alexander Mazuruk [Mon, 17 Sep 2018 15:20:38 +0000 (17:20 +0200)]
Unify JobFilter returned by server

Further description in job_lister_handler.go file and Unify
ArtifactFilter returned by server commit.

Change-Id: Ieda839e30ee6be96187cb9551f9b4cb768298db9
Signed-off-by: Alexander Mazuruk <a.mazuruk@samsung.com>
5 years agoUnify ArtifactFilter returned by server 14/188914/6
Alexander Mazuruk [Tue, 11 Sep 2018 16:19:53 +0000 (18:19 +0200)]
Unify ArtifactFilter returned by server

Due to how json array marshalling works in go:

Having following struct:

type A struct{
    Key1 []string
    Key2 []string
}

When following empty JSON was sent:
{ Key1: [], Key2: [] }

We would receive a struct:
Key1, Key2 - one element slice with empty string

If we would send:
{ Key2: [] }

We would receive a struct:
Key1 - empty slice
Key2 - one element slice with empty string

This commit unifies empty values returned by server to always be empty
slice.

Change-Id: I24ff156dc98f5a1e160858cc3ce02ecd44387129
Signed-off-by: Alexander Mazuruk <a.mazuruk@samsung.com>
5 years agoSet defaults on JobSorter 09/188909/9
Alexander Mazuruk [Tue, 11 Sep 2018 14:22:44 +0000 (16:22 +0200)]
Set defaults on JobSorter

Additionally, this commit unifies how server treats query params
(pagination). They are always ignored if pagination is turned off
(either by user or admin)

Test have been hotfixed to pass and will be fixed in future commits on
this branch.

Change-Id: I12eb875972ac818b0630f10ae95289ff7aef7f88
Signed-off-by: Alexander Mazuruk <a.mazuruk@samsung.com>
5 years agoAllow user to sort with JobSortByID 07/188907/9
Alexander Mazuruk [Tue, 11 Sep 2018 14:21:18 +0000 (16:21 +0200)]
Allow user to sort with JobSortByID

Previously, it was only possible to sort by ID by sending JSON which did
not contain SortBy field.

Change-Id: Ia91bacc1ba8b4df9809faaefc0b54c3196cdcf19
Signed-off-by: Alexander Mazuruk <a.mazuruk@samsung.com>
5 years agoMove default ArtifactSortOrder to server 43/186443/15
Alexander Mazuruk [Tue, 31 Jul 2018 17:16:45 +0000 (19:16 +0200)]
Move default ArtifactSortOrder to server

Previously database package was responsible for setting default
value.

Test were fixed to pass but have little to no value. Next commit will
change tests to be more readable and have less "magic".

Additionally this commit unifies how server treats query params
(pagination). They are always ignored if pagination is turned off
(either by user or admin)

Change-Id: I3d9eaaf517596394537eb8bf9333ebc74c43812c
Signed-off-by: Alexander Mazuruk <a.mazuruk@samsung.com>
5 years agoUnify paths to Dryad tools 42/185942/11
Pawel Wieczorek [Fri, 3 Aug 2018 16:48:49 +0000 (18:48 +0200)]
Unify paths to Dryad tools

Although binaries for Dryad tools (STM and FOTA) are placed in
"/usr/bin", their wrappers which should be primarily used are available
in "/usr/local/bin". This patch unifies those paths until tools are
provided as Dryad API.

Change-Id: Ic34658a7466fd3887996c0248fcdd10fb51f43b2
Signed-off-by: Pawel Wieczorek <p.wieczorek2@samsung.com>
5 years agoPass Artifact DB path to Dryad jobs 43/185943/12
Pawel Wieczorek [Fri, 3 Aug 2018 17:41:51 +0000 (19:41 +0200)]
Pass Artifact DB path to Dryad jobs

After reverse SSHFS introduction for transferring files between Weles
and Dryad assigned for a given job, Artifact DB had to be available
under proper mountpoint on Dryad. This patch propagates path to Artifact
DB from command line flag through Dryad Job Manager to newly created
Dryad Jobs.

Change-Id: I36fdec4ec6f04b2e544a38218b0faeeec1dddaa2
Signed-off-by: Pawel Wieczorek <p.wieczorek2@samsung.com>
5 years agoFix artifact test which failed occasionally in CI 38/189138/4
Alexander Mazuruk [Thu, 13 Sep 2018 22:27:50 +0000 (00:27 +0200)]
Fix artifact test which failed occasionally in CI

Channels in artifacts should be synchronized, for the artifacts to set
state of the artifact only after it is written to the database.
Currently, there might be requested information about artifact which is
not yet in the db. This should be done in separate commit

Change-Id: Ic6da4ea9fe63ea8a42995ef837ad692557979afc
Signed-off-by: Lukasz Wojciechowski <l.wojciechow@partner.samsung.com>
Signed-off-by: Alexander Mazuruk <a.mazuruk@samsung.com>
5 years agoMake filtering one db transaction 18/189018/5
Alexander Mazuruk [Wed, 12 Sep 2018 16:40:16 +0000 (18:40 +0200)]
Make filtering one db transaction

Change-Id: I4a7d1a64addf08bd4f469b47705c9ff7c0a6b7bd
Signed-off-by: Alexander Mazuruk <a.mazuruk@samsung.com>
5 years agoAdjust fixtures to produce more than one artifact per job id 29/186929/13
Alexander Mazuruk [Tue, 14 Aug 2018 12:39:13 +0000 (14:39 +0200)]
Adjust fixtures to produce more than one artifact per job id

Change-Id: I6c0354c974c054f6b57e9b5b9479278e8c1c979a
Signed-off-by: Alexander Mazuruk <a.mazuruk@samsung.com>
5 years agoMove ArtifactNotFound error to database pkg 45/186445/17
Alexander Mazuruk [Fri, 3 Aug 2018 12:03:29 +0000 (14:03 +0200)]
Move ArtifactNotFound error to database pkg

Previously server was checking for this error.

Change-Id: I17467a4569c4ec6c65954c0a3a97b12351ec8848
Signed-off-by: Alexander Mazuruk <a.mazuruk@samsung.com>
5 years agoRemove JobFilterAndSort from Weles pkg 75/187375/10
Alexander Mazuruk [Wed, 22 Aug 2018 10:14:55 +0000 (12:14 +0200)]
Remove JobFilterAndSort from Weles pkg

This struct is now in server/operations/jobs pkg, renamed
(automatically by go-swagger) to JobListerBody. This struct
is only used by server thus should not clutter main weles pkg.

Change-Id: I542c37c44951fa897432bf3ba7badd2867e4ebf3
Signed-off-by: Alexander Mazuruk <a.mazuruk@samsung.com>
5 years agoRemove ArtifactFilterAndSort from Weles pkg 55/186455/13
Alexander Mazuruk [Tue, 31 Jul 2018 17:09:49 +0000 (19:09 +0200)]
Remove ArtifactFilterAndSort from Weles pkg

This struct is now in server/operation/artifacts pkg, renamed
(automatically by go-swagger) to ArtifactListerBody. This struct
is only used by server thus should not clutter main weles pkg.

Change-Id: Ic7cb7ab68cb0feb506f318a5ae4b769065b8c96f
Signed-off-by: Alexander Mazuruk <a.mazuruk@samsung.com>
5 years agoUpdate go-swagger, regenerate server 05/186705/10
Alexander Mazuruk [Mon, 13 Aug 2018 15:30:00 +0000 (17:30 +0200)]
Update go-swagger, regenerate server

This resolves bug where out of ArtifactInfo struct only
ArtifactDescription was marshalled to JSON:
https://github.com/go-swagger/go-swagger/issues/1617
Fixed in 0.16.0 release.

1. Updated Gopkg.toml
2. Re-generated Gopkg.lock
$ make Gopkg.lock
3. Build new swagger
$ make tools
4. Re-generate swagger server
$ make swagger-server-generate

Change-Id: I622e4a2500203f4236d8938031abfee136c69b81
Signed-off-by: Alexander Mazuruk <a.mazuruk@samsung.com>
5 years agoAdd README 51/184551/8
Alexander Mazuruk [Wed, 18 Jul 2018 16:48:25 +0000 (18:48 +0200)]
Add README

Change-Id: I219454ace706cff56ac37ba24565d838002e7627
Signed-off-by: Alexander Mazuruk <a.mazuruk@samsung.com>
Signed-off-by: Pawel Wieczorek <p.wieczorek2@samsung.com>
5 years agoRemove unused Select function 54/186454/11
Alexander Mazuruk [Thu, 9 Aug 2018 15:58:44 +0000 (17:58 +0200)]
Remove unused Select function

Discussed with artifacts pkg author, it was left from previous
implementation.

Change-Id: I99f1035bd36e1e91ace82c64b046db053abcf5c2
Signed-off-by: Alexander Mazuruk <a.mazuruk@samsung.com>
5 years agoMerge branch 'ci' 12/188812/1
Pawel Wieczorek [Mon, 10 Sep 2018 12:48:45 +0000 (14:48 +0200)]
Merge branch 'ci'

Change-Id: I9805c84f042771a22476dd93b4ee7b8ea58999a4

5 years agoAdd config for gometalinter 52/185552/23
Alexander Mazuruk [Tue, 31 Jul 2018 12:47:52 +0000 (14:47 +0200)]
Add config for gometalinter

As there are differences between Boruta and Weles (e.g. usage of
vendoring) we need different sets of linter policies.

Tool:
https://github.com/alecthomas/gometalinter

Install:
$ go get -u gopkg.in/alecthomas/gometalinter.v2

Using gometalinter in Weles repository root will use this config by
default.

Config file documentation:
https://github.com/alecthomas/gometalinter#configuration-file

Format of the config file is determined by Config struct:
https://github.com/alecthomas/gometalinter/blob/master/config.go

There is an issue with gas installation currently:
https://github.com/alecthomas/gometalinter/issues/508

Currently there is a pull request to add support for ignoring generated
files:
https://github.com/walle/lll/pull/4

In current patchset generated files are excluded manually (by pkg or
filename)

Change-Id: Ib750066370392d44555aa5b5d4f342acc06c9b36
Signed-off-by: Alexander Mazuruk <a.mazuruk@samsung.com>
5 years agoSplit Controller's job listing and filtering 03/186603/14
Lukasz Wojciechowski [Fri, 10 Aug 2018 20:46:01 +0000 (22:46 +0200)]
Split Controller's job listing and filtering

The splitting improves readability of the code
and lowers cyclomatic complexity of the functions.

Method JobsControllerImpl.List has been split into:
* filter - returning JobInfos matching filter;
* sort - sorting them;
* paginate - calculating returned page indexes and sizes.

The List function by itself stays responsible for setting up critical
section for accessing jobs collection, runs above functions and returns
proper records and info.

One mechanism requires clarification. If JobID used as index in pagination
does not match filter, it must be temporary added to Jobs collection
for calculation of the index position after sorting.
The "extra" variable is used for containing information, if this job
is added to the collection.

Method Job.passesFilter has been split into several methods.
Each of them verifies if one of the Job fields passes through the filter:
* Job.passesCreatedAfterFilter,
* Job.passesCreatedBeforeFilter,
* Job.passesUpdatedAfterFilter,
* Job.passesUpdatedBeforeFilter,
* Job.passesInfoFilter,
* Job.passesJobIDFilter,
* Job.passesNameFilter,
* Job.passesStatusFilter,
exactly as the name of the function suggests.

Change-Id: I03bab42db51c168afc06d5e954dfcbd137637f12
Signed-off-by: Lukasz Wojciechowski <l.wojciechow@partner.samsung.com>
5 years agoFix linter errors in manager pkg 89/186289/18
Alexander Mazuruk [Wed, 8 Aug 2018 10:50:58 +0000 (12:50 +0200)]
Fix linter errors in manager pkg

Fixed possible context leak in reverse_sshfs.go

Verification:
$ go vet ./manager/...

Added directive for gometalinter/{gas,gosec} to ignore intentional
launch of subprocess with a variable.

Verification:
$ gometalinter.v2 --disable-all --vendor --enable=gas ./manager/...

Fixed variable shadowing.

Verification:
$ go vet -shadow ./manager/...

Fix unhandled errors:
- ignore unhandled errors
- use log library to log errors.

Verification:
$ gometalinter.v2 --disable-all --vendor --enable=errcheck

Change-Id: I777ca6ecfa8da73255efbb4898388b170641276f
Signed-off-by: Alexander Mazuruk <a.mazuruk@samsung.com>
5 years agoHandle server shutdown error 11/186111/16
Alexander Mazuruk [Tue, 7 Aug 2018 04:59:50 +0000 (06:59 +0200)]
Handle server shutdown error

Use standard log library to log error.

Change-Id: I6c6f8ef627d21b929787fabef9794e59d69bf674
Signed-off-by: Alexander Mazuruk <a.mazuruk@samsung.com>
5 years agoFix linter errors in controller pkg 10/186110/16
Alexander Mazuruk [Tue, 7 Aug 2018 03:24:38 +0000 (05:24 +0200)]
Fix linter errors in controller pkg

Remove shadowed variables:
in: downloaderimpl.go, jobscontrollerimpl_test.go

Verification:
$ go vet -shadow=true ./controller/...

Fix unhandled errors:
- ignore errors explicitly (using _)
in: boruterimpl.go, controller.go, dryaderimpl.go, jobscontrollerimpl.go

Use standard log library to log some errors.

Verification:
$ gometalinter.v2 --disable-all --vendor --enable=gas --enable=errcheck  ./controller/...

Remove unused parameter:
in: boruterimpl.go

Verification:
$ gometalinter.v2 --disable-all --vendor --enable=unparam   ./controller/...

Remove unneccessary cast:
in: controller_test.go

Verification:
$ gometalinter.v2 --disable-all --vendor --enable=unconvert  ./controller/...

Add directive for gometalinter/gocyclo to ignore passessFilter() func. This
funciton is readable as-is and breaking it down into smaller functions
would increase allocations while decreasing readability.

Added TODO comment on List() function for the author to break it down.

Thanks to gagarin for help with error handling.

Change-Id: I486a29aa5a83e91775d4d3f370f9d6a19a81b8e9
Signed-off-by: Alexander Mazuruk <a.mazuruk@samsung.com>
5 years agoHandle fixture errors 08/186108/16
Alexander Mazuruk [Mon, 6 Aug 2018 15:45:15 +0000 (17:45 +0200)]
Handle fixture errors

Those errors are handled by panic. They will not occur due to fixed input.

gometalinter.v2 --disable-all --vendor --enable=gas --enable=errcheck  ./fixtures/...

Change-Id: I88a6aa7276bb3a48878620094ca6ea9345c29ded
Signed-off-by: Alexander Mazuruk <a.mazuruk@samsung.com>
5 years agoFix error handling in artifacts{,/*} pkg 41/185941/17
Alexander Mazuruk [Fri, 3 Aug 2018 16:27:45 +0000 (18:27 +0200)]
Fix error handling in artifacts{,/*} pkg

- Handled a few unhandled errors (reported by gas and errcheck).

Verification:
$ gometalinter.v2 --disable-all --vendor --enable=gas --enable=errcheck  ./artifacts/...

Should return no errors.

Some errors should just be logged and are logged via standard log
library.

Additionally call to getID function and the function itself were
removed. They were not neccessary after moving ID field to ArtifactInfo
struct.

Change-Id: If0d249aa08e296c7b46bc06532fe51d835e1b5c6
Signed-off-by: Alexander Mazuruk <a.mazuruk@samsung.com>
5 years agoRemove shadowing variables from artifacts pkg 40/185940/14
Alexander Mazuruk [Fri, 3 Aug 2018 14:01:40 +0000 (16:01 +0200)]
Remove shadowing variables from artifacts pkg

Verification:

$ gometalinter.v2 --disable-all --enable=vetshadow --vendor ./artifacts/...

Change-Id: I25cb9d583075ff61fc210e4c1bd09111f7ff73cc

5 years agoFix line length to max 100 36/185936/14
Alexander Mazuruk [Fri, 3 Aug 2018 13:24:29 +0000 (15:24 +0200)]
Fix line length to max 100

Formatting is not super consistent. I'd love some input on a correct way
of formatting or should I leave it as is.

Verification:
G=`grep -RHI "Code generated" | grep -ve "^vendor" | sed -e 's|:.*||' | sort -u`; \
gometalinter.v2 --disable-all --linter='lll:lll -l 100 -w 4:PATH:LINE:MESSAGE' \
--vendor --skip="mock" --enable=lll ./... | grep -vF "$G"

Should return only 2 occurences of line going over the limit. Those
occurences have "// nolint: lll" comment added on the end of the line to
supress gometalinter from complaining.

Change-Id: I1ea1838233329de63d947de8488b9df682614249
Signed-off-by: Alexander Mazuruk <a.mazuruk@samsung.com>
5 years agoSimplify loop in server_suite_test 09/186109/7
Alexander Mazuruk [Mon, 6 Aug 2018 13:56:12 +0000 (15:56 +0200)]
Simplify loop in server_suite_test

Change-Id: I66391fd2d26cfe0d2a237c4861eaade20d0985f7
Signed-off-by: Alexander Mazuruk <a.mazuruk@samsung.com>
5 years agoMove building sort query to separate func 35/185935/9
Alexander Mazuruk [Mon, 30 Jul 2018 16:08:36 +0000 (18:08 +0200)]
Move building sort query to separate func

This is to reduce cyclomatic complexity of the function and increase
its readability.

Change-Id: I1db6505c90d2ca622ee4d86892dde2efcb9b19ca
igned-off-by: Alexander Mazuruk <a.mazuruk@samsung.com>

5 years agoMove database filter query preparation to separate func 34/185934/9
Alexander Mazuruk [Mon, 30 Jul 2018 16:05:46 +0000 (18:05 +0200)]
Move database filter query preparation to separate func

This is to reduce cyclomatic complexity of the function and increase
readability.

Change-Id: I9292cb37c605e8cd6f6ba7e35af2d5e82556cc5c
Signed-off-by: Alexander Mazuruk <a.mazuruk@samsung.com>
5 years agoRemove redundant go:generate 02/186702/5
Alexander Mazuruk [Mon, 13 Aug 2018 12:00:17 +0000 (14:00 +0200)]
Remove redundant go:generate

This mock is generated via mock/mocks_generate.go.
go:generate in dryadjobmanager.go was redundant.

Change-Id: I03ca83bd49c82589c42ea451c625e9e1eb2ab1b6
Signed-off-by: Alexander Mazuruk <a.mazuruk@samsung.com>
5 years agoMove manager mocks to mock pkgs 47/186547/4
Alexander Mazuruk [Thu, 9 Aug 2018 19:45:00 +0000 (21:45 +0200)]
Move manager mocks to mock pkgs

This removes dependency on mockgen binary in bin/dev-tools to build
weles. (go build triggered go generates in manager pkg which required
mockgen)

Change-Id: I1eb89dce25e2ac0cefcac5dd2ef0bc9bc71760c8
Signed-off-by: Alexander Mazuruk <a.mazuruk@samsung.com>
5 years agoRemove . imports from managers pkg 33/185933/8
Alexander Mazuruk [Mon, 30 Jul 2018 12:43:04 +0000 (14:43 +0200)]
Remove . imports from managers pkg

golint complains about using . imports.

managers package was the last one containing . imports.

Verification:

$ golint ./... | grep -v -e "^vendor*"

Change-Id: I603201cc627691881692b5990b00ad9b606f9e4f
Signed-off-by: Alexander Mazuruk <a.mazuruk@samsung.com>
5 years agoChange ALL_CAPS to CamelCase in DryadJobStatus 32/185932/6
Alexander Mazuruk [Mon, 30 Jul 2018 12:37:04 +0000 (14:37 +0200)]
Change ALL_CAPS to CamelCase in DryadJobStatus

golint complains about using ALL_CAPS.

DJ_<STATUS> were renamed to DryadJobStatus<STATUS>

All occurrences were renamed.

Verification:

$ golint ./... |grep -v -e "^vendor*"

Should not report any warnings regarding ALL_CAPS.

Change-Id: I74afd3b2e24d368aaa63d999ef256df8f2af8566
Signed-off-by: Alexander Mazuruk <a.mazuruk@samsung.com>
5 years agoAdd keys to composite literals declarations 31/185931/5
Alexander Mazuruk [Mon, 30 Jul 2018 12:23:27 +0000 (14:23 +0200)]
Add keys to composite literals declarations

go vet complains about unkeyed composite literals.
This commit adds keys to all composite literal definitions.
This allows adding fields to structs without rewriting code.

Verification:
go vet -composites ./...

Should return no errors.

Change-Id: I59338e47afdddfa1efae2998c9cbdf6049d3a459
Signed-off-by: Alexander Mazuruk <a.mazuruk@samsung.com>
5 years agoSimplify bool comparisons 30/185930/4
Alexander Mazuruk [Mon, 30 Jul 2018 11:19:53 +0000 (13:19 +0200)]
Simplify bool comparisons

Weles has been analyzed with gosimple:
https://github.com/dominikh/go-tools/tree/master/cmd/gosimple

Simplifications here are similiar to formatting code with gofmt as
follows:
$ gofmt -s -w

Additionally getTotal and getRemaining in artifacts/database/database.go
have been renamed to totalRecords and remainingRecords respectively.

Renaming reason:
https://golang.org/doc/effective_go.html#Getters

Verification:
$ gometalinter.v2 --disable-all --vendor --enable=gosimple ./...

Should report no errors

Change-Id: Id1c639e5398d7f07fff4c6c6815ff36c5b499751
Signed-off-by: Alexander Mazuruk <a.mazuruk@samsung.com>
5 years agoRemove unused assignments 29/185929/3
Alexander Mazuruk [Mon, 30 Jul 2018 09:26:07 +0000 (11:26 +0200)]
Remove unused assignments

Weles has been analyzed with ineffassign:
https://github.com/gordonklaus/ineffassign

https://github.com/golang/go/wiki/CodeReviewComments#declaring-empty-slices

Change-Id: Ib05a41f0f35c8b2831b9c5f5ecc85c1774c82555
Signed-off-by: Alexander Mazuruk <a.mazuruk@samsung.com>
5 years agoRemove unnecessary type conversions 28/185928/3
Alexander Mazuruk [Fri, 27 Jul 2018 16:42:11 +0000 (18:42 +0200)]
Remove unnecessary type conversions

Weles has been analyzed with unconvert:
https://github.com/mdempsky/unconvert

This should make code more readable.

Verification:
$ gometalinter.v2 --disable-all --vendor --enable=unconvert ./...

There should be only errors in server/server.go which is generated code.

Change-Id: I8288cb65b9faecd1b16854bf6f4bd3427dd3a01f
Signed-off-by: Alexander Mazuruk <a.mazuruk@samsung.com>
5 years agoMerge branch 'api' 58/185558/1 cors
Pawel Wieczorek [Mon, 30 Jul 2018 16:09:57 +0000 (18:09 +0200)]
Merge branch 'api'

Change-Id: I73745abe146f5e9d6e3a9ba886f727da53a2b32e

5 years agoAdd protocol and IP to default Boruta address.
Alexander Mazuruk [Fri, 27 Jul 2018 15:53:40 +0000 (17:53 +0200)]
Add protocol and IP to default Boruta address.

Weles will not connect to Boruta if protocol and address are not
specified.

Change-Id: I42ad88c5b2b1c4de42347def1d505bee5581f652
Signed-off-by: Alexander Mazuruk <a.mazuruk@samsung.com>
5 years agoAllow disabling pagination in artifacts
Alexander Mazuruk [Wed, 25 Jul 2018 15:57:04 +0000 (17:57 +0200)]
Allow disabling pagination in artifacts

When ArtifactPagination.Limit is 0, .ID and .Forward are ignored.

Additionally, when empty ArtifactSorter is passed, correct sorting is
applied (ascending).

Change-Id: Ibc2cc7ca688c854b33762ee8639ceb9b0529a937
Signed-off-by: Alexander Mazuruk <a.mazuruk@samsung.com>
5 years agoAllow disabling pagination by setting limit to 0 56/185056/8
Lukasz Wojciechowski [Wed, 25 Jul 2018 14:24:04 +0000 (16:24 +0200)]
Allow disabling pagination by setting limit to 0

If JobPagination.Limit is set to 0, then:
* JobID and Forward fields are ignored;
* pagination in listing jobs is disabled;
* all records matching filter are returned.

This patch adjusts JobsController implementation to above new rule.
It modifies also tests to cover new feature.

Change-Id: I929b89aa100d8f491886d0861592de2004758424
Signed-off-by: Lukasz Wojciechowski <l.wojciechow@partner.samsung.com>
5 years agoAdd list artifacts path to API 82/181382/29
Alexander Mazuruk [Tue, 5 Jun 2018 13:25:31 +0000 (15:25 +0200)]
Add list artifacts path to API

There is an issue with generated marshalling and unmarshalling:
https://github.com/go-swagger/go-swagger/issues/1617
Currently generated code with explicit marshalling in artifact_info.go
is commented out. Implicit marshalling works fine.

Change-Id: I211ea81636fe0b7d25d4fb1e7d76b55dacae7121
Signed-off-by: Alexander Mazuruk <a.mazuruk@samsung.com>
5 years agoAdd info about default artifact sorting 39/185439/2
Alexander Mazuruk [Mon, 30 Jul 2018 14:38:20 +0000 (16:38 +0200)]
Add info about default artifact sorting

Change-Id: Idced62086616b1252a6a19575e64bea0ed6c14d4
Signed-off-by: Alexander Mazuruk <a.mazuruk@samsung.com>
5 years agoAdd pagination to artifacts/database 81/181381/28
Alexander Mazuruk [Tue, 5 Jun 2018 13:12:56 +0000 (15:12 +0200)]
Add pagination to artifacts/database

There was a problem with pagination key for ArtifactInfo objects.
Only ArtifactInfo.Path was unique and artifacts database ID was not
accessible. This patch moves ID field to ArtifactInfo from previous struct,
artifactInfoRecord which extended ArtifactInfo and was local to the
database package.

Added identifiers to structs in test as after adding field to
ArtifactInfo there were build errors.

Added some more verbose error messages in database Filtering function.

Added pagination and sorting.

Changed artifacts/database/database_suite_test.go package from
database_test to database as all tests are white-box.

And of course the main purpose of this commit- pagination and sorting of
artifacts is now possible.

Tests were added in separate package, server_suite_test.go contains
beforeSuite initialization which is used only by pagination_test.go
before/after suite has no effect on previous tests of database.

Change-Id: Ic74dfa403ea486faca94aa39e5cb063abdc31ac4
Signed-off-by: Alexander Mazuruk <a.mazuruk@samsung.com>
5 years agoAdd fixture generator module for testing 58/183758/17
Alexander Mazuruk [Mon, 9 Jul 2018 15:25:12 +0000 (17:25 +0200)]
Add fixture generator module for testing

It will be used in tests of artifacts/database (pagination)
as well as server (artifacts pagination).

Change-Id: I3eee5e6891461c46442bcb369e1d9ec0850f3a17
Signed-off-by: Alexander Mazuruk <a.mazuruk@samsung.com>
6 years agoAdd new types to enable artifact pagination 80/181380/26
Alexander Mazuruk [Tue, 5 Jun 2018 13:09:07 +0000 (15:09 +0200)]
Add new types to enable artifact pagination

Change-Id: I1d6cd83883288676703bb18fd3026e6603aacef4
Signed-off-by: Alexander Mazuruk <a.mazuruk@samsung.com>
6 years agoAdd list jobs path to API 25/171225/48
Alexander Mazuruk [Thu, 24 May 2018 04:43:50 +0000 (06:43 +0200)]
Add list jobs path to API

The following files should be reviewed (as they were the only files not
generated by the swagger automatically but had to be filled manually):
- errors.go
- swagger.yml
- cmd/weles-server/main.go
- server/configure_weles.go
- server/job_lister_handler.go
- server/job_lister_handler_test.go
- server/handlers_helpers.go
- server/server_suite_test.go
- server/page_limit.go

Change-Id: Iab9589ca6738831f8269ba3eeb20581bba35645b
Signed-off-by: Alexander Mazuruk <a.mazuruk@samsung.com>
6 years agoRemove dot imports usage from notifier package 13/181413/25
Lukasz Wojciechowski [Wed, 13 Jun 2018 12:12:30 +0000 (14:12 +0200)]
Remove dot imports usage from notifier package

Change-Id: I58ae24b3c86d06f2f487abe18543c50e27fef3d9
Signed-off-by: Lukasz Wojciechowski <l.wojciechow@partner.samsung.com>
6 years agoImplement pagination in listing jobs 12/181412/25
Lukasz Wojciechowski [Mon, 11 Jun 2018 16:18:07 +0000 (18:18 +0200)]
Implement pagination in listing jobs

Change-Id: I5a34576315118d0a946ee1f86cf2443e41ac744f
Signed-off-by: Lukasz Wojciechowski <l.wojciechow@partner.samsung.com>
6 years agoImplement sorting in ListJobs 11/181411/25
Lukasz Wojciechowski [Mon, 11 Jun 2018 13:27:59 +0000 (15:27 +0200)]
Implement sorting in ListJobs

Patch includes Aleksander's version of sorting function selector.

Change-Id: I624bba4a07e39b0129c08d5a2513ad1e874c32cc
Signed-off-by: Lukasz Wojciechowski <l.wojciechow@partner.samsung.com>
Signed-off-by: Aleksander Mistewicz <a.mistewicz@samsung.com>
6 years agoImplement filtering in ListJobs 10/181410/25
Lukasz Wojciechowski [Mon, 11 Jun 2018 10:17:57 +0000 (12:17 +0200)]
Implement filtering in ListJobs

Change-Id: Iae458c029cfd416d39d4999bb745cf78e3720604
Signed-off-by: Lukasz Wojciechowski <l.wojciechow@partner.samsung.com>
6 years agoAdjust Controller to allow addition of pagination 67/180367/27
Lukasz Wojciechowski [Fri, 6 Jul 2018 15:08:48 +0000 (17:08 +0200)]
Adjust Controller to allow addition of pagination

The ListJobs signature has been changed to provide: better filtering,
sorting and pagination of listed jobs.

This patch provides a simple implementation ignoring filtering, sorting
and pagination. It returns all Jobs.
Following patches will add proper implementation.

The patch changes JobsController interface and requires rebuild of mock:
$ make mocks

Change-Id: Id0a806414d9090909274b438b18261193f88a9f7
Signed-off-by: Lukasz Wojciechowski <l.wojciechow@partner.samsung.com>
6 years agoAdd new types to weles to enable pagination 24/171224/35
Alexander Mazuruk [Tue, 27 Feb 2018 13:39:00 +0000 (14:39 +0100)]
Add new types to weles to enable pagination

Types generated by swagger:
- JobFilter containing filters
- JobSorter containing information about sorting the data
- JobSortBy containing enum of possible sorting keys for jobs
- SortOrder containing enum of possible sorting orders

Types added manually:
- JobPagination containing info how much data should be listed and where
should it start. Limit is int32 as Weles is intended to work on both 64
and 32 bit architectures. Due to varying integer size (which is slice
limit) on those archs, max slice len is constrained to be 32bit.
- ListInfo which holds number of total records fulfilling filter and
remaining records that have not yet been sent to the client.

Change-Id: I59e441da86856fd2bc57817ce8903ef96f669e97
Signed-off-by: Alexander Mazuruk <a.mazuruk@samsung.com>
6 years agoAdd cancel job path to API 13/170713/41
Alexander Mazuruk [Tue, 27 Feb 2018 14:17:28 +0000 (15:17 +0100)]
Add cancel job path to API

The following files should be reviewed (as they were the only files not
generated by the swagger automatically):
- swagger.yml
- server/configure_weles.go
- server/job_canceler_handler.go
- server/job_canceler_handler_test.go

Change-Id: I323b78f82c83a28f671f59105f1f5fc06a44be62
Signed-off-by: Alexander Mazuruk <a.mazuruk@samsung.com>
6 years agoAdd flags to set ArtifactManager init values 66/183566/13
Alexander Mazuruk [Fri, 6 Jul 2018 12:22:07 +0000 (14:22 +0200)]
Add flags to set ArtifactManager init values

This commit makes it possible to set ArtifactManager when executing
weles binary, rather than recompile it.

Change-Id: I14eb4c1c11c2bfc6af20bc25208874ce0e7901fd
Signed-off-by: Alexander Mazuruk <a.mazuruk@samsung.com>
6 years agoAdd create job path to API 12/170712/38
Alexander Mazuruk [Thu, 24 May 2018 03:06:13 +0000 (05:06 +0200)]
Add create job path to API

The following files were edited manually:
- swagger.yml
- job_id_string.go
- server/configure_weles.go
- server/job_creator_handler.go
- server/job_creator_handler_test.go
- server/managers.go
- server/server_suite_test.go
- server/test_sample.yml
- cmd/weles-server/main.go

Please note that documentation served with weles server is now preceded
by the basePath specified in the swagger.yml file. To check documentation
served alongside API you need to go to:
http://{host:port}/api/v1/docs

Change-Id: I6ae33208eea35834127e5c6ff0dda2d1e11f79cf
Signed-off-by: Alexander Mazuruk <a.mazuruk@samsung.com>
6 years agoChange basic weles types to generated by swagger 08/170708/27
Alexander Mazuruk [Wed, 21 Feb 2018 12:24:31 +0000 (13:24 +0100)]
Change basic weles types to generated by swagger

Definitions from artifactmanager.go and jobmanager.go are removed.

Definitions which are used by swagger were added to swagger.yml.

Swagger server was regenerated.

ArtifactStatusChange was moved to separate file for consistency.

In ArtifactType const renamed:
YAMLFILE to YAML
TESTFILE to TEST
FILE suffix was redundant as each ArtifactType is a file.

In ArtifactType and ArtifactStatus consts AM_ prefix was changed to
ArtifactType and ArtifactStatus respectively. JobStatus consts JOB_
prefix was changed to JobStatus. This naming is more go-compliant.

Swagger generated models use strfmt.DateTime rather than time.Time.
strfmt.DateTime is a wrapper for time.Time extending it with swagger
validation.

controller and artifacts packages were adjusted to be compatible with
the above.

Currently artifact_info.go has difference between committed and
generated code. This is caused by the following issue:
https://github.com/go-swagger/go-swagger/issues/1617

Change-Id: If7687ac25113c93c6b130ae6555fd338c700fef8
Signed-off-by: Alexander Mazuruk <a.mazuruk@samsung.com>
6 years agoRemove . imports from artifacts pkg 67/183567/9
Alexander Mazuruk [Wed, 4 Jul 2018 14:47:32 +0000 (16:47 +0200)]
Remove . imports from artifacts pkg

Go's vet tool complains about using dot imports.

Change-Id: Ifd9bedabc49b06196c67bf68a3d27923cfe557d9
Signed-off-by: Alexander Mazuruk <a.mazuruk@samsung.com>
6 years agoAdd initial swagger server 05/170705/20
Alexander Mazuruk [Wed, 21 Feb 2018 10:08:06 +0000 (11:08 +0100)]
Add initial swagger server

Swagger was chosen due to:
- Easy generation of server and client boilerplate code in many languages.
(in Weles project only golang is used but the swagger.yml file can be used
to generate Weles server/client boilerplate in any language)
- Clear, automatically generated documentation
- Promising standard that this tool is based on:
https://github.com/OAI/OpenAPI-Specification

This commit should be treated as the Weles server "scaffolding"

The initial swagger.yml file is added so there is something to generate
the server from. "tbd" will be removed in future commits.

Server was generated using following command:
./dev-tools/swagger generate server \
-A weles \
-f ./swagger.yml \
-m ../weles \
-s ./server \
-r ./COPYING \
--flag-strategy pflag \
--compatibility-mode=modern

Due to agreed name of the server package ("server") there was a conflict in
names in generated code causng build error. Generated code used
server as a name for an object instance which has been renamed to srv.

The Makefile recipe has additional --exclude-main flag which prevents the
swagger generator from overwriting cmd/weles-server/main.go

This flag must be set because:
- obviously as stated above regenerating main will cause build error
- all Weles objects will have to be created there
- additional Weles flags will have to be added there

Thus overwriting this file is a no-no and server regeneration should
only be performed using provided Makefile recipe.

The Makefile has also a recipe to generate html documentation which is
intended to be integrated with Sphinx documentation. This recipe
requires docker:
https://docs.docker.com/get-started/

---
Verification

Update your vendor directory
$ make vendor

To build server:
$ make server

You can check default swagger generated server flags:
$ bin/weles-server --help

When the server is running you can also see how the automatically
served swagger documentation looks like:
http://{host:port}/docs

host and port are flags that should be supplied when running Weles.
If not provided, localhost and random port will be used.

To regenerate swagger server code:
$ make swagger-server-generate

To generate html documentation:
$ make swagger-docs-html

Change-Id: I00cda82219944cc6ab1937f6d14f05d52c7fd4e5
Signed-off-by: Alexander Mazuruk <a.mazuruk@samsung.com>
6 years agoAdd swagger to development tools 06/170706/24
Alexander Mazuruk [Mon, 14 May 2018 16:56:26 +0000 (18:56 +0200)]
Add swagger to development tools

There was a problem with different go-swagger versions which made re-generating server
using different go-swagger versions yield different results than commited.

Version of go-swagger was constrained in Gopkg.toml file to resolve
above issue.

go-swagger and all of its dependencies were added to required rule in
Gopkg.toml to instruct dep to download them.

---
Verification:
$ make tools

In the bin/dev-tools/ directory there should be additional swagger
executable.

To check if the swagger tool has built correctly:

- serve specification UI:
$ bin/dev-tools/swagger serve https://raw.githubusercontent.com/swagger-api/swagger-spec/master/examples/v2.0/json/petstore-expanded.json

- validate specification:
$ bin/dev-tools/swagger validate https://raw.githubusercontent.com/swagger-api/swagger-spec/master/examples/v2.0/json/petstore-expanded.json

Change-Id: I4b96bf7181d9fb14d13fe1e2721ec564f66832bb
Signed-off-by: Alexander Mazuruk <a.mazuruk@samsung.com>
6 years agoLock mockgen version and automate mock generation 67/180467/12
Alexander Mazuruk [Tue, 29 May 2018 10:45:25 +0000 (12:45 +0200)]
Lock mockgen version and automate mock generation

Version of mockgen tool has been constrained in dep's Gopkg.toml file.
It will ensure reproducible results of mocks re-generation.

Makefile 'tools' recipe has been added which will install mockgen, and
in the future- other tools supporting development.

Additionally 'mocks' recipe has been added which will generate mocks for
all Weles interfaces.

Go's generate tool has been tasked with mock generation.

"//go:generate" directives have been placed in separate mocks_generate.go
files in repository mock/ controller/mock/ and manager/ directories.

Mocks from manager have been re-generated using mockgen's reflect mode
as source mode does not work using binary not from GOPATH.
This resulted in changes in the following file:
manager/mock_dryad_job_runner_test.go

They work the same but due to different creation method look a bit
different.

ArtifactManager mock was also updated due to interface change:
mocks/artifactmanager.go

---
Verification:

Create mockgen binary:
$ make tools

Regenerate mocks:
$ make mocks

Check if the files have changed:
$ git status

(They should not change)

Additionally:
$ go test ./...
Should result in all tests passing.

Change-Id: Ie7d8ab89ac9b00960fe5473271287d7832d31e9f
Signed-off-by: Alexander Mazuruk <a.mazuruk@samsung.com>
6 years agoAdd dep for dependency management 61/180061/7
Alexander Mazuruk [Wed, 23 May 2018 20:14:14 +0000 (22:14 +0200)]
Add dep for dependency management

Dep is introduced into the Weles project to lock dependencies and ensure
common and reproducible results among users of this package and its
developers. It will be used to lock both imported packages (when needed)
and to lock version of tools supporting development of Weles.

Gopkg.toml contains hand-written rules that govern dep's behaviour.

Gopkg.lock contains information that will enable anyone to download
dependencies in the same version as were used during development.

It has been decided that vendor directory shall not be committed thus was
added to .gitignore. This was decided due to projects contributors
preference not to keep all dependencies in the repository. It might
cause problems in case of dependency migration, name changes etc but
those are rare and should be maintained manually.

While make tool was designed to automate building projects written in
C-family of languages, we have decided to add Makefile to ease usage of
supporting tools such as dep, gomock, ginkgo, go-swagger.

I'd like to thank for all the input regarding Makefile from:
Lukasz Wojciechowski <l.wojciechow@partner.samsung.com>
Aleksander Mistewicz <a.mistewicz@samsung.com>

---
Verification:

To build Weles you will need to have dep installed:
$ go get -u github.com/golang/dep/cmd/dep

To download dependencies needed to build weles:
$ make vendor

To verify you can try building parser as archive and check if the
gopkg.in/yaml.v2 is used from vendor:
$ go build -buildmode=archive -v -a ./parser

One of the output lines should be:
git.tizen.org/tools/weles/vendor/gopkg.in/yaml.v2

---
More about dep:
https://golang.github.io/dep/docs/introduction.html

If you do not have make installed:
https://www.gnu.org/software/make/

Change-Id: Ie787513b26c57117de06b1f6e0da25769d7a4bfe
Signed-off-by: Alexander Mazuruk <a.mazuruk@samsung.com>
6 years agoMerge branch 'artifacts' 35/183235/1 srun
Pawel Wieczorek [Tue, 3 Jul 2018 13:47:50 +0000 (15:47 +0200)]
Merge branch 'artifacts'

Change-Id: I7d422c12880842ce45ef7cb83c20eaf3b6b13192

6 years agoAdd downloader to Storage, implement PushArtifact 59/163859/7 artifacts
Katarzyna Gorska [Wed, 13 Dec 2017 14:10:46 +0000 (15:10 +0100)]
Add downloader to Storage, implement PushArtifact

Change-Id: If757c4745089eb308fca53c732790d3615c5dcb9
Signed-off-by: Katarzyna Gorska <k.gorska@samsung.com>
6 years agoMerge branch 'runner' 13/183013/1 ui
Pawel Wieczorek [Fri, 29 Jun 2018 14:16:56 +0000 (16:16 +0200)]
Merge branch 'runner'

Change-Id: Ic7344743f615ac74fbbf8c0e8c6c8fe46dd069fc

6 years agoAdd Boot to DeviceCommunicationProvider interface 25/182925/2
Aleksander Mistewicz [Fri, 22 Jun 2018 13:31:06 +0000 (15:31 +0200)]
Add Boot to DeviceCommunicationProvider interface

Boot starts DUT and prepares communication so that Login could work.
It can be called more than once to reset DUT's state.

Change-Id: I2c28028b557fa3ea862f5f176090b81767a240d2
Signed-off-by: Aleksander Mistewicz <a.mistewicz@samsung.com>
6 years agoImplement Test with test 01/177401/2
Aleksander Mistewicz [Wed, 29 Nov 2017 17:53:58 +0000 (18:53 +0100)]
Implement Test with test

Change-Id: Ic44cd543be463ef3434a23de679547c5e52e6fe9
Signed-off-by: Aleksander Mistewicz <a.mistewicz@samsung.com>
6 years agoImplement Boot with test 00/177400/2
Aleksander Mistewicz [Wed, 29 Nov 2017 17:29:02 +0000 (18:29 +0100)]
Implement Boot with test

Change-Id: I059792863037d06331fd624ba71543aedd7101ad
Signed-off-by: Aleksander Mistewicz <a.mistewicz@samsung.com>
6 years agoImplement Deploy with test 99/177399/2
Aleksander Mistewicz [Wed, 29 Nov 2017 17:22:56 +0000 (18:22 +0100)]
Implement Deploy with test

Change-Id: Ibc55e994878f639af1f0190c1debd332e35fd1c9
Signed-off-by: Aleksander Mistewicz <a.mistewicz@samsung.com>
6 years agoAdd cmd provider to FOTA CLI 98/177398/2
Aleksander Mistewicz [Wed, 22 Nov 2017 10:31:14 +0000 (11:31 +0100)]
Add cmd provider to FOTA CLI

FOTA is a tool available on MuxPi providing ability to flash sdcard with
archives containing images published via http server.

This patch adds an easy way to construct command line call to the said
tool.

Change-Id: I8da6e5c49a4419e3f3343129456472363e55eb6d
Signed-off-by: Aleksander Mistewicz <a.mistewicz@samsung.com>