Jump to content


Review Enforcement on Windows

Windows Review Enforcement Swarm

  • Please log in to reply
19 replies to this topic

#1 neklund

neklund

    Member

  • Members
  • PipPip
  • 13 posts

Posted 19 December 2013 - 02:48 PM

I found the Review Enforcement doc for Swarm and was happy to see it already existed only to be greeted by this note:
These capabilities are currently not available for a Perforce service running on a Windows host.

Before I dive in to making those capabilities available on Windows I was wondering if anyone could let me know if this is due to simple lack of implementation or if there's something about the windows Perforce service that is preventing it from working.

Thanks,
Nate

#2 P4Matt

P4Matt

    Advanced Member

  • Members
  • PipPipPip
  • 1383 posts

Posted 19 December 2013 - 06:18 PM

Simple lack of implementation. The original was written in bash and we just haven't ported the logic to Windows yet. I've added you to the request for it in our issue tracker.

#3 neklund

neklund

    Member

  • Members
  • PipPip
  • 13 posts

Posted 19 December 2013 - 09:12 PM

Great, thanks Matt.

#4 neklund

neklund

    Member

  • Members
  • PipPip
  • 13 posts

Posted 31 December 2013 - 03:52 PM

I just started porting the enforcement logic from swarm-trigger.sh into a Perl script and have run into an interesting issue.  I'm sure it's something simple that I'm missing...

On Windows when I execute this command line in a command prompt I get no output:
p4 -p cocoderepo01:1667 -u p4dtg-csr search 1301=35353232383

When I execute it on Linux I get this:
p4 -p cocoderepo01:1667 -u p4dtg-csr search 1301=35353232383
swarm-review-ffff2842

