Skip to content

Commit

Permalink
Merge branch 'release/2.10.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
vmalloc committed Aug 20, 2017
2 parents 0c7a6d9 + 106e5d0 commit 6d9a0c7
Show file tree
Hide file tree
Showing 18 changed files with 151 additions and 56 deletions.
20 changes: 13 additions & 7 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,17 @@ python:
- 3.6
addons:
postgresql: "9.5"
sauce_connect: true

env:
DOCKER_COMPOSE_VERSION: 1.11.2
DOCKER_HOST: tcp://127.0.0.1:2375
global:
- DOCKER_COMPOSE_VERSION=1.11.2
- DOCKER_HOST=tcp://127.0.0.1:2375
- SAUCE_USERNAME=vmalloc
- SAUCELABS_USERNAME=vmalloc
- secure: UK8uZD6VvqxxosDCsog6cl0hFng1KVerbEPAfulFpMBybPRM6M0ifspl+hK0AfHQvHtA8PMCs+KsZBb3CV2E5RwoIgXWEBC2t8+XsfU3p2fnhbuz/5S2xs/CvGLhMloeIpc8fIQ7qdRk0pdOqkUK5yMkkV7jfJsqw2HyTS5FOAk=
- secure: UoIM5vtfs+bBcb63aNa4aFV4lCrwgaABKrdYlqkw+vwE6S212a5ssfIn/41Tw80jZ/qBhSMhylIi2Cp6XWQbuSLjNUK1Ar7O0K8HX69QdcUCnofxwHLKSe7wREYhF6QtAegsw5pmSIYTLvHnp3k+6I0tw2DyvSJejS0dv3WWKzw=


services:
- redis-server
Expand Down Expand Up @@ -36,19 +43,18 @@ before_install:
install:
# db and env setup
- psql -c 'create database backslash;' -U postgres
- pip install virtualenv
- pip install -U setuptools pip virtualenv
- python manage.py bootstrap --develop
- python manage.py db upgrade

# install latest backlash-python
- .env/bin/pip install -e git://github.com/getslash/backslash-python.git@develop#egg=backslash-python
# (optional) install latest backlash-python
#- .env/bin/pip install -e git://github.com/getslash/backslash-python.git@develop#egg=backslash-python

# run docker-compose setup in testing mode
- sudo docker-compose -f docker/docker-compose.yml build
- sudo docker-compose -f docker/docker-compose.yml -f docker/docker-compose-testing-override.yml up -d

script:
# frontend test
- cd webapp
- yarn install
- bower install
Expand All @@ -57,7 +63,7 @@ script:
- ./node_modules/.bin/ember build
- cd ..
- .env/bin/py.test tests
- .env/bin/py.test integration_tests --app-url http://127.0.0.1:8000
- .env/bin/py.test integration_tests --app-url http://127.0.0.1:8000 --driver SauceLabs --capability browserName Chrome --capability platform Linux --capability version 48.0 --capability tunnelIdentifier $TRAVIS_JOB_NUMBER

after_success:
- .env/bin/python scripts/travis_docker_publish.py
6 changes: 6 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Changelog

## Version 2.10.0

* Added pagination navigation to session and test error views
* Improved navigation when examining parallel sessions
* Pressing 'u' when inside a test will take you back to the session test list
* Misc. bug fixes

## Version 2.9.0

Expand Down
3 changes: 3 additions & 0 deletions deps/app.txt
Original file line number Diff line number Diff line change
Expand Up @@ -32,3 +32,6 @@ pyldap

#for search
dateparser

#for interactive investigations inside Docker
pgcli
5 changes: 3 additions & 2 deletions docker/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@ services:
image: getslash/backslash
command: [
"dockerize",
"-timeout", "60s",
"-timeout", "3600s",
"-wait", "tcp://db:5432",
"-wait", "tcp://rabbitmq:5672",
".env/bin/python", "manage.py", "docker-start"
]
volumes:
Expand All @@ -25,7 +26,7 @@ services:

worker:
image: getslash/backslash
command: .env/bin/celery -A flask_app.tasks worker -B --loglevel=info
command: dockerize -timeout 3600s -wait tcp://rabbitmq:5672 .env/bin/celery -A flask_app.tasks worker -B --loglevel=info
logging:
driver: syslog
environment:
Expand Down
7 changes: 5 additions & 2 deletions flask_app/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,10 @@ def mark_ended_at(self, timestamp):
self.extend_timespan_to(timestamp)


subject_seq = db.Sequence('subject_seq')

