require 'helix_web_services_client' require 'uri' require 'P4' #------------------------------------------------------------------------------ # Configuration #------------------------------------------------------------------------------ WS_URL = URI(ENV['WS_URL'] || 'http://localhost:9000/') # This is used to prepare a shelved changelist for the 'submit_change' method P4PORT = ENV['P4PORT'] || 'localhost:1666' TMP_FOLDER = '/tmp/clients' DELETE_CLIENT = !ENV.key?('KEEP_WORKSPACES') CHARSET = ENV['P4CHARSET'] || 'auto' JDOE_USER = 'jdoe' JDOE_PASSWORD = 'johndoe1A!' SUPER_USER = 'super' SUPER_PASSWORD = 'superuser1A!' #------------------------------------------------------------------------------ # Helpers #------------------------------------------------------------------------------ def client_as_jdoe client = HelixWebServicesClient.new( url: WS_URL, user: 'jdoe', password: 'johndoe1A!', ssl: {verify: false} ) yield client ensure client.close if client end def client_as_super client = HelixWebServicesClient.new( url: WS_URL, user: 'super', password: 'superuser1A!', ssl: {verify: false} ) yield client ensure client.close if client end def p4_as_jdoe p4 = P4.new # Make P4Ruby only raise exceptions if there are errors. Warnings # (such as 'no such file(s)' don't get the same treatment. p4.exception_level = P4::RAISE_ERRORS p4.port = P4PORT p4.user = JDOE_USER p4.password = JDOE_PASSWORD p4.charset = CHARSET unless CHARSET.nil? || CHARSET == 'none' p4.connect results = p4.run_login('-p') p4.password = results.first yield p4 if block_given? return p4 ensure p4.disconnect if block_given? end def temp_client_as_jdoe(&block) p4_as_jdoe do |p4| unless Dir.exists?(TMP_FOLDER) FileUtils.makedirs(TMP_FOLDER) end name = (0...8).map { (65 + rand(26)).chr }.join root = File.join(TMP_FOLDER, name) Dir.mkdir(root) p4.client = name spec = p4.fetch_client spec._root = root spec._client = name spec._description = 'test client' # When there's one depot, the view generated maps //depot/... //view/... # instead of //depot/... //view/depot/... like it will with multiple depots. if (spec._view.length == 1) spec._view = ["//depot/... //#{name}/depot/..."] end p4.save_client(spec) p4.run_sync('//...') block.call(p4, root) if DELETE_CLIENT p4.user = SUPER_USER p4.password = SUPER_PASSWORD results = p4.run_login('-p') p4.password = results.first p4.run_client('-d', '-f', name) FileUtils.rmtree(root) end end end def temp_stream_client_as_jdoe(&block) p4_as_jdoe do |p4| name = (0...8).map { (65 + rand(26)).chr }.join # Create a stream in the stream-test depot stream_spec = p4.fetch_stream("//stream-test/main-#{name}") stream_spec._type = 'mainline' stream_spec._parent = 'none' p4.save_stream(stream_spec) unless Dir.exists?(TMP_FOLDER) FileUtils.makedirs(TMP_FOLDER) end root = File.join(TMP_FOLDER, name) Dir.mkdir(root) p4.client = name spec = p4.fetch_client spec._root = root spec._client = name spec._description = 'test client' spec._view = nil spec._stream = "//stream-test/main-#{name}" p4.save_client(spec) p4.run_sync('//...') block.call(p4, root, "//stream-test/main-#{name}") if DELETE_CLIENT p4.user = SUPER_USER p4.password = SUPER_PASSWORD results = p4.run_login('-p') p4.password = results.first p4.run_client('-d', '-f', name) FileUtils.rmtree(root) end end end
# | Change | User | Description | Committed | |
---|---|---|---|---|---|
#1 | 15741 | ptomiak | Branch HWS for my use. | ||
//guest/perforce_software/helix-web-services/main/source/helix_web_services_client/spec/test_config.rb | |||||
#1 | 15622 | tjuricek |
Move source code to 'source/' subdirectory of branch. build/ will remain where it is. |
||
//guest/perforce_software/helix-web-services/main/helix_web_services_client/spec/test_config.rb | |||||
#5 | 15147 | tjuricek |
Enable submissions by files on stream clients This obeys our earlier rules: notably the local client must not have any local files open for edit. |
||
#4 | 15142 | tjuricek |
Use the super permission to clean up clients used in tests. For whatever reason, when I was testing this using a localhost connection, I never ran into this issue. Might be special rules to avoid permission checks locally? |
||
#3 | 15133 | tjuricek | Fix case to require 'P4' statement: "require 'p4'" only works on a case-insensitive system. | ||
#2 | 15132 | tjuricek | Provde a basic submit -e mechanism on classic perforce workspaces. | ||
#1 | 15059 | tjuricek | Tested authentication of the core /auth/v1/login method. | ||
//guest/perforce_software/helix-web-services/main/helix_web_services_client/spec/test_connections.rb | |||||
#4 | 15053 | tjuricek |
Revise the client API to use the new login method. The current specs will need to be revised since data normalization is moving out of the server and into the client. |
||
#3 | 14899 | tjuricek | Do not verify SSL certs in tests, and make sure the right DB file is used by our startup script. | ||
#2 | 14898 | tjuricek |
Specify the entire host string when executing tests against a remote host. The new package sets up vs a self-signed cert, so now we can watch failures over SSL. |
||
#1 | 13799 | tjuricek |
Start with branch specs hosting in a new monolithic 'helix web services' project. Converting from a microservice to a monolithic architecture due to resource constraints at getting a deployable system running. Additionally, since it's not expected that people will upgrade often, the major benefit of microservices - being able to add services individually without affecting others - is not really a major benefit. The Ruby SDK will be consolidated into a single 'helix web services client' project. It may end up being distributed via Rubygems. This only runs branch specs at the moment. I want to get a CD pipeline setup for the monolithic server before revising more methods. |