Skip to content

Commit

Permalink
Update TP to use API v5 (#7766)
Browse files Browse the repository at this point in the history
* Update TP to use API v5

* Add changelog and update GHA

* Address feedback

* Missed a cachegroup

---------

Co-authored-by: Steve Hamrick <shamrick@apache.org>
  • Loading branch information
shamrickus and shamrickus committed Aug 31, 2023
1 parent 2257ddb commit d385dcb
Show file tree
Hide file tree
Showing 31 changed files with 230 additions and 230 deletions.
6 changes: 3 additions & 3 deletions .github/actions/tp-integration-tests/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -131,18 +131,18 @@ jq " .capabilities.chromeOptions.args = [
\"--no-sandbox\",
\"--disable-gpu\",
\"--ignore-certificate-errors\"
] | .params.apiUrl = \"${to_fqdn}/api/4.0\" | .params.baseUrl =\"${tp_fqdn}\"
] | .params.apiUrl = \"${to_fqdn}/api/5.0\" | .params.baseUrl =\"${tp_fqdn}\"
| .capabilities[\"goog:chromeOptions\"].w3c = false | .capabilities.chromeOptions.w3c = false" \
config.json > config.json.tmp && mv config.json.tmp config.json

npm run build

# Wait for tp/to build
timeout 5m bash <<TMOUT
while ! curl -Lvsk "${tp_fqdn}/api/4.0/ping" >/dev/null 2>&1; do
while ! curl -Lvsk "${tp_fqdn}/api/5.0/ping" >/dev/null 2>&1; do
echo "waiting for TP/TO server to start on '${tp_fqdn}'"
sleep 10
done
TMOUT

npm test -- --params.baseUrl="${tp_fqdn}" --params.apiUrl="${to_fqdn}/api/4.0"
npm test -- --params.baseUrl="${tp_fqdn}" --params.apiUrl="${to_fqdn}/api/5.0"
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/).
- [#7742](https://github.com/apache/trafficcontrol/pull/7742) *Traffic Ops* Changed api tests to supply the absolute path of certs.
- [#7718](https://github.com/apache/trafficcontrol/pull/7718) *Traffic Ops* `/servers` endpoint now responds with RFC3339 timestamps for all timestamp fields. Cleaned up naming conventions and superfluous data.
- [#7765](https://github.com/apache/trafficcontrol/pull/7765) *Traffic Stats* now uses Traffic Ops APIv5
- [#7766](https://github.com/apache/trafficcontrol/pull/7766) *Traffic Portal* now uses TO APIv5

### Fixed
- [#7767](https://github.com/apache/trafficcontrol/pull/7767) *Traffic Ops* Fixed ASN update logic for APIv5
Expand Down
12 changes: 6 additions & 6 deletions traffic_portal/app/src/common/api/DeliveryServiceService.js
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ class DeliveryServiceService {
* @returns {Promise<DeliveryService[]>} The response property of the response.
*/
async getDeliveryServices(params) {
const result = await this.$http.get(`${this.ENV.api.next}deliveryservices`, { params });
const result = await this.$http.get(`${this.ENV.api.unstable}deliveryservices`, { params });
return result.data.response;
}

Expand All @@ -110,7 +110,7 @@ class DeliveryServiceService {
* @returns {Promise<DeliveryService>} The requested Delivery Service.
*/
async getDeliveryService(id) {
const result = await this.$http.get(`${this.ENV.api.next}deliveryservices`, { params: { id } });
const result = await this.$http.get(`${this.ENV.api.unstable}deliveryservices`, { params: { id } });
return result.data.response[0];
}

Expand All @@ -124,7 +124,7 @@ class DeliveryServiceService {
// strip out any falsy values or duplicates from consistentHashQueryParams
ds.consistentHashQueryParams = Array.from(new Set(ds.consistentHashQueryParams)).filter(i => i);

const response = await this.$http.post(`${this.ENV.api.next}deliveryservices`, ds);
const response = await this.$http.post(`${this.ENV.api.unstable}deliveryservices`, ds);
return response.data;
}

Expand All @@ -138,7 +138,7 @@ class DeliveryServiceService {
// strip out any falsy values or duplicates from consistentHashQueryParams
ds.consistentHashQueryParams = Array.from(new Set(ds.consistentHashQueryParams)).filter(i => i);

const response = await this.$http.put(`${this.ENV.api.next}deliveryservices/${ds.id}`, ds);
const response = await this.$http.put(`${this.ENV.api.unstable}deliveryservices/${ds.id}`, ds);
return response.data;
}

Expand All @@ -149,7 +149,7 @@ class DeliveryServiceService {
* @returns {Promise<{alerts: {level: string; text: string}[]}>} The full API response
*/
async deleteDeliveryService(ds) {
const response = await this.$http.delete(`${this.ENV.api.next}deliveryservices/${ds.id}`);
const response = await this.$http.delete(`${this.ENV.api.unstable}deliveryservices/${ds.id}`);
return response.data;
}

Expand Down Expand Up @@ -219,7 +219,7 @@ class DeliveryServiceService {
* @returns {Promise<DeliveryService[]>} The Delivery Services for which the identified server is responsible for serving content.
*/
async getServerDeliveryServices(serverID) {
const result = await this.$http.get(`${this.ENV.api.next}servers/${serverID}/deliveryservices`);
const result = await this.$http.get(`${this.ENV.api.unstable}servers/${serverID}/deliveryservices`);
return result.data.response;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ var FormServerController = function(server, $scope, $location, $state, $uibModal
var getPhysLocations = function() {
physLocationService.getPhysLocations()
.then(function(result) {
$scope.physLocations = result;
$scope.physicalLocations = result;
});
};

Expand Down Expand Up @@ -87,10 +87,10 @@ var FormServerController = function(server, $scope, $location, $state, $uibModal
$scope.addProfile = function() {
$scope.serverForm.$setDirty();

if (!$scope.server.profileNames) {
$scope.server.profileNames = [null];
if (!$scope.server.profiles) {
$scope.server.profiles = [null];
} else {
$scope.server.profileNames.push(null);
$scope.server.profiles.push(null);
}
}

Expand All @@ -105,7 +105,7 @@ var FormServerController = function(server, $scope, $location, $state, $uibModal

$scope.deleteProfile = function(index) {
$scope.serverForm.$setDirty();
$scope.server.profileNames.splice(index, 1);
$scope.server.profiles.splice(index, 1);
}

var updateStatus = function(status) {
Expand Down Expand Up @@ -184,8 +184,8 @@ var FormServerController = function(server, $scope, $location, $state, $uibModal
}

$scope.onCDNChange = function() {
$scope.server.profileId = null; // the cdn of the server changed, so we need to blank out the selected server profile (if any)
getProfiles($scope.server.cdnId); // and get a new list of profiles (for the selected cdn)
$scope.server.profileID = null; // the cdn of the server changed, so we need to blank out the selected server profile (if any)
getProfiles($scope.server.cdnID); // and get a new list of profiles (for the selected cdn)
};

$scope.isLargeCIDR = function(address) {
Expand Down Expand Up @@ -264,7 +264,10 @@ var FormServerController = function(server, $scope, $location, $state, $uibModal
getCacheGroups();
getTypes();
getCDNs();
getProfiles(($scope.server.cdnId) ? $scope.server.cdnId : 0); // hacky but does the job. only when a cdn is selected can we fetch the appropriate profiles. otherwise, show no profiles.
getProfiles(($scope.server.cdnID) ? $scope.server.cdnID : 0); // hacky but does the job. only when a cdn is selected can we fetch the appropriate profiles. otherwise, show no profiles.

$scope.server.revalPending = $scope.server.revalApplyTime && $scope.server.revalUpdateTime && $scope.server.revalApplyTime < $scope.server.RevalUpdateTime;
$scope.server.updPending = $scope.server.configApplyTime && $scope.server.configUpdateTime && $scope.server.configApplyTime < $scope.server.configUpdateTime;
};
init();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@

<label for="status">Status *</label>
<div>
<select id="status" name="status" class="form-control" ng-model="server.statusId" ng-options="status.id as status.name for status in statuses" ng-disabled="!settings.isNew"></select>
<select id="status" name="status" class="form-control" ng-model="server.statusID" ng-options="status.id as status.name for status in statuses" ng-disabled="!settings.isNew"></select>
</div>

<label ng-if="!settings.isNew" for="statusLastUpdated">Status Last Updated</label>
Expand Down Expand Up @@ -85,29 +85,28 @@

<label for="cdn" ng-class="{'has-error': hasError(serverForm.cdn)}">CDN *</label>
<div ng-class="{'has-error': hasError(serverForm.cdn), 'has-feedback': hasError(serverForm.cdn)}">
<select name="cdn" id="cdn" class="form-control" ng-change="onCDNChange()" ng-model="server.cdnId" ng-options="cdn.id as cdn.name for cdn in cdns" required>
<select name="cdn" id="cdn" class="form-control" ng-change="onCDNChange()" ng-model="server.cdnID" ng-options="cdn.id as cdn.name for cdn in cdns" required>
<option hidden selected disabled value="">Select...</option>
</select>
<small class="input-error" ng-show="hasPropertyError(serverForm.cdn, 'required')">Required</small>
<small ng-show="server.cdnId"><a ng-href="/#!/cdns/{{server.cdnId}}" target="_blank">View Details&nbsp;&nbsp;<i class="fa fs-xs fa-external-link"></i></a></small>
<small ng-show="server.cdnID"><a ng-href="/#!/cdns/{{server.cdnID}}" target="_blank">View Details&nbsp;&nbsp;<i class="fa fs-xs fa-external-link"></i></a></small>
</div>

<label for="cachegroup" ng-class="{'has-error': hasError(serverForm.cachegroup)}">Cache Group *</label>
<div ng-class="{'has-error': hasError(serverForm.cachegroup), 'has-feedback': hasError(serverForm.cachegroup)}">
<select id="cachegroup" name="cachegroup" class="form-control" ng-model="server.cachegroupId" ng-options="cachegroup.id as cachegroup.name for cachegroup in cacheGroups" required>
<label for="cachegroup" ng-class="{'has-error': hasError(serverForm.cacheGroup)}">Cache Group *</label>
<div ng-class="{'has-error': hasError(serverForm.cacheGroup), 'has-feedback': hasError(serverForm.cacheGroup)}">
<select id="cachegroup" name="cachegroup" class="form-control" ng-model="server.cacheGroupID" ng-options="cacheGroup.id as cacheGroup.name for cacheGroup in cacheGroups" required>
<option hidden selected disabled value="">Select...</option>
</select>
<small class="input-error" ng-show="hasPropertyError(serverForm.cachegroup, 'required')">Required</small>
<small ng-show="server.cachegroupId"><a ng-href="/#!/cache-groups/{{server.cachegroupId}}" target="_blank">View Details&nbsp;&nbsp;<i class="fa fs-xs fa-external-link"></i></a></small>
<small class="input-error" ng-show="hasPropertyError(serverForm.cacheGroup, 'required')">Required</small>
<small ng-show="server.cacheGroupID"><a ng-href="/#!/cache-groups/{{server.cacheGroupID}}" target="_blank">View Details&nbsp;&nbsp;<i class="fa fs-xs fa-external-link"></i></a></small>
</div>

<label for="type" ng-class="{'has-error': hasError(serverForm.type)}">Type *</label>
<div ng-class="{'has-error': hasError(serverForm.type), 'has-feedback': hasError(serverForm.type)}">
<select id="type" name="type" class="form-control" ng-model="server.typeId" ng-options="type.id as type.name for type in types" required>
<select id="type" name="type" class="form-control" ng-model="server.typeID" ng-options="type.id as type.name for type in types" required>
<option hidden selected disabled value="">Select...</option>
</select>
<small class="input-error" ng-show="hasPropertyError(serverForm.type, 'required')">Required</small>
<small ng-show="server.typeId"><a ng-href="/#!/types/{{server.typeId}}" target="_blank">View Details&nbsp;&nbsp;<i class="fa fs-xs fa-external-link"></i></a></small>
<small ng-show="server.typeID"><a ng-href="/#!/types/{{server.typeID}}" target="_blank">View Details&nbsp;&nbsp;<i class="fa fs-xs fa-external-link"></i></a></small>
</div>

<fieldset>
Expand All @@ -120,25 +119,25 @@
For example, P1 and P2 are two profiles associated with a server, S1. Parameters of P1 will have a <u>higher</u> priority over that of P2.
And if there exists parameters with same name but different values, then P1's parameters will <b>not</b> be overwritten.
</p>
<fieldset ng-repeat="profile in server.profileNames track by $index"> {{$index + 1}}
<fieldset ng-repeat="profile in server.profiles track by $index"> {{$index + 1}}
<select ng-class="{'has-error': hasPropertyError(serverForm['activeProfile-'+$index], 'required'), 'has-feedback': hasPropertyError(serverForm['activeProfile-'+$index], 'required')}"
id="activeProfile-{{$index}}" name="activeProfile-{{$index}}" class="form-control" ng-model="server.profileNames[$index]"
ng-options="profile.name as profile.name for profile in profiles|excludeFilter:profile:server.profileNames" required>
id="activeProfile-{{$index}}" name="activeProfile-{{$index}}" class="form-control" ng-model="server.profiles[$index]"
ng-options="profile.name as profile.name for profile in profiles|excludeFilter:profile:server.profiles" required>
<option hidden selected disabled value="">Select...</option>
</select>
<small class="input-error" ng-show="hasPropertyError(serverForm['activeProfile-'+$index], 'required')">Required</small>
<a ng-href="{{getProfileID(server.profileNames[$index])}}" target="_blank">View Details&nbsp;&nbsp;<i class="fa fs-xs fa-external-link"></i></a>
<button class="btn btn-danger right-button btn-xs" type="button" title="remove this profile from the server" ng-if="server.profileNames.length>1" ng-click="deleteProfile($index)"><i class="fa fa-minus"></i></button>
<a ng-href="{{getProfileID(server.profiles[$index])}}" target="_blank">View Details&nbsp;&nbsp;<i class="fa fs-xs fa-external-link"></i></a>
<button class="btn btn-danger right-button btn-xs" type="button" title="remove this profile from the server" ng-if="server.profiles.length>1" ng-click="deleteProfile($index)"><i class="fa fa-minus"></i></button>
</fieldset>
</fieldset>

<label for="physLocation" ng-class="{'has-error': hasError(serverForm.physLocation)}">Physical Location *</label>
<div ng-class="{'has-error': hasError(serverForm.physLocation), 'has-feedback': hasError(serverForm.physLocation)}">
<select id="physLocation" name="physLocation" class="form-control" ng-model="server.physLocationId" ng-options="physLocation.id as physLocation.name for physLocation in physLocations" required>
<label for="physicalLocation" ng-class="{'has-error': hasError(serverForm.physicalLocation)}">Physical Location *</label>
<div ng-class="{'has-error': hasError(serverForm.physicalLocation), 'has-feedback': hasError(serverForm.physicalLocation)}">
<select id="physicalLocation" name="physicalLocation" class="form-control" ng-model="server.physicalLocationID" ng-options="pL.id as pL.name for pL in physicalLocations" required>
<option value="">Select...</option>
</select>
<small class="input-error" ng-show="hasPropertyError(serverForm.physLocation, 'required')">Required</small>
<small ng-show="server.physLocationId"><a ng-href="/#!/phys-locations/{{server.physLocationId}}" target="_blank">View Details&nbsp;&nbsp;<i class="fa fs-xs fa-external-link"></i></a></small>
<small class="input-error" ng-show="hasPropertyError(serverForm.physicalLocation, 'required')">Required</small>
<small ng-show="server.physicalLocationID"><a ng-href="/#!/phys-locations/{{server.physicalLocationID}}" target="_blank">View Details&nbsp;&nbsp;<i class="fa fs-xs fa-external-link"></i></a></small>
</div>

<label for="tcpPort" ng-class="{'has-error': hasError(serverForm.tcpPort)}">TCP Port</label>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ var FormNewServerController = function(server, $anchorScroll, $scope, $controlle
$scope.statuses = result;
// Issue #2651 - Enabling server status for New Server but still defaulting enabled dropdown to OFFLINE
const offlineStatus = result.find(status => status.name === 'OFFLINE');
$scope.server.statusId = offlineStatus.id;
$scope.server.statusID = offlineStatus.id;
});
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,10 @@ var TableAssignDSServersController = function(deliveryService, servers, assigned
headerName: "Profile(s)",
field: "profile",
valueGetter: function(params) {
return params.data.profileNames;
return params.data.profiles;
},
tooltipValueGetter: function(params) {
return params.data.profileNames.join(", ");
return params.data.profiles.join(", ");
}
}
];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,12 @@ var TableServersController = function(servers, $scope, $state, $uibModal, locati
$scope.columns = [
{
headerName: "Cache Group",
field: "cachegroup",
field: "cacheGroup",
hide: false
},
{
headerName: "CDN",
field: "cdnName",
field: "cdn",
hide: false
},
{
Expand Down Expand Up @@ -170,18 +170,18 @@ var TableServersController = function(servers, $scope, $state, $uibModal, locati
},
{
headerName: "Phys Location",
field: "physLocation",
field: "physicalLocation",
hide: true
},
{
headerName: "Profile(s)",
field: "profileName",
hide: false,
valueGetter: function(params) {
return params.data.profileNames;
return params.data.profiles;
},
tooltipValueGetter: function(params) {
return params.data.profileNames.join(", ");
return params.data.profiles.join(", ");
},
filter: 'arrayTextColumnFilter'
},
Expand Down Expand Up @@ -384,9 +384,11 @@ var TableServersController = function(servers, $scope, $state, $uibModal, locati
function(x) {
x.lastUpdated = x.lastUpdated ? new Date(x.lastUpdated.replace("+00", "Z")) : x.lastUpdated;
x.statusLastUpdated = x.statusLastUpdated ? new Date(x.statusLastUpdated): x.statusLastUpdated;
x.revalPending = x.revalApplyTime && x.revalUpdateTime && x.revalApplyTime < x.RevalUpdateTime;
x.updPending = x.configApplyTime && x.configUpdateTime && x.configApplyTime < x.configUpdateTime;
Object.assign(x, serverUtils.toLegacyIPInfo(x.interfaces));
if (x.profileNames !== undefined) {
x.profileName = x.profileNames[0]
if (x.profiles !== undefined) {
x.profileName = x.profiles[0]
}
return x;
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ module.exports = angular.module('trafficPortal.private.servers.new', [])
monitor: true
}
],
profileNames: []
profiles: []
};
}
}
Expand Down
2 changes: 1 addition & 1 deletion traffic_portal/app/src/scripts/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,4 @@

angular.module('config', [])

.constant('ENV', { api: { next: "/api/5.0/", unstable:'/api/4.1/', stable: "/api/4.0/" } });
.constant('ENV', { api: { next: "/api/5.0/", unstable:'/api/5.0/', stable: "/api/4.1/" } });
11 changes: 8 additions & 3 deletions traffic_portal/test/integration/CommonUtils/API.ts
Original file line number Diff line number Diff line change
Expand Up @@ -302,6 +302,11 @@ export class API {
if(hasProperty(data, 'requiredCapability')) {
data.requiredCapability = data.requiredCapability + randomize;
}
if(hasProperty(data, 'requiredCapabilities', 'Array')) {
data.requiredCapabilities.forEach((_cap, i) => {
data.requiredCapabilities[i] += randomize;
})
}
if(hasProperty(data, 'serverCapability')) {
data.serverCapability = data.serverCapability + randomize;
}
Expand Down Expand Up @@ -337,9 +342,9 @@ export class API {
}
}
}
if(hasProperty(data, 'profileNames', "Array")){
for (const index in data.profileNames) {
data.profileNames[index] = data.profileNames[index]+randomize
if(hasProperty(data, 'profiles', "Array")){
for (const index in data.profiles) {
data.profiles[index] = data.profiles[index]+randomize
}
}
}
Expand Down

0 comments on commit d385dcb

Please sign in to comment.