session_subject = db.Table('session_subject',
db.Column('ordinal', db.Integer, subject_seq, server_default=subject_seq.next_value()),
db.Column('session_id',
db.Integer,
db.ForeignKey('session.id', ondelete='CASCADE')),
Expand Down Expand Up @@ -134,7 +137,7 @@ class Session(db.Model, TypenameMixin, StatusPredicatesMixin, HasSubjectsMixin,
'SessionMetadata', lazy='dynamic', cascade='all, delete, delete-orphan')

subject_instances = db.relationship(
'SubjectInstance', secondary=session_subject, backref=backref('sessions', lazy='dynamic'), lazy='joined')
'SubjectInstance', secondary=session_subject, backref=backref('sessions', lazy='dynamic'), lazy='joined', order_by=session_subject.c.ordinal)

labels = db.relationship('Label', secondary='session_label', lazy='joined')

Expand Down Expand Up @@ -344,7 +347,7 @@ class Test(db.Model, TypenameMixin, StatusPredicatesMixin, HasSubjectsMixin, Use
test_variation = db.relationship('TestVariation', lazy='joined')

subject_instances = db.relationship(
'SubjectInstance', secondary=session_subject, primaryjoin='Test.session_id==session_subject.c.session_id', lazy='joined')
'SubjectInstance', secondary=session_subject, primaryjoin='Test.session_id==session_subject.c.session_id', lazy='joined', order_by=session_subject.c.ordinal)

user = db.relationship('User', secondary=Session.__table__, primaryjoin='Test.session_id==Session.id', secondaryjoin='Session.user_id==User.id', lazy='joined', uselist=False)

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
"""Add subject ordinal numbers to preserve order
Revision ID: ea0a1b8dd57f
Revises: 9c00de5646cd
Create Date: 2017-08-16 13:20:41.635660
"""

# revision identifiers, used by Alembic.
revision = 'ea0a1b8dd57f'
down_revision = '9c00de5646cd'

from alembic import op
import sqlalchemy as sa


def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.execute('CREATE SEQUENCE subject_seq')
op.add_column('session_subject', sa.Column('ordinal', sa.Integer(), server_default=sa.text("nextval('subject_seq')"), nullable=True))
# ### end Alembic commands ###