They are hitting the same Perforce server, so it seems that there is a difference between the search function (which I can't find documentation for) on Windows and Linux.

Any idea what I'm doing wrong here?

Thanks,
Nate

#5 P4Matt

P4Matt

    Advanced Member

  • Members
  • PipPipPip
  • 1383 posts

Posted 31 December 2013 - 05:39 PM

That's really odd; 'p4 search' like most Perforce commands in fact, is run entirely on the server. There's no platform specific code for it. The help for it is very minimal. 'p4 help search' will you give you the minimal documentation on the command.

My first guess was that the '=' sign was being interpreted by the Windows command prompt, but I tested and that and it works fine. Do you have IP based protections entries for p4dtg-csr? I'm wondering if it doesn't have access to the server from the Windows machine.

#6 neklund

neklund

    Member

  • Members
  • PipPip
  • 13 posts

Posted 31 December 2013 - 06:00 PM

I had similar thoughts about the = character being interpreted by Windows cmd and tried escaping it a few different ways.  I also tried running it from another Windows machine.

We do not have any IP-based protections.

Here is the server "all" log for the search command from linux, from my workstation and from the p4 client running on the server itself.
0,1388512508,122000000,2013/12/31 11:55:08 122000000,5524,1,p4dtg-csr,SVR-Source02,user-search,192.168.200.59,p4,2012.1/LINUX26X86/473528,1301=3535323238
2,1388512508,122000000,2013/12/31 11:55:08 122000000,5524,1,p4dtg-csr,SVR-Source02,user-search,192.168.200.59,p4,2012.1/LINUX26X86/473528,1301=3535323238

0,1388512544,639000000,2013/12/31 11:55:44 639000000,4288,1,p4dtg-csr,vss,user-search,192.168.200.116,p4,2010.2/NTX86/295040,1301=35353232383
2,1388512544,639000000,2013/12/31 11:55:44 639000000,4288,1,p4dtg-csr,vss,user-search,192.168.200.116,p4,2010.2/NTX86/295040,1301=35353232383

0,1388512598,546000000,2013/12/31 11:56:38 546000000,3548,1,p4dtg-csr,neklund_DVLP-NEKLUND1_Training1,user-search,192.168.230.107,p4,2013.2/NTX86/719516,1301=35353232383
2,1388512598,546000000,2013/12/31 11:56:38 546000000,3548,1,p4dtg-csr,neklund_DVLP-NEKLUND1_Training1,user-search,192.168.230.107,p4,2013.2/NTX86/719516,1301=35353232383

#7 P4Matt

P4Matt

    Advanced Member

  • Members
  • PipPipPip
  • 1383 posts

Posted 31 December 2013 - 06:54 PM

Grasping at straws here, but the command line is pretty old on your workstation. Can you try with a more modern version? That shouldn't be it, but I'm at a loss right now.

#8 neklund

neklund

    Member

  • Members
  • PipPip
  • 13 posts

Posted 02 January 2014 - 06:05 PM

The version on the server is 1010.2, however the version on my workstation is 2013.2.  I was hoping that might be the answer, but I think my workstation has the latest version of the client.

Here's my output from p4 -V
Perforce - The Fast Software Configuration Management System.
Copyright 1995-2013 Perforce Software.  All rights reserved.
This product includes software developed by the OpenSSL Project for use in the OpenSSL Toolkit (http://www.openssl.org/)
See 'p4 help legal' for full OpenSSL license information
Version of OpenSSL Libraries: OpenSSL 1.0.1c 10 May 2012
Rev. P4/NTX86/2013.2/719516 (2013/10/09).

#9 P4Matt

P4Matt

    Advanced Member

  • Members
  • PipPipPip
  • 1383 posts

Posted 03 January 2014 - 06:39 PM

Curses. I hate it when straw grasping fails.

Do you have any jobs in your Perforce server? ("p4 jobs") They effectively use 'p4 search' to do their queries, so it would be interesting to try a couple jobs queries.

Also do you get anything with 'p4 -p cocoderepo01:1667 -u p4dtg-csr search 1301=*'

#10 neklund

neklund

    Member

  • Members
  • PipPip
  • 13 posts

Posted 03 January 2014 - 06:50 PM

Yes, our QA department has been using jobs to track some of their stuff, so we have quite a few.

I do get output with the wildcard search!
C:\>p4 -p cocoderepo01:1667 -u p4dtg-csr search 1301=*
swarm-review-ffff2842
swarm-review-ffff2845
swarm-review-ffff284a
swarm-review-ffff2869

#11 P4Matt

P4Matt

    Advanced Member

  • Members
  • PipPipPip
  • 1383 posts

Posted 03 January 2014 - 06:55 PM

Okay, so we know that you can get output, so that's a bold step forward. Now you've been diving into a part of Swarm I haven't, so I have to ask, how did you get the number '35353232383'? I'm not sure how to get the key to do the search in the first place; thus my kludgy, but effective, '*' search. =)

#12 neklund

neklund

    Member

  • Members
  • PipPip
  • 13 posts

Posted 03 January 2014 - 07:21 PM

In swarm-trigger.sh this is the code that grabs the review key from perforce:
# Search for the review key based on the encoded change number
CMD="$P4_CMD search 1301=$(echo $VALUE | $SED -e 's,\(.\),3\1,g')"
REVIEW_KEY=`$CMD | $SED '1q'`
RC=$?

I am using the command "echo $Change_Num | sed -e 's,\(.\),3\1,g'" to grab the key in my script.  It essentially just wraps each character in the changelist number in '3' characters.

edit: I put the wrong command line from my script up there.

#13 P4Matt

P4Matt

    Advanced Member

  • Members
  • PipPipPip
  • 1383 posts

Posted 03 January 2014 - 08:08 PM

Try 'p4 -p cocoderepo01:1667 -u p4dtg-csr search 1301=3535323238'.  Looking at your logout output:


Quote

Here is the server "all" log for the search command from linux, from my workstation and from the p4 client running on the server itself.
0,1388512508,122000000,2013/12/31 11:55:08 122000000,5524,1,p4dtg-csr,SVR-Source02,user-search,192.168.200.59,p4,2012.1/LINUX26X86/473528,1301=3535323238
2,1388512508,122000000,2013/12/31 11:55:08 122000000,5524,1,p4dtg-csr,SVR-Source02,user-search,192.168.200.59,p4,2012.1/LINUX26X86/473528,1301=3535323238

0,1388512544,639000000,2013/12/31 11:55:44 639000000,4288,1,p4dtg-csr,vss,user-search,192.168.200.116,p4,2010.2/NTX86/295040,1301=35353232383
2,1388512544,639000000,2013/12/31 11:55:44 639000000,4288,1,p4dtg-csr,vss,user-search,192.168.200.116,p4,2010.2/NTX86/295040,1301=35353232383

0,1388512598,546000000,2013/12/31 11:56:38 546000000,3548,1,p4dtg-csr,neklund_DVLP-NEKLUND1_Training1,user-search,192.168.230.107,p4,2013.2/NTX86/719516,1301=35353232383
2,1388512598,546000000,2013/12/31 11:56:38 546000000,3548,1,p4dtg-csr,neklund_DVLP-NEKLUND1_Training1,user-search,192.168.230.107,p4,2013.2/NTX86/719516,1301=35353232383

Two of those queries end in a 3, one ends in an 8. From my experiments it appears that we don't wrap the last number in 3's.

#14 neklund

neklund

    Member

  • Members
  • PipPip
  • 13 posts

Posted 03 January 2014 - 08:17 PM

Wow, thanks for pointing out my failure at reading!  That is definitely the issue.

Now to figure out why sed on Windows did the wrong thing...

Thanks for your help, I'll keep you up to date on any progress!

#15 neklund

neklund

    Member

  • Members
  • PipPip
  • 13 posts

Posted 06 January 2014 - 08:21 PM

Alright!  I now have a quick and dirty Perl translation of the enforcement logic from swarm-trigger.sh.  

I just scrapped the use of SED and used Perl RegExes instead.

#16 P4Matt

P4Matt

    Advanced Member

  • Members
  • PipPipPip
  • 1383 posts

Posted 06 January 2014 - 09:53 PM

Sweet! Did you make any modifications while you were in there or keep it pretty much the same?

#17 neklund

neklund

    Member

  • Members
  • PipPip
  • 13 posts

Posted 06 January 2014 - 09:58 PM

I added long options, changed -v to -c for the change number, and added --checkparticipants.  \

Checkparticipants just looks to make sure someone other than the author participated in the review so that people can't mark their own changes as approved without getting someone else involved.  It's not perfect logic, but it's a decent start.  I may change it to check the changelist user against the participant list.  Ideally I would like to be able to pull out the swarm user that set the review to approved, but I don't see that in the JSON for the review.

Other than that it's the same.

#18 jburke

jburke

    Member

  • Members
  • PipPip
  • 16 posts

Posted 25 October 2014 - 12:23 AM

Hi, is the Windows enforcement script available anywhere for download? I'd like to use it as well.

#19 Andrew DeFaria

Andrew DeFaria

    Advanced Member

  • Members
  • PipPipPip
  • 125 posts

Posted 31 October 2014 - 05:59 PM

That was exactly the place where I looked into the Bash script and said "What's this stuff???". Everything else was pretty straight forward and easily portable to Perl. I was about to ask P4Matt to explain what's being done there so I could translate but then my client said not to spend time porting their code and instead work on moving Perforce from Windows -> Linux. I think that that's a better move anyway.

Would love to see you code. Meantime you might want to run it through http://perl-critic.stacka.to/.

#20 jburke

jburke

    Member

  • Members
  • PipPip
  • 16 posts

Posted 31 October 2014 - 09:32 PM

Right now, I'm stuck with a Windows Perforce server. Will likely be investigating a migration to Linux at some point....



Also tagged with one or more of these keywords: Windows, Review Enforcement, Swarm

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users