@@ -1830,117 +1830,3 @@ func TestBuildNginxResourceObjects_InferenceExtension(t *testing.T) {
18301830 g .Expect (containers [1 ].Name ).To (Equal ("endpoint-picker-shim" ))
18311831 g .Expect (containers [1 ].Command ).To (Equal (expectedCommands ))
18321832}
1833-
1834- func TestBuildNginxResourceObjects_NginxProxyConfigWithAccesslog (t * testing.T ) {
1835- t .Parallel ()
1836- g := NewWithT (t )
1837-
1838- agentTLSSecret := & corev1.Secret {
1839- ObjectMeta : metav1.ObjectMeta {
1840- Name : agentTLSTestSecretName ,
1841- Namespace : ngfNamespace ,
1842- },
1843- Data : map [string ][]byte {"tls.crt" : []byte ("tls" )},
1844- }
1845- fakeClient := fake .NewFakeClient (agentTLSSecret )
1846-
1847- provisioner := & NginxProvisioner {
1848- cfg : Config {
1849- GatewayPodConfig : & config.GatewayPodConfig {
1850- Namespace : ngfNamespace ,
1851- Version : "1.0.0" ,
1852- },
1853- AgentTLSSecretName : agentTLSTestSecretName ,
1854- },
1855- baseLabelSelector : metav1.LabelSelector {
1856- MatchLabels : map [string ]string {
1857- "app" : "nginx" ,
1858- },
1859- },
1860- k8sClient : fakeClient ,
1861- }
1862-
1863- gateway := & gatewayv1.Gateway {
1864- ObjectMeta : metav1.ObjectMeta {
1865- Name : "gw" ,
1866- Namespace : "default" ,
1867- },
1868- Spec : gatewayv1.GatewaySpec {
1869- Listeners : []gatewayv1.Listener {
1870- {Name : "port-8443" , Port : 8443 , Protocol : "tcp" },
1871- },
1872- },
1873- }
1874-
1875- resourceName := "gw-nginx"
1876- nProxyCfg := & graph.EffectiveNginxProxy {
1877- IPFamily : helpers .GetPointer (ngfAPIv1alpha2 .IPv4 ),
1878- Logging : & ngfAPIv1alpha2.NginxLogging {
1879- ErrorLevel : helpers .GetPointer (ngfAPIv1alpha2 .NginxLogLevelDebug ),
1880- AgentLevel : helpers .GetPointer (ngfAPIv1alpha2 .AgentLogLevelDebug ),
1881- LogFormat : & ngfAPIv1alpha2.LogFormat {
1882- Name : helpers .GetPointer ("custom_format" ),
1883- Format : helpers .GetPointer ("$remote_addr - [$time_local] \" $request\" $status $body_bytes_sent" ),
1884- },
1885- AccessLog : & ngfAPIv1alpha2.AccessLog {
1886- Path : helpers .GetPointer ("/var/log/nginx/access.log" ),
1887- Format : helpers .GetPointer ("custom_format" ),
1888- },
1889- },
1890- Metrics : & ngfAPIv1alpha2.Metrics {
1891- Port : helpers.GetPointer [int32 ](8080 ),
1892- },
1893- Kubernetes : & ngfAPIv1alpha2.KubernetesSpec {
1894- Service : & ngfAPIv1alpha2.ServiceSpec {
1895- ServiceType : helpers .GetPointer (ngfAPIv1alpha2 .ServiceTypeNodePort ),
1896- ExternalTrafficPolicy : helpers .GetPointer (ngfAPIv1alpha2 .ExternalTrafficPolicyCluster ),
1897- LoadBalancerIP : helpers .GetPointer ("1.2.3.4" ),
1898- LoadBalancerClass : helpers .GetPointer ("myLoadBalancerClass" ),
1899- LoadBalancerSourceRanges : []string {"5.6.7.8" },
1900- },
1901- Deployment : & ngfAPIv1alpha2.DeploymentSpec {
1902- Replicas : helpers.GetPointer [int32 ](3 ),
1903- Autoscaling : & ngfAPIv1alpha2.AutoscalingSpec {
1904- Enable : true ,
1905- MinReplicas : helpers.GetPointer [int32 ](1 ),
1906- MaxReplicas : 5 ,
1907- TargetMemoryUtilizationPercentage : helpers.GetPointer [int32 ](60 ),
1908- },
1909- Pod : ngfAPIv1alpha2.PodSpec {
1910- TerminationGracePeriodSeconds : helpers.GetPointer [int64 ](25 ),
1911- },
1912- Container : ngfAPIv1alpha2.ContainerSpec {
1913- Image : & ngfAPIv1alpha2.Image {
1914- Repository : helpers .GetPointer ("nginx-repo" ),
1915- Tag : helpers .GetPointer ("1.1.1" ),
1916- PullPolicy : helpers .GetPointer (ngfAPIv1alpha2 .PullAlways ),
1917- },
1918- Resources : & corev1.ResourceRequirements {
1919- Limits : corev1.ResourceList {
1920- corev1 .ResourceCPU : resource.Quantity {Format : "100m" },
1921- },
1922- },
1923- ReadinessProbe : & ngfAPIv1alpha2.ReadinessProbeSpec {
1924- Port : helpers.GetPointer [int32 ](9091 ),
1925- InitialDelaySeconds : helpers.GetPointer [int32 ](5 ),
1926- },
1927- HostPorts : []ngfAPIv1alpha2.HostPort {{ContainerPort : int32 (8443 ), Port : int32 (8443 )}},
1928- },
1929- },
1930- },
1931- }
1932-
1933- objects , err := provisioner .buildNginxResourceObjects (resourceName , gateway , nProxyCfg )
1934- g .Expect (err ).ToNot (HaveOccurred ())
1935-
1936- g .Expect (objects ).To (HaveLen (7 ))
1937-
1938- cmObj := objects [1 ]
1939- cm , ok := cmObj .(* corev1.ConfigMap )
1940- g .Expect (ok ).To (BeTrue ())
1941- g .Expect (cm .Data ).To (HaveKey ("main.conf" ))
1942- g .Expect (cm .Data ["main.conf" ]).To (ContainSubstring ("debug" ))
1943- g .Expect (cm .Data ["main.conf" ]).
1944- To (ContainSubstring ("log_format custom_format '$remote_addr - [$time_local] \" $request\" $status $body_bytes_sent';" ))
1945- g .Expect (cm .Data ["main.conf" ]).To (ContainSubstring ("access_log /var/log/nginx/access.log custom_format;" ))
1946- }
0 commit comments