def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.execute('DROP SEQUENCE subject_seq')
op.drop_column('session_subject', 'ordinal')
# ### end Alembic commands ###
8 changes: 4 additions & 4 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,13 @@
@pytest.fixture
def subjects():
returned = [
Munch(name='prod1', product='Car',
version=None, revision='120'),
Munch(name='prod2', product='Car',
version=None, revision='120'),
Munch(name='prod1', product='Car',
version='10', revision='1200'),
Munch(name='prod3', product='Motorcycle',
Munch(name='prod4', product='Motorcycle',
version='10', revision='1200'),
Munch(name='prod4', product='Car',
Munch(name='prod3', product='Car',
version=None, revision='120'),
]
salt = '_{}'.format(uuid4())
Expand Down
6 changes: 2 additions & 4 deletions tests/test_subjects.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import flux
import functools
import pytest
import requests

Expand All @@ -11,8 +10,7 @@ def test_start_session_with_subjects(client, subjects):
session = client.report_session_start(
subjects=subjects
)
_sorted = functools.partial(sorted, key=lambda d: d['name'])
assert _sorted(session.refresh().subjects) == _sorted(dict(s) for s in subjects)
assert session.refresh().subjects == [dict(s) for s in subjects]


def test_add_subject(started_session, subjects, flask_app):
Expand All @@ -33,7 +31,7 @@ def test_product_rendered_field(started_session, subjects):


def test_subject_activity(client, subjects, flask_app):
current_time = flux.current_timeline.time()
current_time = flux.current_timeline.time() # pylint: disable=no-member
client.report_session_start(subjects=subjects)
with flask_app.app_context():
for subject in subjects:
Expand Down
28 changes: 19 additions & 9 deletions webapp/app/components/error-detail/template.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,27 @@
{{/expandable-div}}
{{/if}}

{{#if (and error.traceback_url (not error.traceback)) }}
<div class="box error">
{{#if loading }}
<div class="box">
<div class="info">
Could not load traceback
<i class="fa fa-spin fa-refresh"></i> Loading Traceback...
</div>
</div>

{{else}}
<p>
Traceback (<a class="clickable" {{action "toggle_all_frames"}}>{{if all_expanded 'collapse' 'expand'}} all</a>):
</p>
{{#each error.traceback as |frame|}}
{{errors/traceback-frame frame=frame override_expand=override_expand}}
{{/each}}

{{#if (and error.traceback_url (not error.traceback)) }}
<div class="box error">
<div class="info">
Could not load traceback
</div>
</div>
{{else}}
<p>
Traceback (<a class="clickable" {{action "toggle_all_frames"}}>{{if all_expanded 'collapse' 'expand'}} all</a>):
</p>
{{#each error.traceback as |frame|}}
{{errors/traceback-frame frame=frame override_expand=override_expand}}
{{/each}}
{{/if}}
{{/if}}
16 changes: 16 additions & 0 deletions webapp/app/components/keyboard-shortcuts/component.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ let _keys = [
},
{ key: "j", action: "jump_one_down", description: "Jump to next item" },
{ key: "k", action: "jump_one_up", description: "Jump to previous item" },

{ key: "u", action: "goto_session_tests", description: "Go back to session's test list" },

{ key: "esc", action: "close_boxes_or_home" },
{
key: "ctrl+s",
Expand Down Expand Up @@ -179,6 +182,19 @@ export default Ember.Component.extend(KeyboardShortcuts, {
this.router.transitionTo("users");
},

goto_session_tests() {
let appcontroller = getOwner(this).lookup("controller:application");
let current_path = appcontroller.currentPath;

if (!current_path.startsWith("session.test.")) {
return;
}

let session_controller = getOwner(this).lookup("controller:session");
let session = session_controller.get("session_model");
this.router.transitionTo("session.index", session.get('display_id'));
},

toggle_human_times() {
this.get("display").toggleProperty("humanize_times");
},
Expand Down
12 changes: 12 additions & 0 deletions webapp/app/mixins/paginated-controller.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import Ember from 'ember';

export default Ember.Mixin.create({
page: 1,
page_size: 25,

queryParams: [
"page",
"page_size",
],

});
13 changes: 13 additions & 0 deletions webapp/app/mixins/paginated-route.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import Ember from 'ember';

export default Ember.Mixin.create({
queryParams: {
page: {
refreshModel: true
},
page_size: {
refreshModel: true
},
},

});
11 changes: 6 additions & 5 deletions webapp/app/session/errors/route.js
Original file line number Diff line number Diff line change
@@ -1,21 +1,22 @@
import Ember from "ember";
import AuthenticatedRouteMixin
from "ember-simple-auth/mixins/authenticated-route-mixin";
import InfinityRoute from "../../mixins/infinity-route";
import PaginatedRoute from "../../mixins/paginated-route";
import ComplexModelRoute from "../../mixins/complex-model-route";

export default Ember.Route.extend(
AuthenticatedRouteMixin,
InfinityRoute,
ComplexModelRoute,
PaginatedRoute,
{
model: function() {
model: function({page, page_size}) {
const parent = this.modelFor("session").session_model;
return Ember.RSVP.hash({
session: this.modelFor("session").session_model,
errors: this.infinityModel("error", {
errors: this.store.query("error", {
session_id: parent.id,
modelPath: "controller.errors"
page: page,
page_size: page_size,
})
});
}
Expand Down
3 changes: 1 addition & 2 deletions webapp/app/session/errors/template.hbs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
{{pagination-nav page=(mut page) has_next=errors.meta.has_more num_pages=errors.meta.num_pages}}
{{#each errors as |error index|}}
{{error-box error=error}}
{{/each}}

{{infinity-loader infinityModel=errors loadingText="Loading..." loadedText=""}}
11 changes: 6 additions & 5 deletions webapp/app/session/test/errors/route.js
Original file line number Diff line number Diff line change
@@ -1,22 +1,23 @@
import Ember from "ember";
import AuthenticatedRouteMixin
from "ember-simple-auth/mixins/authenticated-route-mixin";
import InfinityRoute from "../../../mixins/infinity-route";
import PaginatedRoute from "../../../mixins/paginated-route";
import ComplexModelRoute from "../../../mixins/complex-model-route";

export default Ember.Route.extend(
AuthenticatedRouteMixin,
InfinityRoute,
PaginatedRoute,
ComplexModelRoute,
{
model: function() {
model: function({page, page_size}) {
const parent = this.modelFor("session.test");
return Ember.RSVP.hash({
test_model: parent.test_model,
session_model: parent.session_model,
errors: this.infinityModel("error", {
errors: this.store.query("error", {
test_id: parent.test_model.id,
modelPath: "controller.errors"
page: page,
page_size: page_size,
})
});
}
Expand Down
3 changes: 1 addition & 2 deletions webapp/app/session/test/errors/template.hbs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
{{pagination-nav page=(mut page) has_next=errors.meta.has_more num_pages=errors.meta.num_pages}}
{{#each errors as |error index|}}
{{error-box error=error}}
{{/each}}

{{infinity-loader infinityModel=errors loadingText="Loading..." loadedText=""}}
12 changes: 12 additions & 0 deletions webapp/app/sessions/template.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,18 @@
<td>Find sessions which contain a test named <code>test_something</code></td>
</tr>

{{# if (can "admin")}}
<tr>
<td><code>python_version &gt; 3.5</code></td>
<td>Search by Python version</td>
</tr>
<tr>
<td><code>commandline ~ slash</code></td>
<td>Search by command-line substrings</td>
</tr>

{{/if}}

</tbody>
</table>

Expand Down
Loading

0 comments on commit 6d9a0c7

Please sign in to comment.