ocket8888 commented on a change in pull request #5502:
URL: https://github.com/apache/trafficcontrol/pull/5502#discussion_r571300737



##########
File path: traffic_ops/testing/api/v4/servers_test.go
##########
@@ -885,6 +886,7 @@ func UpdateTestServers(t *testing.T) {
 
        originalHostname := *resp.Response[0].HostName
        originalXMPIDD := *resp.Response[0].XMPPID
+       originalMTU := *resp.Response[0].Interfaces[0].MTU

Review comment:
       This check should go down below the check for `len(infs)` on line 896 to 
avoid a segfault. For the same reason, should also check that MTU is not `nil` 
before dereferencing it

##########
File path: 
traffic_ops/app/db/migrations/2021020500000000_change_mtu_check_interfaces.sql
##########
@@ -0,0 +1,21 @@
+/*
+    Licensed under the Apache License, Version 2.0 (the "License");
+    you may not use this file except in compliance with the License.
+    You may obtain a copy of the License at
+        http://www.apache.org/licenses/LICENSE-2.0
+    Unless required by applicable law or agreed to in writing, software
+    distributed under the License is distributed on an "AS IS" BASIS,
+    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+    See the License for the specific language governing permissions and
+    limitations under the License.
+*/
+
+-- +goose Up
+-- SQL in section 'Up' is executed when this migration is applied
+ALTER TABLE interface DROP CONSTRAINT interface_mtu_check;
+ALTER TABLE interface ADD CONSTRAINT interface_mtu_check CHECK (((mtu IS NULL) 
OR (mtu >= 1280)));
+
+-- +goose Down
+-- SQL section 'Down' is executed when this migration is rolled back
+ALTER TABLE interface DROP CONSTRAINT interface_mtu_check;
+ALTER TABLE interface ADD CONSTRAINT interface_mtu_check CHECK (((mtu IS NULL) 
OR (mtu > 1280)));

Review comment:
       Missing newline at EOF

##########
File path: traffic_ops/testing/api/v4/servers_test.go
##########
@@ -950,6 +954,11 @@ func UpdateTestServers(t *testing.T) {
                t.Fatalf("Cannot test server type change update; server '%s' 
had nil type ID", hostName)
        }
 
+       // Check to verify mtu changed
+       if originalMTU == *respServer.Interfaces[0].MTU {

Review comment:
       Need to check that `respServer.Interfaces` has a length of at least one, 
and that the 0<sup>th</sup> element has a non-`nil` MTU before dereferencing 
like this, to avoid a segfault.

##########
File path: traffic_ops/testing/api/v4/servers_test.go
##########
@@ -950,6 +954,11 @@ func UpdateTestServers(t *testing.T) {
                t.Fatalf("Cannot test server type change update; server '%s' 
had nil type ID", hostName)
        }
 
+       // Check to verify mtu changed
+       if originalMTU == *respServer.Interfaces[0].MTU {
+               t.Errorf("MTU value didn't update. Expected: #{*updatedMTU}, 
actual: #{*originalMTU}")

Review comment:
       I don't think this is going to print out the values, I think this will 
just literally print out
   ```
   MTU value didn't update. Expected: #{*updatedMTU}, actual: #{*originalMTU}
   ```




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to