BigW Consortium Gitlab
Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
gitlab-ce
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Forest Godfrey
gitlab-ce
Commits
58017e17
Commit
58017e17
authored
Dec 13, 2017
by
Douwe Maan
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'bvl-backport-migration-spec-changes-to-ce' into 'master'
Create models directly in migration specs See merge request gitlab-org/gitlab-ce!15874
parents
b305a133
5ac98f93
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
31 additions
and
29 deletions
+31
-29
create_fork_network_memberships_range_spec.rb
...d_migration/create_fork_network_memberships_range_spec.rb
+14
-13
migrate_events_to_push_event_payloads_spec.rb
...d_migration/migrate_events_to_push_event_payloads_spec.rb
+2
-1
populate_fork_networks_range_spec.rb
...background_migration/populate_fork_networks_range_spec.rb
+10
-9
migrate_gcp_clusters_to_new_clusters_architectures_spec.rb
...igrate_gcp_clusters_to_new_clusters_architectures_spec.rb
+5
-6
No files found.
spec/lib/gitlab/background_migration/create_fork_network_memberships_range_spec.rb
View file @
58017e17
...
...
@@ -2,19 +2,20 @@ require 'spec_helper'
describe
Gitlab
::
BackgroundMigration
::
CreateForkNetworkMembershipsRange
,
:migration
,
schema:
20170929131201
do
let
(
:migration
)
{
described_class
.
new
}
let
(
:projects
)
{
table
(
:projects
)
}
let
(
:base1
)
{
create
(
:project
)
}
let
(
:base1_fork1
)
{
create
(
:project
)
}
let
(
:base1_fork2
)
{
create
(
:project
)
}
let
(
:base1
)
{
projects
.
create
}
let
(
:base1_fork1
)
{
projects
.
create
}
let
(
:base1_fork2
)
{
projects
.
create
}
let
(
:base2
)
{
create
(
:project
)
}
let
(
:base2_fork1
)
{
create
(
:project
)
}
let
(
:base2_fork2
)
{
create
(
:project
)
}
let
(
:base2
)
{
projects
.
create
}
let
(
:base2_fork1
)
{
projects
.
create
}
let
(
:base2_fork2
)
{
projects
.
create
}
let
(
:fork_of_fork
)
{
create
(
:project
)
}
let
(
:fork_of_fork2
)
{
create
(
:project
)
}
let
(
:second_level_fork
)
{
create
(
:project
)
}
let
(
:third_level_fork
)
{
create
(
:project
)
}
let
(
:fork_of_fork
)
{
projects
.
create
}
let
(
:fork_of_fork2
)
{
projects
.
create
}
let
(
:second_level_fork
)
{
projects
.
create
}
let
(
:third_level_fork
)
{
projects
.
create
}
let
(
:fork_network1
)
{
fork_networks
.
find_by
(
root_project_id:
base1
.
id
)
}
let
(
:fork_network2
)
{
fork_networks
.
find_by
(
root_project_id:
base2
.
id
)
}
...
...
@@ -97,7 +98,7 @@ describe Gitlab::BackgroundMigration::CreateForkNetworkMembershipsRange, :migrat
end
it
'does not miss members for forks of forks for which the root was deleted'
do
forked_project_links
.
create
(
id:
9
,
forked_from_project_id:
base1_fork1
.
id
,
forked_to_project_id:
create
(
:project
)
.
id
)
forked_project_links
.
create
(
id:
9
,
forked_from_project_id:
base1_fork1
.
id
,
forked_to_project_id:
projects
.
create
.
id
)
base1
.
destroy
expect
(
migration
.
missing_members?
(
7
,
10
)).
to
be_falsy
...
...
@@ -105,8 +106,8 @@ describe Gitlab::BackgroundMigration::CreateForkNetworkMembershipsRange, :migrat
context
'with more forks'
do
before
do
forked_project_links
.
create
(
id:
9
,
forked_from_project_id:
fork_of_fork
.
id
,
forked_to_project_id:
create
(
:project
)
.
id
)
forked_project_links
.
create
(
id:
10
,
forked_from_project_id:
fork_of_fork
.
id
,
forked_to_project_id:
create
(
:project
)
.
id
)
forked_project_links
.
create
(
id:
9
,
forked_from_project_id:
fork_of_fork
.
id
,
forked_to_project_id:
projects
.
create
.
id
)
forked_project_links
.
create
(
id:
10
,
forked_from_project_id:
fork_of_fork
.
id
,
forked_to_project_id:
projects
.
create
.
id
)
end
it
'only processes a single batch of links at a time'
do
...
...
spec/lib/gitlab/background_migration/migrate_events_to_push_event_payloads_spec.rb
View file @
58017e17
...
...
@@ -225,7 +225,8 @@ describe Gitlab::BackgroundMigration::MigrateEventsToPushEventPayloads, :migrati
let
(
:user_class
)
{
table
(
:users
)
}
let
(
:author
)
{
build
(
:user
).
becomes
(
user_class
).
tap
(
&
:save!
).
becomes
(
User
)
}
let
(
:namespace
)
{
create
(
:namespace
,
owner:
author
)
}
let
(
:project
)
{
create
(
:project_empty_repo
,
namespace:
namespace
,
creator:
author
)
}
let
(
:projects
)
{
table
(
:projects
)
}
let
(
:project
)
{
projects
.
create
(
namespace_id:
namespace
.
id
,
creator_id:
author
.
id
)
}
# We can not rely on FactoryGirl as the state of Event may change in ways that
# the background migration does not expect, hence we use the Event class of
...
...
spec/lib/gitlab/background_migration/populate_fork_networks_range_spec.rb
View file @
58017e17
...
...
@@ -2,10 +2,11 @@ require 'spec_helper'
describe
Gitlab
::
BackgroundMigration
::
PopulateForkNetworksRange
,
:migration
,
schema:
20170929131201
do
let
(
:migration
)
{
described_class
.
new
}
let
(
:base1
)
{
create
(
:project
)
}
let
(
:projects
)
{
table
(
:projects
)
}
let
(
:base1
)
{
projects
.
create
}
let
(
:base2
)
{
create
(
:project
)
}
let
(
:base2_fork1
)
{
create
(
:project
)
}
let
(
:base2
)
{
projects
.
create
}
let
(
:base2_fork1
)
{
projects
.
create
}
let!
(
:forked_project_links
)
{
table
(
:forked_project_links
)
}
let!
(
:fork_networks
)
{
table
(
:fork_networks
)
}
...
...
@@ -18,10 +19,10 @@ describe Gitlab::BackgroundMigration::PopulateForkNetworksRange, :migration, sch
# A normal fork link
forked_project_links
.
create
(
id:
1
,
forked_from_project_id:
base1
.
id
,
forked_to_project_id:
create
(
:project
)
.
id
)
forked_to_project_id:
projects
.
create
.
id
)
forked_project_links
.
create
(
id:
2
,
forked_from_project_id:
base1
.
id
,
forked_to_project_id:
create
(
:project
)
.
id
)
forked_to_project_id:
projects
.
create
.
id
)
forked_project_links
.
create
(
id:
3
,
forked_from_project_id:
base2
.
id
,
forked_to_project_id:
base2_fork1
.
id
)
...
...
@@ -29,10 +30,10 @@ describe Gitlab::BackgroundMigration::PopulateForkNetworksRange, :migration, sch
# create a fork of a fork
forked_project_links
.
create
(
id:
4
,
forked_from_project_id:
base2_fork1
.
id
,
forked_to_project_id:
create
(
:project
)
.
id
)
forked_to_project_id:
projects
.
create
.
id
)
forked_project_links
.
create
(
id:
5
,
forked_from_project_id:
create
(
:project
)
.
id
,
forked_to_project_id:
create
(
:project
)
.
id
)
forked_from_project_id:
projects
.
create
.
id
,
forked_to_project_id:
projects
.
create
.
id
)
# Stub out the calls to the other migrations
allow
(
BackgroundMigrationWorker
).
to
receive
(
:perform_in
)
...
...
@@ -63,7 +64,7 @@ describe Gitlab::BackgroundMigration::PopulateForkNetworksRange, :migration, sch
end
it
'creates a fork network for the fork of which the source was deleted'
do
fork
=
create
(
:project
)
fork
=
projects
.
create
forked_project_links
.
create
(
id:
6
,
forked_from_project_id:
99999
,
forked_to_project_id:
fork
.
id
)
migration
.
perform
(
5
,
8
)
...
...
spec/migrations/migrate_gcp_clusters_to_new_clusters_architectures_spec.rb
View file @
58017e17
...
...
@@ -2,9 +2,10 @@ require 'spec_helper'
require
Rails
.
root
.
join
(
'db'
,
'post_migrate'
,
'20171013104327_migrate_gcp_clusters_to_new_clusters_architectures.rb'
)
describe
MigrateGcpClustersToNewClustersArchitectures
,
:migration
do
let
(
:project
)
{
create
(
:project
)
}
let
(
:projects
)
{
table
(
:projects
)
}
let
(
:project
)
{
projects
.
create
}
let
(
:user
)
{
create
(
:user
)
}
let
(
:service
)
{
create
(
:kubernetes_service
,
project
:
project
)
}
let
(
:service
)
{
create
(
:kubernetes_service
,
project
_id:
project
.
id
)
}
context
'when cluster is being created'
do
let
(
:project_id
)
{
project
.
id
}
...
...
@@ -56,8 +57,7 @@ describe MigrateGcpClustersToNewClustersArchitectures, :migration do
expect
(
cluster
.
provider_type
).
to
eq
(
'gcp'
)
expect
(
cluster
.
platform_type
).
to
eq
(
'kubernetes'
)
expect
(
cluster
.
project
).
to
eq
(
project
)
expect
(
project
.
clusters
).
to
include
(
cluster
)
expect
(
cluster
.
project_ids
).
to
include
(
project
.
id
)
expect
(
cluster
.
provider_gcp
.
cluster
).
to
eq
(
cluster
)
expect
(
cluster
.
provider_gcp
.
status
).
to
eq
(
status
)
...
...
@@ -133,8 +133,7 @@ describe MigrateGcpClustersToNewClustersArchitectures, :migration do
expect
(
cluster
.
provider_type
).
to
eq
(
'gcp'
)
expect
(
cluster
.
platform_type
).
to
eq
(
'kubernetes'
)
expect
(
cluster
.
project
).
to
eq
(
project
)
expect
(
project
.
clusters
).
to
include
(
cluster
)
expect
(
cluster
.
project_ids
).
to
include
(
project
.
id
)
expect
(
cluster
.
provider_gcp
.
cluster
).
to
eq
(
cluster
)
expect
(
cluster
.
provider_gcp
.
status
).
to
eq
(
status
)
...
...
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