-
Notifications
You must be signed in to change notification settings - Fork 125
Expand file tree
/
Copy pathusers_brick_load_spec.rb
More file actions
202 lines (184 loc) · 7.44 KB
/
users_brick_load_spec.rb
File metadata and controls
202 lines (184 loc) · 7.44 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
require 'active_support/core_ext/numeric/time'
require_relative '../integration/support/project_helper'
require_relative '../integration/support/connection_helper'
require_relative '../integration/support/configuration_helper'
require_relative '../integration/support/s3_helper'
require_relative '../userprov/shared_contexts_for_user_bricks'
require_relative '../integration/spec/brick_runner'
require_relative '../helpers/schedule_helper'
require_relative 'shared_contexts_for_load_tests'
def user_in_domain(user_name)
domain = @rest_client.domain(LcmConnectionHelper.environment[:prod_organization])
domain.find_user_by_login(user_name)
end
# set up by execmgr-k8s
image_tag = ENV['LCM_BRICKS_IMAGE_TAG']
GoodData::Environment.const_set('VCR_ON', false)
user_array = []
user_count = ENV['GD_LCM_SPEC_USER_COUNT'] ? ENV['GD_LCM_SPEC_USER_COUNT'].to_i : 20
project_array = []
project_count = ENV['GD_LCM_SPEC_PROJECT_COUNT'] ? ENV['GD_LCM_SPEC_PROJECT_COUNT'].to_i : 20
service_project = nil
users_schedule = nil
user_filters_schedule = nil
describe 'UsersBrick' do
include_context 'load tests cleanup' unless ENV['GD_LCM_SMOKE_TEST'] == 'true'
before(:all) do
@suffix = ConfigurationHelper.suffix
@rest_client = LcmConnectionHelper.production_server_connection
@domain = @rest_client.domain(LcmConnectionHelper.environment[:prod_organization])
@opts = {
client: @rest_client,
title: "users brick load test #{@suffix}",
auth_token: LcmConnectionHelper.environment[:prod_token],
environment: 'TESTING'
}
project_helper = Support::ProjectHelper.create(@opts)
project_helper.create_ldm
project_helper.load_data
@project = project_helper.project
@user_name = "#{@suffix}@bar.baz"
project_helper.ensure_user(@user_name, @domain)
@user_data = {
login: @user_name,
first_name: 'first',
last_name: 'last',
company: 'GoodData',
position: 'developer',
country: 'CZech',
phone: '123',
language: 'fr-FR',
user_groups: 'test_group',
client_id: 'testingclient'
}
users_csv = ConfigurationHelper.csv_from_hashes([@user_data])
s3_key = 'user_data'
s3_info = Support::S3Helper.upload_file(users_csv, s3_key)
@test_context = {
project_id: @project.pid,
config: LcmConnectionHelper.environment,
s3_bucket: GoodData::Environment::ConnectionHelper::SECRETS[:s3_bucket_name],
s3_key: s3_key
}.merge(s3_info)
@template_path = File.expand_path('../userprov/params/users_brick.json.erb', __dir__)
end
after(:each) do
$SCRIPT_PARAMS = nil
end
context 'when using mode sync_multiple_projects_based_on_custom_id' do
before(:all) do
@test_context[:sync_mode] = 'sync_multiple_projects_based_on_custom_id'
(1..user_count).each do |i|
user_name = "#{@suffix}2_#{i}@bar.baz"
@user_data[:login] = user_name
user_array << @user_data.clone
end
(1..project_count).each do |j|
(1..user_count).each do |i|
user_name = "#{@suffix}2_#{i}_#{j}@bar.baz"
@user_data[:login] = user_name
@user_data[:client_id] = "testing_client_#{j}"
user_array << @user_data.clone
end
end
@domain.create_users(user_array)
users_csv = ConfigurationHelper.csv_from_hashes(user_array)
Support::S3Helper.upload_file(users_csv, @test_context[:s3_key])
@data_product_id = "testing-data-product-#{@suffix}"
@data_product = @domain.create_data_product(id: @data_product_id)
@master_project = @rest_client.create_project(title: "Test MASTER project for #{@suffix}", auth_token: LcmConnectionHelper.environment[:prod_token])
@segment = @data_product.create_segment(segment_id: "testing-segment-#{@suffix}", master_project: @master_project)
@segment.create_client(id: 'testingclient', project: @project.uri)
(1..project_count).each do |i|
project_helper = Support::ProjectHelper.create(
client: @rest_client,
title: "Test MINOR project with testing_client_#{i} for #{@suffix}",
auth_token: LcmConnectionHelper.environment[:prod_token],
environment: 'TESTING'
)
project_helper.create_ldm
project_helper.load_data
project = project_helper.project
@segment.create_client(id: "testing_client_#{i}", project: project.uri)
project_array << project
end
@test_context[:data_product] = @data_product_id
@config_path = ConfigurationHelper.create_interpolated_tempfile(
@template_path,
@test_context
)
end
it 'adds users to project' do
# service_project = @rest_client.create_project(
# title: 'users load test service project',
# auth_token: @test_context[:config][:prod_token]
# )
# opts = {
# context: @test_context,
# template_path: '../../../userprov/params/users_brick.json.erb',
# image_tag: image_tag
# }
# users_schedule = BrickRunner.schedule_brick('users_brick', service_project, opts)
end
it 'sets the right MUFs to right users' do
# @test_context = {
# project_id: @project.pid,
# config: LcmConnectionHelper.environment,
# s3_bucket: GoodData::Environment::ConnectionHelper::SECRETS[:s3_bucket_name],
# s3_endpoint: Support::S3Helper::S3_ENDPOINT,
# s3_key: 'user_data',
# users_brick_input: {
# s3_bucket: GoodData::Environment::ConnectionHelper::SECRETS[:s3_bucket_name],
# s3_endpoint: Support::S3Helper::S3_ENDPOINT,
# s3_key: 'users_brick_input'
# }
# }
# @ads = GoodData::DataWarehouse.create(
# client: @rest_client,
# title: 'TEST ADS',
# auth_token: LcmConnectionHelper.environment[:prod_token]
# )
# @test_context[:jdbc_url] = @ads.data['connectionUrl']
# @ads_client = GoodData::Datawarehouse.new(
# @test_context[:config][:username],
# @test_context[:config][:password],
# nil,
# jdbc_url: @ads.data['connectionUrl']
# )
# query = 'CREATE TABLE IF NOT EXISTS "user_filters" (login VARCHAR(255) NOT NULL, state VARCHAR(255) NOT NULL, client_id VARCHAR(255));'
# @ads_client.execute(query)
# user_array.map do |u|
# insert = "INSERT INTO \"user_filters\" VALUES('#{u[:login]}', 'Oregon','#{u[:client_id]}');"
# @ads_client.execute(insert)
# end
# @test_context[:sync_mode] = 'sync_multiple_projects_based_on_custom_id'
# @test_context[:data_product] = @data_product_id
# @template_path = File.expand_path('../userprov/params/user_filters_brick_ads.json.erb', __dir__)
# @config_path = ConfigurationHelper.create_interpolated_tempfile(
# @template_path,
# @test_context
# )
# user_filters_schedule = BrickRunner.schedule_brick(
# 'user_filters_brick',
# service_project,
# context: @test_context,
# template_path: '../../../userprov/params/user_filters_brick_ads.json.erb',
# image_tag: image_tag,
# run_after: users_schedule
# )
end
it 'executes the schedules' do
#users_schedule.execute(wait: false)
end
it 'successfully finishes' do
# timeout = 3.hours
# results = GoodData::AppStore::Helper.wait_for_executions(
# [users_schedule, user_filters_schedule],
# timeout
# )
# results.each do |result|
# expect(result.status).to be :ok
# end
end
end
end