Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Léo-Paul Géneau
gitlab-ce
Commits
623940bf
Commit
623940bf
authored
Oct 28, 2018
by
Chris Baumbauer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add knative model tests
parent
50a708f5
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
107 additions
and
8 deletions
+107
-8
app/models/clusters/applications/knative.rb
app/models/clusters/applications/knative.rb
+5
-8
spec/models/clusters/applications/knative_spec.rb
spec/models/clusters/applications/knative_spec.rb
+102
-0
No files found.
app/models/clusters/applications/knative.rb
View file @
623940bf
...
...
@@ -3,26 +3,23 @@
module
Clusters
module
Applications
class
Knative
<
ActiveRecord
::
Base
VERSION
=
'0.1.
2
'
.
freeze
VERSION
=
'0.1.
3
'
.
freeze
REPOSITORY
=
'https://storage.googleapis.com/triggermesh-charts'
.
freeze
# This is required for helm version <= 2.10.x in order to support
# Setting up CRDs
ISTIO_CRDS
=
'http://cabnetworks.net/triggermesh-charts/istio-crds.yaml'
.
freeze
self
.
table_name
=
'clusters_applications_knative'
include
::
Clusters
::
Concerns
::
ApplicationCore
include
::
Clusters
::
Concerns
::
ApplicationStatus
include
::
Clusters
::
Concerns
::
ApplicationVersion
include
::
Clusters
::
Concerns
::
ApplicationData
include
AfterCommitQueue
default_value_for
:version
,
VERSION
default_value_for
:domainname
,
''
def
set_initial_status
return
unless
not_installable?
self
.
status
=
'installable'
if
cluster
&
.
platform_kubernetes_active?
end
def
chart
'knative/knative'
end
...
...
spec/models/clusters/applications/knative_spec.rb
0 → 100644
View file @
623940bf
require
'rails_helper'
describe
Clusters
::
Applications
::
Knative
do
let
(
:knative
)
{
create
(
:clusters_applications_knative
)
}
include_examples
'cluster application core specs'
,
:clusters_applications_knative
include_examples
'cluster application status specs'
,
:clusters_applications_knative
describe
'.installed'
do
subject
{
described_class
.
installed
}
let!
(
:cluster
)
{
create
(
:clusters_applications_knative
,
:installed
)
}
before
do
create
(
:clusters_applications_knative
,
:errored
)
end
it
{
is_expected
.
to
contain_exactly
(
cluster
)
}
end
describe
'#make_installing!'
do
before
do
application
.
make_installing!
end
context
'application install previously errored with older version'
do
let
(
:application
)
{
create
(
:clusters_applications_knative
,
:scheduled
,
version:
'0.1.3'
)
}
it
'updates the application version'
do
expect
(
application
.
reload
.
version
).
to
eq
(
'0.1.3'
)
end
end
end
describe
'#make_installed'
do
subject
{
described_class
.
installed
}
let!
(
:cluster
)
{
create
(
:clusters_applications_knative
,
:installed
)
}
before
do
create
(
:clusters_applications_knative
,
:errored
)
end
it
{
is_expected
.
to
contain_exactly
(
cluster
)
}
end
describe
'#install_command'
do
subject
{
knative
.
install_command
}
it
{
is_expected
.
to
be_an_instance_of
(
Gitlab
::
Kubernetes
::
Helm
::
InstallCommand
)
}
it
'should be initialized with knative arguments'
do
expect
(
subject
.
name
).
to
eq
(
'knative'
)
expect
(
subject
.
chart
).
to
eq
(
'knative/knative'
)
expect
(
subject
.
version
).
to
eq
(
'0.1.3'
)
expect
(
subject
.
files
).
to
eq
(
knative
.
files
)
expect
(
subject
.
setargs
).
to
eq
([])
end
context
'application failed to install previously'
do
let
(
:knative
)
{
create
(
:clusters_applications_knative
,
:errored
,
version:
'knative'
)
}
it
'should be initialized with the locked version'
do
expect
(
subject
.
version
).
to
eq
(
'0.1.3'
)
end
end
end
describe
'#files'
do
let
(
:application
)
{
knative
}
let
(
:values
)
{
subject
[
:'values.yaml'
]
}
subject
{
application
.
files
}
it
'should include knative valid keys in values'
do
expect
(
values
).
to
include
(
'domain'
)
end
context
'when the helm application does not have a ca_cert'
do
before
do
application
.
cluster
.
application_helm
.
ca_cert
=
nil
end
it
'should not include cert files'
do
expect
(
subject
[
:'ca.pem'
]).
not_to
be_present
expect
(
subject
[
:'cert.pem'
]).
not_to
be_present
expect
(
subject
[
:'key.pem'
]).
not_to
be_present
end
end
it
'should include cert files'
do
expect
(
subject
[
:'ca.pem'
]).
to
be_present
expect
(
subject
[
:'ca.pem'
]).
to
eq
(
application
.
cluster
.
application_helm
.
ca_cert
)
expect
(
subject
[
:'cert.pem'
]).
to
be_present
expect
(
subject
[
:'key.pem'
]).
to
be_present
cert
=
OpenSSL
::
X509
::
Certificate
.
new
(
subject
[
:'cert.pem'
])
expect
(
cert
.
not_after
).
to
be
<
60
.
minutes
.
from_now
end
end
end
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment